diff --git a/Framework/PythonInterface/mantid/kernel/_aliases.py b/Framework/PythonInterface/mantid/kernel/_aliases.py index 11e69e16a28fe6f053b7868211333ae0ef0bd9b2..b6ac466b9d7ce5a992507530126fd7d8bdd6036e 100644 --- a/Framework/PythonInterface/mantid/kernel/_aliases.py +++ b/Framework/PythonInterface/mantid/kernel/_aliases.py @@ -1,4 +1,4 @@ -# Mantid Repository : https://github.com/mantidproject/mantmatrixWorkspaceid +# Mantid Repository : https://github.com/mantidproject/mantid # # Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source diff --git a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py index db15335bc5f7492df9960a08fa395676b754ef46..6b38972c87c9a5e778220c87f5f00137e1d3d736 100644 --- a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py +++ b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py index 26e0d00a54f637c7669de5884a62fb1f6ad480ea..bc3bc62a21fbcf7a38bcee66804186ebd4478a46 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + @@ -31,6 +31,15 @@ class CalibrationModel(object): plot_output, instrument, rb_num=None): + """ + Create a new calibration from a vanadium run and ceria run + :param vanadium_path: Path to vanadium data file. + :param ceria_path: Path to ceria data file + :param plot_output: Whether the output should be plotted. + :param instrument: The instrument the data relates to. + :param rb_num: The RB number for file creation. + """ + vanadium_corrections = self.calculate_vanadium_correction(vanadium_path) van_integration = vanadium_corrections[0] van_curves = vanadium_corrections[1] @@ -125,6 +134,13 @@ class CalibrationModel(object): raise RuntimeError def run_calibration(self, ceria_ws, van_integration, van_curves): + """ + Runs the main Engineering calibration algorithm. + :param ceria_ws: The workspace with the ceria data. + :param van_integration: The integration values from the vanadium corrections + :param van_curves: The curves from the vanadium corrections. + :return: The output of the algorithm. + """ output = [None] * 2 for i in range(2): table_name = self._generate_table_workspace_name(i) @@ -136,13 +152,18 @@ class CalibrationModel(object): OutputParametersTableName=table_name) return output - def calculate_vanadium_correction(self, vanadium_run_no): + def calculate_vanadium_correction(self, vanadium_path): + """ + Runs the vanadium correction algorithm. + :param vanadium_path: The path to the vanadium data. + :return: The integrated workspace and the curves generated by the algorithm. + """ try: - Load(Filename=vanadium_run_no, OutputWorkspace=self.VANADIUM_INPUT_WORKSPACE_NAME) + Load(Filename=vanadium_path, OutputWorkspace=self.VANADIUM_INPUT_WORKSPACE_NAME) except Exception as e: logger.error("Error when loading vanadium sample data. " "Could not run Load algorithm with vanadium run number: " + - str(vanadium_run_no) + ". Error description: " + str(e)) + str(vanadium_path) + ". Error description: " + str(e)) raise RuntimeError EnggVanadiumCorrections(VanadiumWorkspace=self.VANADIUM_INPUT_WORKSPACE_NAME, OutIntegrationWorkspace=self.INTEGRATED_WORKSPACE_NAME, @@ -154,6 +175,15 @@ class CalibrationModel(object): def create_output_files(self, calibration_dir, difc, tzero, ceria_path, vanadium_path, instrument): + """ + Create output files from the algorithms in the specified directory + :param calibration_dir: The directory to save the files into. + :param difc: DIFC values from the calibration algorithm. + :param tzero: TZERO values from the calibration algorithm. + :param ceria_path: The path to the ceria data file. + :param vanadium_path: The path to the vanadium data file. + :param instrument: The instrument (ENGINX or IMAT) + """ if not path.exists(calibration_dir): makedirs(calibration_dir) filename, vanadium_no, ceria_no = self._generate_output_file_name(vanadium_path, @@ -190,6 +220,14 @@ class CalibrationModel(object): @staticmethod def _generate_output_file_name(vanadium_path, ceria_path, instrument, bank): + """ + Generate an output filename in the form INSTRUMENT_VanadiumRunNo_CeriaRunCo_BANKS + :param vanadium_path: Path to vanadium data file + :param ceria_path: Path to ceria data file + :param instrument: The instrument in use. + :param bank: The bank being saved. + :return: The filename, the vanadium run number, and ceria run number. + """ vanadium_no = path.splitext(basename(vanadium_path))[0].replace(instrument, '').lstrip('0') ceria_no = path.splitext(basename(ceria_path))[0].replace(instrument, '').lstrip('0') filename = instrument + "_" + vanadium_no + "_" + ceria_no + "_" diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py index 63c87939005f36c7f779a3274171cc9326ef1ab6..5515a5f5c5dcc78e00d1686ae08d099eef8535cf 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + @@ -31,8 +31,15 @@ class CalibrationPresenter(object): plot_output = self.view.get_plot_output() self.start_calibration_worker(vanadium_no, calib_no, plot_output, self.rb_num) - def start_calibration_worker(self, vanadium_no, calib_no, plot_output, rb_num): - self.worker = AsyncTask(self.model.create_new_calibration, (vanadium_no, calib_no), + def start_calibration_worker(self, vanadium_path, calib_path, plot_output, rb_num): + """ + Calibrate the data in a separate thread so as to not freeze the GUI. + :param vanadium_path: Path to vanadium data file. + :param calib_path: Path to calibration data file. + :param plot_output: Whether to plot the output. + :param rb_num: The current RB number set in the GUI. + """ + self.worker = AsyncTask(self.model.create_new_calibration, (vanadium_path, calib_path), {"plot_output": plot_output, "instrument": self.instrument, "rb_num": rb_num}, error_cb=self._on_error, finished_cb=self.enable_calibrate_buttons) self.worker.start() diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_model.py index 808340663824870d017a79ecad1e3887d3c15840..ba57bc8aeaccc184c8e4eabde39bb6ad9fa2e7cc 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_model.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_presenter.py index ae0b2aa52a216c55a3fbe6d9db61de04d68a7380..9a5e0100d719ad240efc4b058cbac4790188a62e 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_presenter.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py index 6494b21667f1378b3f6bbc9b34f9d70e84767dac..c3251f1e8a90d91458f6bee651fcf65f183cb808 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py @@ -1,6 +1,6 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 +