From f7ac817b4e36e41e93ce91c3de9f51ca50d4bc8a Mon Sep 17 00:00:00 2001 From: David Fairbrother <DavidFair@users.noreply.github.com> Date: Fri, 16 Dec 2016 11:09:57 +0000 Subject: [PATCH] Re #18108 Documented adv. params for both instruments --- scripts/Diffraction/isis_powder/pearl.py | 6 ++- .../pearl_routines/pearl_advanced_config.py | 41 +++++++++++++----- .../isis_powder/pearl_routines/pearl_algs.py | 12 +++--- .../pearl_routines/pearl_calibration.yaml | 4 +- scripts/Diffraction/isis_powder/polaris.py | 11 ++--- .../polaris_advanced_config.py | 43 ++++++++++++++++--- .../polaris_routines/polaris_algs.py | 14 +++--- .../polaris_routines/polaris_param_mapping.py | 1 + .../isis_powder/routines/common.py | 11 +++-- 9 files changed, 94 insertions(+), 49 deletions(-) diff --git a/scripts/Diffraction/isis_powder/pearl.py b/scripts/Diffraction/isis_powder/pearl.py index 8dbb2cadd6a..8c3f9c8e989 100644 --- a/scripts/Diffraction/isis_powder/pearl.py +++ b/scripts/Diffraction/isis_powder/pearl.py @@ -65,10 +65,12 @@ class Pearl(AbstractInst): return _generate_file_name(run_number=run_number) def generate_output_file_name(self, run_number): - output_name = "PEARL" + str(run_number) + + output_name = "PRL" + str(run_number) # Append each mode of operation output_name += "_" + self._inst_settings.tt_mode - output_name += "_long" if self._inst_settings.absorb_corrections else "" + output_name += "_absorb" if self._inst_settings.absorb_corrections else "" + output_name += "_long" if self._inst_settings.long_mode else "" return output_name def attenuate_workspace(self, input_workspace): diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py index c636d676343..dee95542749 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py @@ -14,9 +14,9 @@ long_mode_off_params = { "tt35_grouping": "pearl_group_12_1_TT35.cal" }, - # This needs to be greater than the bank TOF cropping values or you will get data that divides to 0/inf "monitor_lambda_crop_range": (0.03, 6.00), "monitor_integration_range": (0.6, 5.0), + # This needs to be greater than the bank TOF cropping values or you will get data that divides to 0/inf "raw_data_tof_cropping": (0, 19995), "tof_cropping_ranges": [ (1500, 19900), # Bank 1 @@ -37,9 +37,9 @@ long_mode_off_params = { } long_mode_on_params = { - # This needs to be greater than the bank TOF cropping values or you will get data that divides to 0/inf "monitor_lambda_crop_range": (5.9, 12.0), "monitor_integration_range": (6, 10), + # This needs to be greater than the bank TOF cropping values or you will get data that divides to 0/inf "raw_data_tof_cropping": (20295, 39995), "tof_cropping_ranges": [ (20300, 39990), # Bank 1 @@ -61,20 +61,39 @@ long_mode_on_params = { variable_help = { - "file_names": { - "vanadium_absorb_file_name": "Takes the name of the calculated vanadium absorption corrections. This file " - " must be located in the top level of the calibration folder", + "long_mode_<on/off>_params": { + "file_names": { + "vanadium_absorb_file_name": "Takes the name of the calculated vanadium absorption corrections. This file " + " must be located in the top level of the calibration folder", - "tt88_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT88. " - "This file must be located in the top level of the calibration folder.", + "tt88_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT88. " + "This file must be located in the top level of the calibration folder.", - "tt70_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT70. " - "This file must be located in the top level of the calibration folder.", + "tt70_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT70. " + "This file must be located in the top level of the calibration folder.", - "tt35_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT35. " - "This file must be located in the top level of the calibration folder.", + "tt35_grouping_name": "The name of the .cal file that defines the grouping of detectors in banks for TT35. " + "This file must be located in the top level of the calibration folder.", + }, + "monitor_lambda_crop_range": "The range in wavelength to crop a monitor workspace to before calculating " + "the current normalisation", + "monitor_integration_range": "The minimum and maximum values to consider whilst integrating the monitor " + "workspace", + "raw_data_tof_cropping": "The crop values for to apply when loading raw data. This step is applied before any " + "processing takes place. This is to crop from 40,000 microseconds windows in the " + "raw data to 20,000 windows in PEARL", + "tof_cropping_ranges": "These values are used to determine the TOF range to crop a focused (not Vanadium " + "Cal.) workspace to. These are applied on a bank by bank basis. They must be less than " + "the values specified for raw_data_tof_cropping." + }, + "general_params": { + "monitor_spectrum_number": "The spectrum number the monitor is located at in the workspace", + "monitor_spline_coefficient": "The coefficient to use whilst calculating a spline from the monitor." + "workspace. This is used to normalise the workspace current.", + "spline_coefficient": "The coefficient to use whilst calculating a spline for each bank during " + "a vanadium calibration." } } diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py index b386a666c93..a36ae9421db 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py @@ -46,8 +46,8 @@ def get_run_details(run_number_string, inst_settings): vanadium_run_numbers = mapping_dict["vanadium_run_numbers"] splined_vanadium_name = _generate_splined_van_name(absorb_on=inst_settings.absorb_corrections, - long_mode=inst_settings.long_mode, - vanadium_run_string=vanadium_run_numbers) + vanadium_run_string=vanadium_run_numbers, + long_mode_on=inst_settings.long_mode) calibration_dir = inst_settings.calibration_dir cycle_calibration_dir = os.path.join(calibration_dir, label) @@ -101,12 +101,10 @@ def normalise_ws_current(ws_to_correct, monitor_ws, spline_coeff, lambda_values, return normalised_ws -def _generate_splined_van_name(absorb_on, long_mode, vanadium_run_string): +def _generate_splined_van_name(absorb_on, long_mode_on, vanadium_run_string): output_string = "SVan_" + str(vanadium_run_string) - if absorb_on: - output_string += "_absorb" - if long_mode: - output_string += "_long" + output_string += "_absorb" if absorb_on else "" + output_string += "_long" if long_mode_on else "" output_string += ".nxs" return output_string diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration.yaml b/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration.yaml index 59c3749c8ab..2ce273e2385 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration.yaml +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration.yaml @@ -1,5 +1,5 @@ 94516-: - label : "16_3" + label : "16_4" vanadium_run_numbers : "95634-95647" empty_run_numbers : "95648-95654" - calibration_file : "pearl_offset_15_3.cal" # Should be "pearl_offset_16_3.cal" + calibration_file : "pearl_offset_16_4.cal" # Should be "pearl_offset_16_3.cal" diff --git a/scripts/Diffraction/isis_powder/polaris.py b/scripts/Diffraction/isis_powder/polaris.py index 35067c711cf..e5c71dd40e3 100644 --- a/scripts/Diffraction/isis_powder/polaris.py +++ b/scripts/Diffraction/isis_powder/polaris.py @@ -46,19 +46,13 @@ class Polaris(AbstractInst): def get_default_group_names(self): return self._calibration_grouping_names - # Abstract implementation - def get_run_details(self, run_number_string): input_run_number_list = common.generate_run_numbers(run_number_string=run_number_string) first_run = input_run_number_list[0] if self._run_details_last_run_number == first_run: return self._run_details_cached_obj - # TODO use _inst_settings instead - run_details = polaris_algs.get_run_details( - chopper_on=self._inst_settings.chopper_on, sac_on=self._inst_settings.solid_angle_on, - run_number=first_run, calibration_dir=self._inst_settings.calibration_dir, - mapping_path=self._inst_settings.cal_mapping_file) + run_details = polaris_algs.get_run_details(run_number=first_run, inst_settings=self._inst_settings) # Hold obj in case same run range is requested self._run_details_last_run_number = first_run @@ -118,7 +112,8 @@ class Polaris(AbstractInst): return d_spacing_group def crop_short_long_mode(self, ws_to_crop): - cropped_ws = common.crop_in_tof(ws_to_crop=ws_to_crop, x_min=800, x_max=20000) + cropped_ws = common.crop_in_tof(ws_to_crop=ws_to_crop, x_min=self._inst_settings.raw_data_crop_values[0], + x_max=self._inst_settings.raw_data_crop_values[1]) return cropped_ws def crop_banks_to_user_tof(self, focused_banks): 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 d9d49a5c889..05a1a9ebfb9 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py @@ -4,6 +4,7 @@ file_names = { script_params = { "apply_solid_angle": False, + "raw_data_cropping_values": (800, 20000), "spline_coefficient": 100 } @@ -15,14 +16,12 @@ tof_cropping_ranges = [ (1500, 19900), # Bank 5 ] -variables = { - "file_names_dict": file_names, - "script_params": script_params, - "tof_cropping_ranges": tof_cropping_ranges -} - absorption_correction_params = { - # These are read directly by the generate absorb corrections functions instead of being parsed + # These are read directly by the generate absorb corrections functions instead of being parsed. + # Therefore they cannot be overridden using basic config files or keyword arguments. + + # For documentation on their behaviour please see: + # http://docs.mantidproject.org/nightly/algorithms/CylinderAbsorption-v1.html "cylinder_sample_height": 4.0, "cylinder_sample_radius": 0.4, @@ -35,3 +34,33 @@ absorption_correction_params = { "number_of_wavelength_points": 100, "exponential_method": "Normal" } + +variable_help = { + "file_names": { + "masking_file_name": "Specifies the name of the of the file containing the positions of the Bragg Peaks to " + "mask out. This must be located at the root of the calibration folder the user has " + "specified." + }, + + "script_params": { + "apply_solid_angle": "Specifies if the script should perform solid angle corrections. This is usually " + "defaulted to off and should be overridden in the basic configuration when necessary to " + "avoid them being performed accidentally.", + "raw_data_cropping_values": "This specifies the valid range in TOF of the raw data. This is applied before any " + "processing takes place to remove negative counts where at very low TOF the empty " + "count => sample count.", + "spline_coefficient": "The coefficient to use when calculating the vanadium splines during the calibration " + "step." + }, + + "tof_cropping_ranges": "These values are used to determine the TOF range to crop a focused (not Vanadium Cal.) " + "workspace to. These are applied on a bank by bank basis. They must be less than " + "the values specified for raw_data_cropping_values." +} + +variables = { + # Used by the script to find the dictionaries in advanced config. + "file_names_dict": file_names, + "script_params": script_params, + "tof_cropping_ranges": tof_cropping_ranges +} diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index 66d8e4002a4..ca9b2a29212 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -34,10 +34,10 @@ def generate_solid_angle_corrections(run_details, instrument): return corrections -def get_run_details(chopper_on, sac_on, run_number, calibration_dir, mapping_path): - yaml_dict = yaml_parser.get_run_dictionary(run_number=run_number, file_path=mapping_path) +def get_run_details(run_number, inst_settings): + yaml_dict = yaml_parser.get_run_dictionary(run_number=run_number, file_path=inst_settings.cal_mapping_file) - if chopper_on: + if inst_settings.chopper_on: chopper_config = yaml_dict["chopper_on"] else: chopper_config = yaml_dict["chopper_off"] @@ -46,12 +46,13 @@ def get_run_details(chopper_on, sac_on, run_number, calibration_dir, mapping_pat empty_runs = chopper_config["empty_run_numbers"] vanadium_runs = chopper_config["vanadium_run_numbers"] - solid_angle_file_name = _generate_solid_angle_file_name(chopper_on=chopper_on, + solid_angle_file_name = _generate_solid_angle_file_name(chopper_on=inst_settings.chopper_on, vanadium_run_string=vanadium_runs) - splined_vanadium_name = _generate_splined_van_name(chopper_on=chopper_on, sac_applied=sac_on, + splined_vanadium_name = _generate_splined_van_name(chopper_on=inst_settings.chopper_on, + sac_applied=inst_settings.solid_angle_on, vanadium_run_string=vanadium_runs) - in_calib_dir = os.path.join(calibration_dir, label) + in_calib_dir = os.path.join(inst_settings.calibration_dir, label) calibration_full_path = os.path.join(in_calib_dir, yaml_dict["offset_file_name"]) grouping_full_path = os.path.join(in_calib_dir, yaml_dict["offset_file_name"]) solid_angle_file_path = os.path.join(in_calib_dir, solid_angle_file_name) @@ -97,6 +98,7 @@ def process_vanadium_for_focusing(bank_spectra, mask_path, spline_number): masked_workspace_list = _apply_bragg_peaks_masking(bank_spectra, mask_list=bragg_masking_list) output = common.spline_vanadium_for_focusing(focused_vanadium_spectra=masked_workspace_list, num_splines=spline_number) + common.remove_intermediate_workspace(masked_workspace_list) return output diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py index 287cfb29c83..dec95cdd42b 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py @@ -10,6 +10,7 @@ attr_mapping = [("apply_solid_angle", "solid_angle_on"), ("do_absorb_corrections", "do_absorb_corrections"), ("generate_absorb_corrections", "gen_absorb_corrections"), ("masking_file_name", "masking_file_name"), + ("raw_data_cropping_values", "raw_data_crop_values"), ("spline_coefficient", "spline_coeff"), ("tof_cropping_ranges", "tof_cropping_values"), ("output_directory", "output_dir"), diff --git a/scripts/Diffraction/isis_powder/routines/common.py b/scripts/Diffraction/isis_powder/routines/common.py index 5d1b441ede2..41584e38cd2 100644 --- a/scripts/Diffraction/isis_powder/routines/common.py +++ b/scripts/Diffraction/isis_powder/routines/common.py @@ -6,8 +6,6 @@ from isis_powder.routines.common_enums import InputBatchingEnum # A small workaround to ensure when reading workspaces in a loop # the previous workspace does not got overridden -global g_ads_workaround -g_ads_workaround = {"read_ws": 0} def create_calibration_by_names(calibration_runs, startup_objects, grouping_file_name, group_names): @@ -166,14 +164,15 @@ def _normalise_workspaces(ws_list, instrument, run_information): def _check_load_range(list_of_runs_to_load): - MAXIMUM_RANGE_LEN = 1000 # If more than this number of runs is entered probably wrong - if len(list_of_runs_to_load) > MAXIMUM_RANGE_LEN: - raise ValueError("More than " + str(MAXIMUM_RANGE_LEN) + " runs were selected." + maximum_range_len = 1000 # If more than this number of runs is entered probably wrong + if len(list_of_runs_to_load) > maximum_range_len: + raise ValueError("More than " + str(maximum_range_len) + " runs were selected." " Found " + str(len(list_of_runs_to_load)) + " Aborting.") def _create_blank_cal_file(calibration_runs, out_grouping_file_name, instrument, group_names): - input_ws_list = load_current_normalised_ws_list(calibration_runs, instrument, input_batching=InputBatchingEnum.Summed) + input_ws_list = load_current_normalised_ws_list(calibration_runs, instrument, + input_batching=InputBatchingEnum.Summed) calibration_d_spacing_ws = mantid.ConvertUnits(InputWorkspace=input_ws_list[0], Target="dSpacing") mantid.CreateCalFileByNames(InstrumentWorkspace=calibration_d_spacing_ws, GroupingFileName=out_grouping_file_name, GroupNames=group_names) -- GitLab