diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/POLARIS00098534.nxs.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/POLARIS00098534.nxs.md5 new file mode 100644 index 000000000000..1537c387fda3 --- /dev/null +++ b/Testing/Data/SystemTest/ISIS_Powder/input/POLARIS00098534.nxs.md5 @@ -0,0 +1 @@ +84cf90b7704c016162deb5def8dec28a diff --git a/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/polaris_system_test_mapping.yaml.md5 b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/polaris_system_test_mapping.yaml.md5 index 2df3374a6e44..119aa641568a 100644 --- a/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/polaris_system_test_mapping.yaml.md5 +++ b/Testing/Data/SystemTest/ISIS_Powder/input/yaml_files/polaris_system_test_mapping.yaml.md5 @@ -1 +1 @@ -28c6b5a204a148206ff2c61a8b69a60b +c50f5d06a8f8975e8dbc1cecb5974f50 diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index 25459eebd625..31f5ab9c3761 100644 --- a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py @@ -116,7 +116,7 @@ def cleanup(self): config["datasearch.directories"] = self.existing_config -class FocusTestNoAbsorption(systemtesting.MantidSystemTest): +class FocusTestNoAbsorptionWithRelativeNormalisation(systemtesting.MantidSystemTest): focus_results = None existing_config = config["datasearch.directories"] @@ -126,29 +126,34 @@ def requiredFiles(self): def runTest(self): # Gen vanadium calibration first setup_mantid_paths() - self.focus_results = run_focus_no_absorption() + self.focus_results = run_focus_no_absorption(mode="PDF") def validate(self): - # check output files as expected - def generate_error_message(expected_file, output_dir): - return "Unable to find {} in {}.\nContents={}".format(expected_file, output_dir, os.listdir(output_dir)) + return validate_normalisation_focus_tests(self, "98533") - def assert_output_file_exists(directory, filename): - self.assertTrue(os.path.isfile(os.path.join(directory, filename)), msg=generate_error_message(filename, directory)) + def cleanup(self): + try: + _try_delete(spline_path) + _try_delete(output_dir) + finally: + mantid.mtd.clear() + config["datasearch.directories"] = self.existing_config - user_output = os.path.join(output_dir, "17_1", "Test") - assert_output_file_exists(user_output, "POLARIS98533.nxs") - assert_output_file_exists(user_output, "POLARIS98533.gsas") - output_dat_dir = os.path.join(user_output, "dat_files") - for bankno in range(1, 6): - assert_output_file_exists(output_dat_dir, "POL98533-b_{}-TOF.dat".format(bankno)) - assert_output_file_exists(output_dat_dir, "POL98533-b_{}-d.dat".format(bankno)) - for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si Si") - self.tolerance_is_rel_err = True - self.tolerance = 1e-6 - return self.focus_results.name(), "ISIS_Powder-POLARIS98533_FocusSempty.nxs" +class FocusTestNoAbsorptionWithAbsoluteNormalisation(systemtesting.MantidSystemTest): + focus_results = None + existing_config = config["datasearch.directories"] + + def requiredFiles(self): + return _gen_required_files() + + def runTest(self): + # Gen vanadium calibration first + setup_mantid_paths() + self.focus_results = run_focus_no_absorption(mode="PDF_NORM") + + def validate(self): + return validate_normalisation_focus_tests(self, "98534") def cleanup(self): try: @@ -534,7 +539,7 @@ def run_total_scattering( def _gen_required_files(): - required_run_numbers = ["98531", "98532", "98533"] # create_van : PDF mode # File to focus (Si) + required_run_numbers = ["98531", "98532", "98533", "98534"] # create_van : PDF mode # File to focus (Si) # Generate file names of form "INSTxxxxx.nxs" input_files = [os.path.join(input_dir, (inst_name + "000" + number + ".nxs")) for number in required_run_numbers] @@ -566,8 +571,13 @@ def run_vanadium_calibration(per_detector): return splined_ws, unsplined_ws -def run_focus_no_absorption(per_detector=False): - run_number = 98533 +def run_focus_no_absorption(per_detector=False, mode="PDF"): + if mode == "PDF_NORM": + run_number = 98534 + elif mode == "PDF": + run_number = 98533 + else: + raise RuntimeError("Invalid mode") sample_empty = 98532 # Use the vanadium empty again to make it obvious sample_empty_scale = 0.5 # Set it to 50% scale @@ -580,7 +590,7 @@ def run_focus_no_absorption(per_detector=False): 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") + inst_object = setup_inst_object(mode=mode) return inst_object.focus( run_number=run_number, input_mode="Individual", @@ -588,7 +598,6 @@ def run_focus_no_absorption(per_detector=False): do_absorb_corrections=False, sample_empty=sample_empty, sample_empty_scale=sample_empty_scale, - van_normalisation_method="Relative", per_detector_vanadium=per_detector, ) @@ -625,30 +634,22 @@ def run_focus_absorption(run_number, paalman_pings=False): shutil.copy(original_splined_path, spline_path) inst_object = setup_inst_object("PDF", with_container=True) + focus_kwargs = {} if paalman_pings: inst_object._inst_settings.empty_can_subtraction_method = "PaalmanPings" # the default is Simple inst_object._inst_settings.paalman_pings_events_per_point = 1 - - return inst_object.focus( - run_number=run_number, - input_mode="Summed", - do_van_normalisation=True, - do_absorb_corrections=True, - sample_empty=sample_empty, - multiple_scattering=False, - van_normalisation_method="Relative", - ) else: - return inst_object.focus( - run_number=run_number, - input_mode="Summed", - do_van_normalisation=True, - do_absorb_corrections=True, - sample_empty=sample_empty, - sample_empty_scale=sample_empty_scale, - multiple_scattering=False, - van_normalisation_method="Relative", - ) + focus_kwargs["sample_empty_scale"] = sample_empty_scale + + return inst_object.focus( + run_number=run_number, + input_mode="Summed", + do_van_normalisation=True, + do_absorb_corrections=True, + sample_empty=sample_empty, + multiple_scattering=False, + **focus_kwargs, + ) def setup_mantid_paths(): @@ -701,3 +702,26 @@ def get_bin_number_at_given_r(r_data, r): diffs = [abs(i - r) for i in r_centres] idx = diffs.index(min(diffs)) return idx + + +def validate_normalisation_focus_tests(test, ws_num): + # check output files as expected + def generate_error_message(expected_file, output_dir): + return f"Unable to find {expected_file} in {output_dir}.\nContents={os.listdir(output_dir)}" + + def assert_output_file_exists(directory, filename): + test.assertTrue(os.path.isfile(os.path.join(directory, filename)), msg=generate_error_message(filename, directory)) + + user_output = os.path.join(output_dir, "17_1", "Test") + assert_output_file_exists(user_output, f"POLARIS{ws_num}.nxs") + assert_output_file_exists(user_output, f"POLARIS{ws_num}.gsas") + output_dat_dir = os.path.join(user_output, "dat_files") + for bankno in range(1, 6): + assert_output_file_exists(output_dat_dir, f"POL{ws_num}-b_{bankno}-TOF.dat") + assert_output_file_exists(output_dat_dir, f"POL{ws_num}-b_{bankno}-d.dat") + + for ws in test.focus_results: + test.assertEqual(ws.sample().getMaterial().name(), "Si Si") + test.tolerance_is_rel_err = True + test.tolerance = 1e-6 + return test.focus_results.name(), f"ISIS_Powder-POLARIS{ws_num}_FocusSempty.nxs" diff --git a/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98534_FocusSempty.nxs.md5 b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98534_FocusSempty.nxs.md5 new file mode 100644 index 000000000000..adcdcec943cc --- /dev/null +++ b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98534_FocusSempty.nxs.md5 @@ -0,0 +1 @@ +81c8bbfd41201606449de36771ce9655 diff --git a/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38535.rst b/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38535.rst new file mode 100644 index 000000000000..2fd77db640c6 --- /dev/null +++ b/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38535.rst @@ -0,0 +1 @@ +- Added new mode ``mode="pdf_norm"`` to :ref:`ISIS POLARIS powder reduction` for when the chopper is off/stationary with a default ``van_normalisation_method="absolute"``. The existing ``mode="pdf"`` now has a default ``van_normalisation_method="relative"`` (was previously ``"absolute"``). diff --git a/docs/source/techniques/ISISPowder-Polaris-v1.rst b/docs/source/techniques/ISISPowder-Polaris-v1.rst index a4edd369241c..e9f09fc548a1 100644 --- a/docs/source/techniques/ISISPowder-Polaris-v1.rst +++ b/docs/source/techniques/ISISPowder-Polaris-v1.rst @@ -358,7 +358,7 @@ and :ref:`focus_polaris_isis-powder-diffraction-ref` method. This determines which vanadium and empty run numbers to use whilst processing. -Accepted values are: **PDF** or **Rietveld** +Accepted values are: **PDF**, **PDF_NORM** or **Rietveld** *Note: This parameter is not case sensitive* @@ -371,6 +371,8 @@ Example Input: polaris_example.create_vanadium(mode="PDF", ...) # Or + polaris_example.create_vanadium(mode="PDF_NORM", ...) + # Or alternatively polaris_example.focus(mode="Rietveld", ...) .. _config_file_polaris_isis-powder-diffraction-ref: diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py index ed467bd17f40..07acde170b50 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py @@ -101,6 +101,9 @@ def get_mode_specific_dict(mode): return {"focused_cropping_values": "auto", "van_normalisation_method": "Relative"} mode = mode.lower() if mode == "pdf": + return {"focused_cropping_values": pdf_focused_cropping_values, "van_normalisation_method": "Relative"} + if mode == "pdf_norm": + # In long run this will replace gudrun return {"focused_cropping_values": pdf_focused_cropping_values, "van_normalisation_method": "Absolute"} if mode == "rietveld": return {"focused_cropping_values": rietveld_focused_cropping_values, "van_normalisation_method": "Relative"} diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py index ae042fb669ef..15f0d0b80183 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py @@ -9,4 +9,5 @@ class POLARIS_CHOPPER_MODES(object): enum_friendly_name = "Polaris chopper modes" PDF = "PDF" + PDF_NORM = "PDF_NORM" Rietveld = "Rietveld"