Skip to content
Snippets Groups Projects
Commit 9bc396dc authored by Conor Finn's avatar Conor Finn
Browse files

RE #26846 Initial Review Changes

parent abb377ad
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ Q.convention = Inelastic
# Set of PyQt interfaces to add to the Interfaces menu, separated by a space. Interfaces are seperated from their respective categories by a "/".
mantidqt.python_interfaces = Direct/DGS_Reduction.py Direct/DGSPlanner.py Direct/PyChop.py Direct/MSlice.py SANS/ORNL_SANS.py Utility/TofConverter.py Reflectometry/ISIS_Reflectometry_Old.py Diffraction/Powder_Diffraction_Reduction.py Diffraction/Engineering_Diffraction_2.py Utility/FilterEvents.py Diffraction/HFIR_4Circle_Reduction.py Utility/QECoverage.py SANS/ISIS_SANS.py Muon/Frequency_Domain_Analysis.py Muon/Elemental_Analysis.py Muon/Frequency_Domain_Analysis_Old.py Muon/Muon_Analysis_2.py
mantidqt.python_interfaces = Direct/DGS_Reduction.py Direct/DGSPlanner.py Direct/PyChop.py Direct/MSlice.py SANS/ORNL_SANS.py Utility/TofConverter.py Reflectometry/ISIS_Reflectometry_Old.py Diffraction/Powder_Diffraction_Reduction.py Utility/FilterEvents.py Diffraction/HFIR_4Circle_Reduction.py Utility/QECoverage.py SANS/ISIS_SANS.py Muon/Frequency_Domain_Analysis.py Muon/Elemental_Analysis.py Muon/Frequency_Domain_Analysis_Old.py Muon/Muon_Analysis_2.py
# Directory containing the above startup scripts
mantidqt.python_interfaces_directory = @MANTID_ROOT@/scripts
......
......@@ -10,7 +10,7 @@ Interface Overview
------------------
This custom interface will integrate several tasks related to engineering
diffraction. In its current state it provides functionality for createing
diffraction. In its current state it provides functionality for creating
new calibration files. This interface is under active development.
General Options
......
......@@ -116,6 +116,13 @@
</layout>
</widget>
</widget>
<tabstops>
<tabstop>lineEdit_RBNumber</tabstop>
<tabstop>comboBox_instrument</tabstop>
<tabstop>tab_main</tabstop>
<tabstop>pushButton_help</tabstop>
<tabstop>pushButton_close</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
......
......@@ -8,7 +8,6 @@
from __future__ import (absolute_import, division, print_function)
from os import path, makedirs
from ntpath import basename
from mantid.api import AnalysisDataService as Ads
from mantid.kernel import logger
......@@ -18,13 +17,15 @@ from mantidqt.plotting.functions import plot
from Engineering.EnggUtils import write_ENGINX_GSAS_iparam_file
class CalibrationModel(object):
def __init__(self):
self.VANADIUM_INPUT_WORKSPACE_NAME = "engggui_vanadium_ws"
self.CURVES_WORKSPACE_NAME = "engggui_vanadium_curves"
self.INTEGRATED_WORKSPACE_NAME = "engggui_vanadium_integration"
self.out_files_root_dir = path.join(path.expanduser("~"), "Engineering_Mantid/")
VANADIUM_INPUT_WORKSPACE_NAME = "engggui_vanadium_ws"
CURVES_WORKSPACE_NAME = "engggui_vanadium_curves"
INTEGRATED_WORKSPACE_NAME = "engggui_vanadium_integration"
OUT_FILES_ROOT_DIR = path.join(path.expanduser("~"), "Engineering_Mantid")
CALIBRATION_DIR = path.join(OUT_FILES_ROOT_DIR, "Calibration", "")
class CalibrationModel(object):
def create_new_calibration(self,
vanadium_path,
ceria_path,
......@@ -39,7 +40,6 @@ class CalibrationModel(object):
: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]
......@@ -54,12 +54,11 @@ class CalibrationModel(object):
difc = [output[0].DIFC, output[1].DIFC]
tzero = [output[0].TZERO, output[1].TZERO]
calibration_dir = self.out_files_root_dir + "Calibration/"
self.create_output_files(calibration_dir, difc, tzero, ceria_path, vanadium_path,
self.create_output_files(CALIBRATION_DIR, difc, tzero, ceria_path, vanadium_path,
instrument)
if rb_num:
calibration_dir = self.out_files_root_dir + "User/" + rb_num + "/Calibration/"
self.create_output_files(calibration_dir, difc, tzero, ceria_path, vanadium_path,
user_calib_dir = path.join(OUT_FILES_ROOT_DIR, "User", rb_num, "Calibration", "")
self.create_output_files(user_calib_dir, difc, tzero, ceria_path, vanadium_path,
instrument)
@staticmethod
......@@ -83,7 +82,7 @@ class CalibrationModel(object):
@staticmethod
def _plot_difc_zero(difc, tzero):
for i in range(1, 3):
bank_ws = Ads.retrieve("engggui_calibration_bank_" + str(i))
bank_ws = Ads.retrieve(CalibrationModel._generate_table_workspace_name(i-1))
x_val = []
y_val = []
......@@ -129,7 +128,7 @@ class CalibrationModel(object):
return Load(Filename=ceria_run_no, OutputWorkspace="engggui_calibration_sample_ws")
except Exception as e:
logger.error("Error while loading calibration sample data. "
"Could not run the algorithm Load succesfully for the calibration sample "
"Could not run the algorithm Load successfully for the calibration sample "
"(run number: " + str(ceria_run_no) + "). Error description: " + str(e) +
" Please check also the previous log messages for details.")
raise RuntimeError
......@@ -153,25 +152,26 @@ class CalibrationModel(object):
OutputParametersTableName=table_name)
return output
def calculate_vanadium_correction(self, vanadium_path):
@staticmethod
def calculate_vanadium_correction(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_path, OutputWorkspace=self.VANADIUM_INPUT_WORKSPACE_NAME)
Load(Filename=vanadium_path, OutputWorkspace=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_path) + ". Error description: " + str(e))
raise RuntimeError
EnggVanadiumCorrections(VanadiumWorkspace=self.VANADIUM_INPUT_WORKSPACE_NAME,
OutIntegrationWorkspace=self.INTEGRATED_WORKSPACE_NAME,
OutCurvesWorkspace=self.CURVES_WORKSPACE_NAME)
Ads.remove(self.VANADIUM_INPUT_WORKSPACE_NAME)
integrated_workspace = Ads.Instance().retrieve(self.INTEGRATED_WORKSPACE_NAME)
curves_workspace = Ads.Instance().retrieve(self.CURVES_WORKSPACE_NAME)
EnggVanadiumCorrections(VanadiumWorkspace=VANADIUM_INPUT_WORKSPACE_NAME,
OutIntegrationWorkspace=INTEGRATED_WORKSPACE_NAME,
OutCurvesWorkspace=CURVES_WORKSPACE_NAME)
Ads.remove(VANADIUM_INPUT_WORKSPACE_NAME)
integrated_workspace = Ads.Instance().retrieve(INTEGRATED_WORKSPACE_NAME)
curves_workspace = Ads.Instance().retrieve(CURVES_WORKSPACE_NAME)
return integrated_workspace, curves_workspace
def create_output_files(self, calibration_dir, difc, tzero, ceria_path, vanadium_path,
......@@ -229,8 +229,8 @@ class CalibrationModel(object):
: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')
vanadium_no = path.splitext(path.basename(vanadium_path))[0].replace(instrument, '').lstrip('0')
ceria_no = path.splitext(path.basename(ceria_path))[0].replace(instrument, '').lstrip('0')
filename = instrument + "_" + vanadium_no + "_" + ceria_no + "_"
if bank == "all":
filename = filename + "all_banks.prm"
......
......@@ -41,8 +41,8 @@ class CalibrationPresenter(object):
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()
self.disable_calibrate_buttons()
self.worker.start()
def set_instrument_override(self, instrument):
if instrument == 0:
......
......@@ -10,8 +10,6 @@ from Engineering.gui.engineering_diffraction.engineering_diffraction import Engi
from qtpy import QtCore
Name = "Engineering_Diffraction"
if 'engineering_diffraction' in globals():
eng_diff = globals()['engineering_diffraction']
if not eng_diff.isHidden():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment