Skip to content
Snippets Groups Projects
Commit fc650123 authored by Elliot Oram's avatar Elliot Oram Committed by Sam Jenkins
Browse files

WIP automatically determine Chopper mode on POLARIS

Refs #24150
parent 85919fcd
No related merge requests found
...@@ -100,10 +100,7 @@ variables = { ...@@ -100,10 +100,7 @@ variables = {
def get_mode_specific_dict(mode): def get_mode_specific_dict(mode):
if mode is None: if mode is None:
raise RuntimeError("The parameter with name: 'mode' is required but " return {"focused_cropping_values": 'auto'}
"was not set or passed.\n"
"Acceptable values for this parameter are: PDF, Rietveld.")
mode = mode.lower() mode = mode.lower()
if mode == "pdf": if mode == "pdf":
return {"focused_cropping_values": pdf_focused_cropping_values} return {"focused_cropping_values": pdf_focused_cropping_values}
...@@ -112,7 +109,7 @@ def get_mode_specific_dict(mode): ...@@ -112,7 +109,7 @@ def get_mode_specific_dict(mode):
raise ValueError("Invalid chopper mode: \"{}\"".format(mode)) raise ValueError("Invalid chopper mode: \"{}\"".format(mode))
def get_all_adv_variables(mode="PDF"): def get_all_adv_variables(mode=None):
advanced_config_dict = {} advanced_config_dict = {}
advanced_config_dict.update(variables) advanced_config_dict.update(variables)
advanced_config_dict.update(get_mode_specific_dict(mode)) advanced_config_dict.update(get_mode_specific_dict(mode))
......
...@@ -34,6 +34,12 @@ def _get_run_numbers_for_key(current_mode_run_numbers, key): ...@@ -34,6 +34,12 @@ def _get_run_numbers_for_key(current_mode_run_numbers, key):
def _get_current_mode_dictionary(run_number_string, inst_settings): def _get_current_mode_dictionary(run_number_string, inst_settings):
mapping_dict = get_cal_mapping_dict(run_number_string, inst_settings.cal_mapping_path) mapping_dict = get_cal_mapping_dict(run_number_string, inst_settings.cal_mapping_path)
if inst_settings.mode is None:
ws = mantid.Load('POLARIS'+run_number_string+'.nxs')
mode, cropping_vals = _determine_chopper_mode(ws)
inst_settings.mode = mode
inst_settings.focused_cropping_values = cropping_vals
mantid.DeleteWorkspace(ws)
# Get the current mode "Rietveld" or "PDF" run numbers # Get the current mode "Rietveld" or "PDF" run numbers
return common.cal_map_dictionary_key_helper(mapping_dict, inst_settings.mode) return common.cal_map_dictionary_key_helper(mapping_dict, inst_settings.mode)
...@@ -161,3 +167,17 @@ def _read_masking_file(masking_file_path): ...@@ -161,3 +167,17 @@ def _read_masking_file(masking_file_path):
if bank_masking_list: if bank_masking_list:
all_banks_masking_list.append(bank_masking_list) all_banks_masking_list.append(bank_masking_list)
return all_banks_masking_list return all_banks_masking_list
def _determine_chopper_mode(ws):
if ws.getRun().hasProperty('Frequency'):
frequency = ws.getRun()['Frequency'].lastValue()
print("No chopper mode provided")
if frequency == 50:
print("automatically chose Rietveld")
return 'Rietveld', polaris_advanced_config.rietveld_focused_cropping_values
if frequency == 0:
print("automatically chose PDF")
return 'PDF', polaris_advanced_config.pdf_focused_cropping_values
else:
raise ValueError("Chopper frequency not in log data. Please specify a chopper mode")
...@@ -25,7 +25,7 @@ attr_mapping = \ ...@@ -25,7 +25,7 @@ attr_mapping = \
ParamMapEntry(ext_name="grouping_file_name", int_name="grouping_file_name"), ParamMapEntry(ext_name="grouping_file_name", int_name="grouping_file_name"),
ParamMapEntry(ext_name="input_mode", int_name="input_mode", enum_class=INPUT_BATCHING), ParamMapEntry(ext_name="input_mode", int_name="input_mode", enum_class=INPUT_BATCHING),
ParamMapEntry(ext_name="merge_banks", int_name="merge_banks"), ParamMapEntry(ext_name="merge_banks", int_name="merge_banks"),
ParamMapEntry(ext_name="mode", int_name="mode", enum_class=POLARIS_CHOPPER_MODES), ParamMapEntry(ext_name="mode", int_name="mode", enum_class=POLARIS_CHOPPER_MODES, optional=True),
ParamMapEntry(ext_name="multiple_scattering", int_name="multiple_scattering", optional=True), ParamMapEntry(ext_name="multiple_scattering", int_name="multiple_scattering", optional=True),
ParamMapEntry(ext_name="raw_data_cropping_values", int_name="raw_data_crop_values"), ParamMapEntry(ext_name="raw_data_cropping_values", int_name="raw_data_crop_values"),
ParamMapEntry(ext_name="run_number", int_name="run_number"), ParamMapEntry(ext_name="run_number", int_name="run_number"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment