From 477ae747f79e5913e4280d98cc2b99ec11217606 Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Wed, 18 Dec 2024 14:29:19 +0000 Subject: [PATCH 1/8] Updated vanadium norm dict as per issue #37795 Some extra changes will be needed as this norm_dict doesn't seem to be called properly --- .../isis_powder/polaris_routines/polaris_advanced_config.py | 3 +++ 1 file changed, 3 insertions(+) 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"} From 74dc1a0c977116eb5ce0bb4f3d245cfd3d62d817 Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Wed, 18 Dec 2024 17:15:35 +0000 Subject: [PATCH 2/8] Removed hard-coded vanadium normalisation method --- Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index 25459eebd625..dbd39a4448ca 100644 --- a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py @@ -588,7 +588,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, ) @@ -636,7 +635,6 @@ def run_focus_absorption(run_number, paalman_pings=False): do_absorb_corrections=True, sample_empty=sample_empty, multiple_scattering=False, - van_normalisation_method="Relative", ) else: return inst_object.focus( @@ -647,7 +645,6 @@ def run_focus_absorption(run_number, paalman_pings=False): sample_empty=sample_empty, sample_empty_scale=sample_empty_scale, multiple_scattering=False, - van_normalisation_method="Relative", ) From c7197f7f200c40528271620da3c7b1996ce021af Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Fri, 20 Dec 2024 09:29:03 +0000 Subject: [PATCH 3/8] Added test support for pdf_norm options #37795 Updated the enum to recognise the option and updated the tests so "Relative" is no longer hard coded - added an extra test some corresponding files --- .../tests/framework/ISIS_PowderPolarisTest.py | 60 +++++++++++++++++-- .../polaris_routines/polaris_enums.py | 1 + 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index dbd39a4448ca..676d8ef3db1d 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,7 +126,7 @@ 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 @@ -159,6 +159,49 @@ def cleanup(self): config["datasearch.directories"] = self.existing_config +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): + # 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)) + + def assert_output_file_exists(directory, filename): + self.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, "POLARIS98534.nxs") + assert_output_file_exists(user_output, "POLARIS98534.gsas") + output_dat_dir = os.path.join(user_output, "dat_files") + for bankno in range(1, 6): + assert_output_file_exists(output_dat_dir, "POL98534-b_{}-TOF.dat".format(bankno)) + assert_output_file_exists(output_dat_dir, "POL98534-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-POLARIS98534_FocusSempty.nxs" + + def cleanup(self): + try: + _try_delete(spline_path) + _try_delete(output_dir) + finally: + mantid.mtd.clear() + config["datasearch.directories"] = self.existing_config + + class FocusTestAbsorptionPaalmanPings(systemtesting.MantidSystemTest): focus_results = None existing_config = config["datasearch.directories"] @@ -534,7 +577,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 +609,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 +628,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", 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" From e9fbdbfd0696c7a2404604e4f0c2c70704b82086 Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Fri, 20 Dec 2024 10:03:54 +0000 Subject: [PATCH 4/8] Updated Test files for pdf_norm inclusion #37795 --- .../Data/SystemTest/ISIS_Powder/input/POLARIS00098534.nxs.md5 | 1 + .../input/yaml_files/polaris_system_test_mapping.yaml.md5 | 2 +- .../reference/ISIS_Powder-POLARIS98534_FocusSempty.nxs.md5 | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Testing/Data/SystemTest/ISIS_Powder/input/POLARIS00098534.nxs.md5 create mode 100644 Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98534_FocusSempty.nxs.md5 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/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 From ed9ce53bc31a303ed6ff3bfec9a3ac7de6b3ccd0 Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Thu, 9 Jan 2025 11:16:37 +0000 Subject: [PATCH 5/8] moved repeated validation code to helper --- .../tests/framework/ISIS_PowderPolarisTest.py | 65 +++++++------------ 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index 676d8ef3db1d..25d8c3a53af4 100644 --- a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py @@ -129,26 +129,7 @@ def runTest(self): 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)) - - def assert_output_file_exists(directory, filename): - self.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, "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" + return validate_normalisation_focus_tests(self, "98533") def cleanup(self): try: @@ -172,26 +153,7 @@ def runTest(self): self.focus_results = run_focus_no_absorption(mode="PDF_NORM") 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)) - - def assert_output_file_exists(directory, filename): - self.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, "POLARIS98534.nxs") - assert_output_file_exists(user_output, "POLARIS98534.gsas") - output_dat_dir = os.path.join(user_output, "dat_files") - for bankno in range(1, 6): - assert_output_file_exists(output_dat_dir, "POL98534-b_{}-TOF.dat".format(bankno)) - assert_output_file_exists(output_dat_dir, "POL98534-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-POLARIS98534_FocusSempty.nxs" + return validate_normalisation_focus_tests(self, "98534") def cleanup(self): try: @@ -746,3 +708,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" From d9600384d742dd4ff4a8c26f48bf5df74118bd5c Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Thu, 9 Jan 2025 12:09:59 +0000 Subject: [PATCH 6/8] improved run_focus_absorption readability --- .../tests/framework/ISIS_PowderPolarisTest.py | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index 25d8c3a53af4..31f5ab9c3761 100644 --- a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py @@ -634,28 +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, - ) 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, - ) + 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(): From 753a65770aea8d202bde42747285a58bc72de16c Mon Sep 17 00:00:00 2001 From: andy-bridger <71634246+andy-bridger@users.noreply.github.com> Date: Mon, 13 Jan 2025 09:58:15 +0000 Subject: [PATCH 7/8] Add release notes --- .../release/v6.12.0/Diffraction/Powder/New_features/38535.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/source/release/v6.12.0/Diffraction/Powder/New_features/38535.rst 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"``). From a3e4aada69ccd47048409fc358902df0d4c94f97 Mon Sep 17 00:00:00 2001 From: Andy Bridger Date: Mon, 13 Jan 2025 09:59:55 +0000 Subject: [PATCH 8/8] Updated the Polaris Docs --- docs/source/techniques/ISISPowder-Polaris-v1.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: