diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83605.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83605.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..1788a579f1ee600d6d3aa0068f3671654dc1280e --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83605.nxs.md5 @@ -0,0 +1 @@ +8fc5b99698df90d930eddcbca7d6767c diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83607.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83607.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..403c02a66eb7b4b0f20f6181a7d1b9a08446bcc6 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83607.nxs.md5 @@ -0,0 +1 @@ +4f441f16f4c07de67dfef295dacb790d diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83608.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83608.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..7a3cf4f273b9ea82cf70c768727e259ccf63346d --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83608.nxs.md5 @@ -0,0 +1 @@ +6eb5619f8eac2ac1a6ae0566b1a73c23 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..356c19fa01673f8c92b71d4f66d6f0d9c3c3555f --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 @@ -0,0 +1 @@ +517ea9fd7b580bfd4c7cb9f4c9eb0072 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..a3674973f0522112045898dc9e00a7462ca85c4c --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 @@ -0,0 +1 @@ +1a87419df68632fc25c1f24703c71ff6 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..3533345ba3d5e84bcb52bfad65ea0672119dad6a --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 @@ -0,0 +1 @@ +233b2a1fa57ec4c9442c881b3c32f7b3 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/17_1/offsets_2011_cycle111b.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/17_1/offsets_2011_cycle111b.cal.md5 new file mode 100644 index 0000000000000000000000000000000000000000..612b94f4183ab640d69ff51558f226cc3a02607b --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/17_1/offsets_2011_cycle111b.cal.md5 @@ -0,0 +1 @@ +d59cb19944cf8a186b7124f4497f7e61 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/GEM_Instrument_grouping.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/GEM_Instrument_grouping.cal.md5 new file mode 100644 index 0000000000000000000000000000000000000000..34b033a2eea6de6fe6848dcc3de6c00c1d0c27f3 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/gem/GEM_Instrument_grouping.cal.md5 @@ -0,0 +1 @@ +370c13263b4ccd6e22cc215e66cbc548 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/gem_system_test_mapping.yaml.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/gem_system_test_mapping.yaml.md5 new file mode 100644 index 0000000000000000000000000000000000000000..8d10a7142d3d5011b6cf24b49cfe8fa42b3cae61 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/gem_system_test_mapping.yaml.md5 @@ -0,0 +1 @@ +b63fb7eebb20e0279e7a165932eeb702 diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py new file mode 100644 index 0000000000000000000000000000000000000000..8b092426b595704a6e4ec346e482b646083d23b5 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py @@ -0,0 +1,184 @@ +from __future__ import (absolute_import, division, print_function) + +import os +import stresstesting +import shutil + +import mantid.simpleapi as mantid +from mantid import config + +from isis_powder import Gem + +DIRS = config['datasearch.directories'].split(';') + +# Setup various path details + +inst_name = "GEM" +# Relative to system data folder +working_folder_name = "ISIS_Powder" + +# Relative to working folder +input_folder_name = "input" +output_folder_name = "output" + +# Relative to input folder +calibration_folder_name = os.path.join("calibration", inst_name.lower()) +calibration_map_rel_path = os.path.join("yaml_files", "gem_system_test_mapping.yaml") + +# Generate paths for the tests +# This implies DIRS[0] is the system test data folder +working_folder = os.path.join(DIRS[0], working_folder_name) + +input_folder = os.path.join(working_folder, input_folder_name) +output_folder = os.path.join(working_folder, output_folder_name) + +calibration_map_path = os.path.join(input_folder, calibration_map_rel_path) +calibration_folder = os.path.join(input_folder, calibration_folder_name) + + +class VanadiumCalibrationTest(stresstesting.MantidStressTest): + + calibration_results = None + existing_config = config['datasearch.directories'] + + def requiredFiles(self): + return _gen_required_files() + + def runTest(self): + setup_mantid_paths() + self.calibration_results = _run_vanadium_calibration() + + def validate(self): + return calibration_validator(self, self.calibration_results) + + def cleanup(self): + clean_up() + config['datasearch.directories'] = self.existing_config + + +class FocusTest(stresstesting.MantidStressTest): + + focus_results = None + existing_config = config['datasearch.directories'] + + # TODO + # Test disabled whilst in development as we were having to update the reference file on a daily basis + def skipTests(self): + return True + + def requiredFiles(self): + return _gen_required_files() + + def runTest(self): + # Gen vanadium calibration first + _run_vanadium_calibration() + self.focus_results = _run_focus() + + def validation(self): + return _focus_validation(self, self.focus_results) + + def cleanup(self): + config['datasearch.directories'] = self.existing_config + # TODO + + +def _gen_required_files(): + required_run_numbers = ["83605", "83607", "83608", # create_van : PDF mode + "83664", "83665", "83666"] # create_van : Rietveld mode + + # Generate file names of form "INSTxxxxx.nxs" + input_files = [os.path.join(input_folder, (inst_name + number + ".nxs")) for number in required_run_numbers] + input_files.append(calibration_map_path) + return input_files + + +def _run_vanadium_calibration(): + vanadium_run = 83605 # Choose arbitrary run in the cycle 17_1 + + pdf_inst_obj = setup_inst_object(mode="PDF") + rietveld_inst_obj = setup_inst_object(mode="Rietveld") + + # Run create vanadium twice to ensure we get two different output splines / files + pdf_inst_obj.create_vanadium(first_cycle_run_no=vanadium_run, + do_absorb_corrections=True, multiple_scattering=False) + rietveld_inst_obj.create_vanadium(first_cycle_run_no=vanadium_run, + do_absorb_corrections=True, multiple_scattering=False) + + # Check the spline looks good + spline_path = os.path.join(calibration_folder, "17_1", "VanSplined_83608_offsets_2011_cycle111b.cal.nxs") + if not os.path.exists(spline_path): + raise RuntimeError("Could not find output spline at the following path: " + spline_path) + splined_ws = mantid.Load(Filename=spline_path) + + return splined_ws + + +def _run_focus(): + run_number = 95599 + polaris_obj = setup_inst_object() + return polaris_obj.focus(run_number=run_number, input_mode="Individual", do_van_normalisation=True) + + +def calibration_validator(cls, results): + _validation_setup(cls) + + # Get the name of the grouped workspace list + reference_file_name = "ISIS_Powder-GEM-VanSplined_83608_offsets_2011_cycle111b.cal.nxs" + ref_ws = mantid.Load(Filename=reference_file_name) + + is_valid = True if len(results) > 0 else False + + for ws, ref in zip(results, ref_ws): + if not (mantid.CompareWorkspaces(Workspace1=ws, Workspace2=ref)): + is_valid = False + print (ws.getName() + " was not equal to: " + ref.getName()) + + return is_valid + + +def _focus_validation(cls, results): + _validation_setup(cls) + + reference_file_name = "POLARIS_PowderFocus79514.nxs" + focus_output_name = "Focus_results" + mantid.GroupWorkspaces(InputWorkspaces=results, OutputWorkspace=focus_output_name) + + return focus_output_name, reference_file_name + + +def _validation_setup(cls): + cls.disableChecking.append('Instrument') + cls.disableChecking.append('Sample') + cls.disableChecking.append('SpectraMap') + + +def clean_up(): + mantid.mtd.clear() + + spline_folder = os.path.join(calibration_folder, "17_1") + try: + shutil.rmtree(output_folder) + except OSError: + print("Could not delete output file at: ", output_folder) + + _try_delete(os.path.join(spline_folder, "VanSplined_83608_offsets_2011_cycle111b.cal.nxs")) + _try_delete(os.path.join(spline_folder, "VanSplined_83664_offsets_2011_cycle111b.cal.nxs")) + + +def setup_mantid_paths(): + config['datasearch.directories'] += ";" + input_folder + + +def setup_inst_object(mode): + user_name = "Test" + + inst_obj = Gem(user_name=user_name, calibration_mapping_file=calibration_map_path, + calibration_directory=calibration_folder, output_directory=output_folder, mode=mode) + return inst_obj + + +def _try_delete(path): + try: + os.remove(path) + except OSError: + print ("Could not delete output file at: ", path) diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderDiffraction.py b/Testing/SystemTests/tests/analysis/ISIS_PowderGeneric.py similarity index 100% rename from Testing/SystemTests/tests/analysis/ISIS_PowderDiffraction.py rename to Testing/SystemTests/tests/analysis/ISIS_PowderGeneric.py diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py index af7292d376e006d93ff44bfdbd4a88bdbb2f2e06..4e25f3a3ed8ca731e0d208c7bddde2e100870438 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py @@ -16,11 +16,6 @@ class VanadiumCalibrationTest(stresstesting.MantidStressTest): calibration_results = None existing_config = config['datasearch.directories'] - # TODO - # Test disabled whilst in development as we were having to update the reference file on a daily basis - def skipTests(self): - return True - def requiredFiles(self): return _gen_required_files() @@ -41,11 +36,6 @@ class FocusTest(stresstesting.MantidStressTest): focus_results = None existing_config = config['datasearch.directories'] - # TODO - # Test disabled whilst in development as we were having to update the reference file on a daily basis - def skipTests(self): - return True - def requiredFiles(self): return _gen_required_files() diff --git a/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-GEM-VanSplined_83608_offsets_2011_cycle111b.cal.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-GEM-VanSplined_83608_offsets_2011_cycle111b.cal.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..6beb21d836c02bd3b114893958a88a342d81fa9a --- /dev/null +++ b/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-GEM-VanSplined_83608_offsets_2011_cycle111b.cal.nxs.md5 @@ -0,0 +1 @@ +ae7980d3a4879b3adaa4332da9e238e2 diff --git a/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5 deleted file mode 100644 index f50b06c6be5eed2ad560e1b9fb2816ed38257c11..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/reference/ISIS_PowderPEARL95634-95647_Van_Cal.nxs.md5 +++ /dev/null @@ -1 +0,0 @@ -35cbcc39432281c90c97e36bd6be7e1f diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py index 3250f661ee24734733fda851be923f3df664369c..fbe4c9a9aea0004ed3035295caec570646782afe 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py @@ -10,7 +10,7 @@ from isis_powder.gem_routines import gem_advanced_config def calculate_van_absorb_corrections(ws_to_correct, multiple_scattering): # First 100 detectors are monitors or not connected to DAE - mantid.MaskDetectors(ws_to_correct, SpectraList=list(range(0, 101))) + mantid.MaskDetectors(ws_to_correct, SpectraList=range(1, 100)) absorb_dict = gem_advanced_config.absorption_correction_params sample_details_obj = absorb_corrections.create_vanadium_sample_details_obj(config_dict=absorb_dict) diff --git a/scripts/Diffraction/isis_powder/routines/common.py b/scripts/Diffraction/isis_powder/routines/common.py index e567cbcbef047b32f2ef948642539fd765e680d0..3bdd9086d6e0fc3f1a330405a60383cf1c20d839 100644 --- a/scripts/Diffraction/isis_powder/routines/common.py +++ b/scripts/Diffraction/isis_powder/routines/common.py @@ -350,10 +350,7 @@ def spline_vanadium_workspaces(focused_vanadium_spectra, spline_coefficient): :param spline_coefficient: The coefficient to use when creating the splined vanadium workspaces :return: The splined vanadium workspace """ - stripped_ws_list = _strip_vanadium_peaks(workspaces_to_strip=focused_vanadium_spectra) - splined_workspaces = spline_workspaces(stripped_ws_list, num_splines=spline_coefficient) - - remove_intermediate_workspace(stripped_ws_list) + splined_workspaces = spline_workspaces(focused_vanadium_spectra, num_splines=spline_coefficient) return splined_workspaces @@ -489,7 +486,7 @@ def _load_list_of_files(run_numbers_list, instrument, file_ext=None): def _strip_vanadium_peaks(workspaces_to_strip): out_list = [] for i, ws in enumerate(workspaces_to_strip): - out_name = ws.getName() + "_splined-" + str(i+1) + out_name = ws.getName() + "_toSpline-" + str(i+1) out_list.append(mantid.StripVanadiumPeaks(InputWorkspace=ws, OutputWorkspace=out_name)) return out_list