From df2c38faf3ec672f961bbbfd43b77195de8a444c Mon Sep 17 00:00:00 2001 From: David Fairbrother <DavidFair@users.noreply.github.com> Date: Wed, 7 Jun 2017 11:34:57 +0100 Subject: [PATCH] Re #19794 Added system tests for PEARL --- .../ISIS_Powder/input/GEM83664.nxs.md5 | 1 - .../ISIS_Powder/input/GEM83665.nxs.md5 | 1 - .../ISIS_Powder/input/GEM83666.nxs.md5 | 1 - .../ISIS_Powder/input/PEARL00098472.nxs.md5 | 1 + .../input/PEARL00098472_splined.nxs.md5 | 1 + .../ISIS_Powder/input/PEARL00098485.nxs.md5 | 1 + .../ISIS_Powder/input/PEARL00098507.nxs.md5 | 1 + .../pearl/17_1/pearl_offset_16_4.cal.md5 | 1 + .../pearl/PRL112_DC25_10MM_FF.OUT.md5 | 1 + ...l_absorp_sphere_10mm_newinst2_long.nxs.md5 | 1 + .../pearl/pearl_group_12_1_TT35.cal.md5 | 1 + .../pearl/pearl_group_12_1_TT70.cal.md5 | 1 + .../pearl/pearl_group_12_1_TT88.cal.md5 | 1 + .../pearl_system_test_mapping.yaml.md5 | 1 + .../tests/analysis/ISIS_PowderGemTest.py | 57 +++--- .../tests/analysis/ISIS_PowderPearlTest.py | 187 +++++++++++++----- ...SIS_Powder-PEARL00098507_tt70Atten.nxs.md5 | 1 + .../pearl_routines/pearl_output.py | 15 +- .../isis_powder/routines/calibrate.py | 2 +- 19 files changed, 177 insertions(+), 99 deletions(-) delete mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 delete mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 delete mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472_splined.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098485.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098507.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/17_1/pearl_offset_16_4.cal.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/PRL112_DC25_10MM_FF.OUT.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_absorp_sphere_10mm_newinst2_long.nxs.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT35.cal.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT70.cal.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT88.cal.md5 create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/pearl_system_test_mapping.yaml.md5 create mode 100644 Testing/SystemTests/tests/analysis/reference/ISIS_Powder-PEARL00098507_tt70Atten.nxs.md5 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 deleted file mode 100644 index 356c19fa016..00000000000 --- a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83664.nxs.md5 +++ /dev/null @@ -1 +0,0 @@ -517ea9fd7b580bfd4c7cb9f4c9eb0072 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 deleted file mode 100644 index a3674973f05..00000000000 --- a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83665.nxs.md5 +++ /dev/null @@ -1 +0,0 @@ -1a87419df68632fc25c1f24703c71ff6 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 deleted file mode 100644 index 3533345ba3d..00000000000 --- a/Testing/Data/SystemTest/ISIS_Powder/input/GEM83666.nxs.md5 +++ /dev/null @@ -1 +0,0 @@ -233b2a1fa57ec4c9442c881b3c32f7b3 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472.nxs.md5 new file mode 100644 index 00000000000..7410fb68407 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472.nxs.md5 @@ -0,0 +1 @@ +551dac3a31a837fabed1773c1eb8450c diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472_splined.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472_splined.nxs.md5 new file mode 100644 index 00000000000..f4ab974a464 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098472_splined.nxs.md5 @@ -0,0 +1 @@ +198b283578396699dccb590876668305 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098485.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098485.nxs.md5 new file mode 100644 index 00000000000..fb593ccb394 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098485.nxs.md5 @@ -0,0 +1 @@ +86e8967d796112353754008637bbc8d8 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098507.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098507.nxs.md5 new file mode 100644 index 00000000000..7cc3c391895 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/PEARL00098507.nxs.md5 @@ -0,0 +1 @@ +641d395519e6766043bc6eaa9798fb3e diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/17_1/pearl_offset_16_4.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/17_1/pearl_offset_16_4.cal.md5 new file mode 100644 index 00000000000..2d208f99c36 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/17_1/pearl_offset_16_4.cal.md5 @@ -0,0 +1 @@ +918c05da37cf50e89553164e2c6387f0 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/PRL112_DC25_10MM_FF.OUT.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/PRL112_DC25_10MM_FF.OUT.md5 new file mode 100644 index 00000000000..74929ed1e82 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/PRL112_DC25_10MM_FF.OUT.md5 @@ -0,0 +1 @@ +ef84ea197398c92bf293dc11112e01f7 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_absorp_sphere_10mm_newinst2_long.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_absorp_sphere_10mm_newinst2_long.nxs.md5 new file mode 100644 index 00000000000..e18f253d7d3 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_absorp_sphere_10mm_newinst2_long.nxs.md5 @@ -0,0 +1 @@ +d1b66c634fc4e6046e8f75121b505518 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT35.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT35.cal.md5 new file mode 100644 index 00000000000..e72dfc0f25e --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT35.cal.md5 @@ -0,0 +1 @@ +07b2b2ddb7c02a77b8a3633367146cd9 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT70.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT70.cal.md5 new file mode 100644 index 00000000000..0396af0f68d --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT70.cal.md5 @@ -0,0 +1 @@ +c2efdc30a09b2faa57309bdc9274e415 diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT88.cal.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT88.cal.md5 new file mode 100644 index 00000000000..b5f22f830b6 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/calibration/pearl/pearl_group_12_1_TT88.cal.md5 @@ -0,0 +1 @@ +0fbc68bfdfba6e87dede662dbb213b2d diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/pearl_system_test_mapping.yaml.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/pearl_system_test_mapping.yaml.md5 new file mode 100644 index 00000000000..abab6932d59 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/pearl_system_test_mapping.yaml.md5 @@ -0,0 +1 @@ +f3064cb75a0f8c0238afe0f1caa6aa7d diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py index e0d987b9166..81090326c21 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py @@ -28,14 +28,14 @@ spline_rel_path = os.path.join("17_1", "VanSplined_83608_offsets_2011_cycle111b. # 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) +working_dir = 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) +input_dir = os.path.join(working_dir, input_folder_name) +output_dir = os.path.join(working_dir, 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) -spline_path = os.path.join(calibration_folder, spline_rel_path) +calibration_map_path = os.path.join(input_dir, calibration_map_rel_path) +calibration_dir = os.path.join(input_dir, calibration_folder_name) +spline_path = os.path.join(calibration_dir, spline_rel_path) class CreateVanadiumTest(stresstesting.MantidStressTest): @@ -51,14 +51,12 @@ class CreateVanadiumTest(stresstesting.MantidStressTest): self.calibration_results = run_vanadium_calibration() def validate(self): - return calibration_validator(self, self.calibration_results) + return calibration_validator(self.calibration_results) def cleanup(self): try: - spline_folder = os.path.join(calibration_folder, "17_1") - _try_delete(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")) + _try_delete(output_dir) + _try_delete(spline_path) finally: mantid.mtd.clear() config['datasearch.directories'] = self.existing_config @@ -78,24 +76,23 @@ class FocusTest(stresstesting.MantidStressTest): self.focus_results = run_focus() def validate(self): - return focus_validation(self, self.focus_results) + return focus_validation(self.focus_results) def cleanup(self): try: _try_delete(spline_path) - _try_delete(output_folder) + _try_delete(output_dir) finally: config['datasearch.directories'] = self.existing_config mantid.mtd.clear() def _gen_required_files(): - required_run_numbers = ["83605", "83607", "83608", # create_van : PDF mode - "83664", "83665", "83666", # create_van : Rietveld mode + required_run_numbers = ["83607", "83608", # create_van : PDF mode "83605", "83608_splined"] # File to focus (Si) # 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 = [os.path.join(input_dir, (inst_name + number + ".nxs")) for number in required_run_numbers] input_files.append(calibration_map_path) return input_files @@ -104,13 +101,10 @@ 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 and was saved if not os.path.exists(spline_path): @@ -128,7 +122,7 @@ def run_focus(): # Copy the required splined file into place first (instead of relying on generated one) splined_file_name = "GEM83608_splined.nxs" - original_splined_path = os.path.join(input_folder, splined_file_name) + original_splined_path = os.path.join(input_dir, splined_file_name) shutil.copy(original_splined_path, spline_path) inst_object = setup_inst_object(mode="PDF") @@ -137,17 +131,13 @@ def run_focus(): sample_empty_scale=sample_empty_scale) -def calibration_validator(cls, results): - _validation_setup(cls) - +def calibration_validator(results): # Get the name of the grouped workspace list reference_file_name = "ISIS_Powder-GEM-VanSplined_83608_offsets_2011_cycle111b.cal.nxs" return _compare_ws(reference_file_name=reference_file_name, results=results) -def focus_validation(cls, results): - _validation_setup(cls) - +def focus_validation(results): reference_file_name = "ISIS_Powder-GEM83605_FocusSempty.nxs" return _compare_ws(reference_file_name=reference_file_name, results=results) @@ -165,27 +155,24 @@ def _compare_ws(reference_file_name, results): return is_valid -def _validation_setup(cls): - cls.disableChecking.append('Instrument') - cls.disableChecking.append('Sample') - cls.disableChecking.append('SpectraMap') - - def setup_mantid_paths(): - config['datasearch.directories'] += ";" + input_folder + config['datasearch.directories'] += ";" + input_dir 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) + calibration_directory=calibration_dir, output_directory=output_dir, mode=mode) return inst_obj def _try_delete(path): try: # Use this instead of os.remove as we could be passed a non-empty dir - shutil.rmtree(path) + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) except OSError as err: print ("Could not delete output file at: ", path) diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py index d645319580e..ef3c0a17aa9 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py @@ -2,95 +2,176 @@ 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.pearl import Pearl +from isis_powder import Pearl DIRS = config['datasearch.directories'].split(';') +# Setup various path details + +inst_name = "PEARL" +# 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", "pearl_system_test_mapping.yaml") +spline_rel_path = os.path.join("17_1", "VanSplined_98472_tt70_pearl_offset_16_4.cal.nxs") + +# Generate paths for the tests +# This implies DIRS[0] is the system test data folder +working_dir = os.path.join(DIRS[0], working_folder_name) + +input_dir = os.path.join(working_dir, input_folder_name) +output_dir = os.path.join(working_dir, output_folder_name) + +calibration_map_path = os.path.join(input_dir, calibration_map_rel_path) +calibration_dir = os.path.join(input_dir, calibration_folder_name) +spline_path = os.path.join(calibration_dir, spline_rel_path) + + +class CreateVanadiumTest(stresstesting.MantidStressTest): -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() def runTest(self): - self.calibration_results = _run_vanadium_calibration() + setup_mantid_paths() + self.calibration_results = run_vanadium_calibration() def validate(self): - return _calibration_validation(self, self.calibration_results) + return calibration_validator(self.calibration_results) def cleanup(self): - # TODO clean up reference files properly - config['datasearch.directories'] = self.existing_config - # _clean_up() + try: + _try_delete(output_dir) + _try_delete(spline_path) + finally: + mantid.mtd.clear() + config['datasearch.directories'] = self.existing_config -def _calibration_validation(cls, results): - _validation_setup(cls) - results_group_name = results.name() - reference_file_name = "ISIS_PowderPEARL95634-95647_Van_Cal.nxs" - return results_group_name, reference_file_name +class FocusTest(stresstesting.MantidStressTest): + focus_results = None + existing_config = config['datasearch.directories'] -def _validation_setup(cls): - cls.disableChecking.append('Instrument') - cls.disableChecking.append('Sample') - cls.disableChecking.append('SpectraMap') + def requiredFiles(self): + return _gen_required_files() + + def runTest(self): + # Gen vanadium calibration first + setup_mantid_paths() + self.focus_results = run_focus() + + def validate(self): + return focus_validation(self.focus_results) + + def cleanup(self): + try: + _try_delete(spline_path) + _try_delete(output_dir) + finally: + config['datasearch.directories'] = self.existing_config + mantid.mtd.clear() def _gen_required_files(): - input_file_dir = _get_input_dir() - van_files_names = ["PEARL000" + str(num) for num in range(95634, 95647)] - empty_file_names = ["PEARL000" + str(num) for num in range(95648, 95654)] + required_run_numbers = ["98472", "98485", # create_van + "98507", "98472_splined"] # Focus (Si) - required_files = [] - for van_name, empty_name in zip(van_files_names, empty_file_names): - required_files.append(os.path.join(input_file_dir, van_name)) - required_files.append(os.path.join(input_file_dir, empty_name)) + # Generate file names of form "INSTxxxxx.nxs" - PEARL requires 000 padding + input_files = [os.path.join(input_dir, (inst_name + "000" + number + ".nxs")) for number in required_run_numbers] + input_files.append(calibration_map_path) + return input_files - return required_files +def run_vanadium_calibration(): + vanadium_run = 98507 # Choose arbitrary run in the cycle 17_1 -def _get_calibration_dir(): - return os.path.join(DIRS[0], "PEARL", "Calibration") + inst_obj = setup_inst_object(mode="tt70") + # Run create vanadium twice to ensure we get two different output splines / files + inst_obj.create_vanadium(run_in_cycle=vanadium_run, do_absorb_corrections=True) -def _get_input_dir(): - return os.path.join(DIRS[0], "PEARL", "InputData") + # Check the spline looks good and was saved + 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 _get_output_dir(): - return os.path.join(DIRS[0], "PEARL", "SystemTest_Output") + +def run_focus(): + run_number = 98507 + attenuation_file_name = "PRL112_DC25_10MM_FF.OUT" + + # Copy the required splined file into place first (instead of relying on generated one) + splined_file_name = "PEARL00098472_splined.nxs" + + attenuation_path = os.path.join(calibration_dir, attenuation_file_name) + original_splined_path = os.path.join(input_dir, splined_file_name) + shutil.copy(original_splined_path, spline_path) + + inst_object = setup_inst_object(mode="tt70") + return inst_object.focus(run_number=run_number, vanadium_normalisation=True, + perform_attenuation=True, attenuation_file_path=attenuation_path, + focus_mode="Trans") + + +def calibration_validator(results): + # Get the name of the grouped workspace list + reference_file_name = "ISIS_Powder-PEARL00098472_splined.nxs" + return _compare_ws(reference_file_name=reference_file_name, results=results) + + +def focus_validation(results): + reference_file_name = "ISIS_Powder-PEARL00098507_tt70Atten.nxs" + return _compare_ws(reference_file_name=reference_file_name, results=results) -def _run_vanadium_calibration(): - vanadium_runs = "95634_95647" +def _compare_ws(reference_file_name, results): + ref_ws = mantid.Load(Filename=reference_file_name) - pearl_obj = _setup_pearl_instrument(tt_mode=None) - results = pearl_obj.create_calibration_vanadium(run_in_range=vanadium_runs, do_absorb_corrections=True, - long_mode=False) - return results + 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()) -def _setup_pearl_instrument(tt_mode): + return is_valid + + +def setup_mantid_paths(): + config['datasearch.directories'] += ";" + input_dir + + +def setup_inst_object(mode): user_name = "Test" - calibration_mapping_file_name = "pearl_calibration.yaml" - attenuation_file_name = "PRL112_DC25_10MM_FF.OUT" - attenuation_file_path = os.path.join(_get_calibration_dir(), attenuation_file_name) - calibration_map_file_path = os.path.join(_get_calibration_dir(), calibration_mapping_file_name) - # Setup raw data directory in Mantid - config['datasearch.directories'] += ";" + _get_input_dir() - - pearl_obj = Pearl(user_name=user_name, tt_mode=tt_mode, attenuation_file_name=attenuation_file_path, - calibration_directory=_get_calibration_dir(), output_directory=_get_output_dir(), - calibration_config_path=calibration_map_file_path) - return pearl_obj + + inst_obj = Pearl(user_name=user_name, calibration_mapping_file=calibration_map_path, long_mode=False, + calibration_directory=calibration_dir, output_directory=output_dir, tt_mode=mode) + return inst_obj + + +def _try_delete(path): + try: + # Use this instead of os.remove as we could be passed a non-empty dir + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) + except OSError as err: + print ("Could not delete output file at: ", path) diff --git a/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-PEARL00098507_tt70Atten.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-PEARL00098507_tt70Atten.nxs.md5 new file mode 100644 index 00000000000..53efe00e1d4 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/reference/ISIS_Powder-PEARL00098507_tt70Atten.nxs.md5 @@ -0,0 +1 @@ +9489e6d9cfcee132c245c09580f1421a diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py index 69449cb2576..77190c916d2 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py @@ -3,6 +3,7 @@ from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as mantid import isis_powder.routines.common as common +from isis_powder.routines.common_enums import WORKSPACE_UNITS # This file generates the various outputs for the PEARL instruments and saves them to their respective files @@ -33,19 +34,19 @@ def _attenuate_workspace(instrument, output_file_paths, attenuated_ws): def _focus_mode_mods(output_file_paths, calibrated_spectra): - index = 1 append = False output_list = [] - for ws in calibrated_spectra: - - mantid.SaveGSS(InputWorkspace=ws, Filename=output_file_paths["gss_filename"], Append=append, Bank=index) - output_name = output_file_paths["output_name"] + "_mod" + str(index) - dspacing_ws = mantid.ConvertUnits(InputWorkspace=ws, OutputWorkspace=output_name, Target="dSpacing") + for index, ws in enumerate(calibrated_spectra): + output_name = output_file_paths["output_name"] + "_mod" + str(index + 1) + tof_ws = mantid.ConvertUnits(InputWorkspace=ws, OutputWorkspace=output_name, + Target=WORKSPACE_UNITS.tof) + mantid.SaveGSS(InputWorkspace=tof_ws, Filename=output_file_paths["gss_filename"], Append=append, Bank=index + 1) + dspacing_ws = mantid.ConvertUnits(InputWorkspace=ws, OutputWorkspace=output_name, + Target=WORKSPACE_UNITS.d_spacing) output_list.append(dspacing_ws) mantid.SaveNexus(Filename=output_file_paths["nxs_filename"], InputWorkspace=dspacing_ws, Append=append) append = True - index += 1 return output_list diff --git a/scripts/Diffraction/isis_powder/routines/calibrate.py b/scripts/Diffraction/isis_powder/routines/calibrate.py index 7912d328441..cb5700733a1 100644 --- a/scripts/Diffraction/isis_powder/routines/calibrate.py +++ b/scripts/Diffraction/isis_powder/routines/calibrate.py @@ -40,7 +40,7 @@ def create_van(instrument, run_details, absorb): focused_spectra = instrument._crop_van_to_expected_tof_range(focused_spectra) d_spacing_group, tof_group = instrument._output_focused_ws(processed_spectra=focused_spectra, - run_details=run_details, output_mode="all") + run_details=run_details, output_mode="mods") _create_vanadium_splines(focused_spectra, instrument, run_details) -- GitLab