Skip to content
Snippets Groups Projects
Commit 219dd216 authored by David Fairbrother's avatar David Fairbrother
Browse files

Re #18108 Move POLARIS onto Instrument settings class

parent 0016add1
No related branches found
No related tags found
No related merge requests found
...@@ -114,9 +114,6 @@ class AbstractInst(object): ...@@ -114,9 +114,6 @@ class AbstractInst(object):
def attenuate_workspace(self, input_workspace): def attenuate_workspace(self, input_workspace):
return input_workspace return input_workspace
def correct_sample_vanadium(self, focused_ws, vanadium_ws=None):
raise NotImplementedError("Cannot process the sample with a vanadium run for this instrument")
def get_default_group_names(self): def get_default_group_names(self):
return None return None
......
...@@ -5,21 +5,19 @@ import mantid.simpleapi as mantid ...@@ -5,21 +5,19 @@ import mantid.simpleapi as mantid
from isis_powder.routines import common, InstrumentSettings, yaml_parser from isis_powder.routines import common, InstrumentSettings, yaml_parser
from isis_powder.routines.common_enums import InputBatchingEnum from isis_powder.routines.common_enums import InputBatchingEnum
from isis_powder.abstract_inst import AbstractInst from isis_powder.abstract_inst import AbstractInst
from isis_powder.pearl_routines import pearl_algs, pearl_output, pearl_advanced_config from isis_powder.pearl_routines import pearl_algs, pearl_output, pearl_advanced_config, pearl_param_mapping
class Pearl(AbstractInst): class Pearl(AbstractInst):
def __init__(self, **kwargs): def __init__(self, **kwargs):
expected_attr = ["user_name", "config_file_name", "calibration_dir", "output_dir", "attenuation_file_name", expected_attr = ["user_name", "config_file_name", "calibration_dir", "output_dir", "attenuation_file_name",
"cal_map_path", "van_absorb_file"] "cal_map_path", "van_absorb_file"]
# Parse all possible locations that the parameters can be set from
basic_config_dict = yaml_parser.open_yaml_file_as_dictionary(kwargs.get("config_file", None)) basic_config_dict = yaml_parser.open_yaml_file_as_dictionary(kwargs.get("config_file", None))
self._inst_settings = InstrumentSettings.InstrumentSettings( self._inst_settings = InstrumentSettings.InstrumentSettings(
attr_mapping=self.attr_mapping, adv_conf_dict=pearl_advanced_config.variables, attr_mapping=pearl_param_mapping.attr_mapping, adv_conf_dict=pearl_advanced_config.variables,
basic_conf_dict=basic_config_dict, kwargs=kwargs) basic_conf_dict=basic_config_dict, kwargs=kwargs)
self._inst_settings.check_expected_attributes_are_set(attr_mapping=self.attr_mapping, self._inst_settings.check_expected_attributes_are_set(expected_attr_names=expected_attr)
expected_attr_names=expected_attr)
super(Pearl, self).__init__(user_name=self._inst_settings.user_name, super(Pearl, self).__init__(user_name=self._inst_settings.user_name,
calibration_dir=self._inst_settings.calibration_dir, calibration_dir=self._inst_settings.calibration_dir,
...@@ -30,10 +28,9 @@ class Pearl(AbstractInst): ...@@ -30,10 +28,9 @@ class Pearl(AbstractInst):
self._cached_run_details_number = None self._cached_run_details_number = None
def focus(self, run_number, **kwargs): def focus(self, run_number, **kwargs):
self._inst_settings.update_attributes_from_kwargs(attr_mapping=self.attr_mapping, kwargs=kwargs) self._inst_settings.update_attributes_from_kwargs(kwargs=kwargs)
expected_attr = ["absorb_corrections", "long_mode", "tt_mode", "perform_atten", "van_norm"] expected_attr = ["absorb_corrections", "long_mode", "tt_mode", "perform_atten", "van_norm"]
self._inst_settings.check_expected_attributes_are_set(attr_mapping=self.attr_mapping, self._inst_settings.check_expected_attributes_are_set(expected_attr_names=expected_attr)
expected_attr_names=expected_attr)
return self._focus(run_number=run_number, input_batching=InputBatchingEnum.Summed, return self._focus(run_number=run_number, input_batching=InputBatchingEnum.Summed,
do_van_normalisation=self._inst_settings.van_norm) do_van_normalisation=self._inst_settings.van_norm)
...@@ -41,10 +38,9 @@ class Pearl(AbstractInst): ...@@ -41,10 +38,9 @@ class Pearl(AbstractInst):
def create_calibration_vanadium(self, run_in_range, **kwargs): def create_calibration_vanadium(self, run_in_range, **kwargs):
kwargs["tt_mode"] = "tt88" kwargs["tt_mode"] = "tt88"
kwargs["perform_attenuation"] = False kwargs["perform_attenuation"] = False
self._inst_settings.update_attributes_from_kwargs(attr_mapping=self.attr_mapping, kwargs=kwargs) self._inst_settings.update_attributes_from_kwargs(kwargs=kwargs)
expected_attr = ["long_mode", "van_norm", "absorb_corrections"] expected_attr = ["long_mode", "van_norm", "absorb_corrections"]
self._inst_settings.check_expected_attributes_are_set(attr_mapping=self.attr_mapping, self._inst_settings.check_expected_attributes_are_set(expected_attr_names=expected_attr)
expected_attr_names=expected_attr)
run_details = self.get_run_details(run_number_string=int(run_in_range)) run_details = self.get_run_details(run_number_string=int(run_in_range))
run_details.run_number = run_details.vanadium_run_numbers run_details.run_number = run_details.vanadium_run_numbers
...@@ -120,48 +116,6 @@ class Pearl(AbstractInst): ...@@ -120,48 +116,6 @@ class Pearl(AbstractInst):
def generate_vanadium_absorb_corrections(self, run_details, ws_to_match): def generate_vanadium_absorb_corrections(self, run_details, ws_to_match):
return pearl_algs.generate_vanadium_absorb_corrections(van_ws=ws_to_match) return pearl_algs.generate_vanadium_absorb_corrections(van_ws=ws_to_match)
def correct_sample_vanadium(self, focused_ws, vanadium_ws=None):
# TODO does this need doing per bank - currently we call this with each and every spectra?
# TODO instead we should just pass a spectra list
import pydevd
pydevd.settrace('localhost', port=51205, stdoutToServer=True, stderrToServer=True)
data_ws = mantid.ConvertUnits(InputWorkspace=focused_ws, Target="TOF")
if vanadium_ws:
# Workaround for Mantid overwriting the WS in a loop
data_processed = "van_processed" + str(self._ads_workaround)
vanadium_ws = mantid.RebinToWorkspace(WorkspaceToRebin=vanadium_ws, WorkspaceToMatch=data_ws)
data_ws = mantid.Divide(LHSWorkspace=data_ws, RHSWorkspace=vanadium_ws, OutputWorkspace=data_processed)
else:
data_processed = "processed-" + str(self._ads_workaround)
data_ws = mantid.RenameWorkspace(InputWorkspace=data_ws, OutputWorkspace=data_processed)
self._ads_workaround += 1
divided_ws = mantid.CropWorkspace(InputWorkspace=data_ws, XMin=0.1, OutputWorkspace=data_ws)
if vanadium_ws:
divided_ws = mantid.Scale(InputWorkspace=divided_ws, Factor=10, OutputWorkspace=divided_ws)
return divided_ws
# Maps friendly user name -> script name
attr_mapping = [("attenuation_file_name", "attenuation_file_name"),
("config_file", "config_file_name"),
("calibration_config_path", "cal_map_path"),
("calibration_directory", "calibration_dir"),
("do_absorb_corrections", "absorb_corrections"),
("focus_mode", "focus_mode"),
("long_mode", "long_mode"),
("output_directory", "output_dir"),
("perform_attenuation", "perform_atten"),
("spline_coefficient", "spline_coefficient"),
("tt88_grouping", "tt88_grouping"),
("tt70_grouping", "tt70_grouping"),
("tt35_grouping", "tt35_grouping"),
("tt_mode", "tt_mode"),
("user_name", "user_name"),
("vanadium_absorb_file", "van_absorb_file"),
("vanadium_normalisation", "van_norm")]
def _generate_file_name(run_number): def _generate_file_name(run_number):
digit = len(str(run_number)) digit = len(str(run_number))
......
...@@ -5,10 +5,6 @@ file_names = { ...@@ -5,10 +5,6 @@ file_names = {
"tt35_grouping": "pearl_group_12_1_TT35.cal" "tt35_grouping": "pearl_group_12_1_TT35.cal"
} }
script_params = {
"spline_coefficient": 60,
}
tof_cropping_ranges = [ tof_cropping_ranges = [
(1500, 19900), # Bank 1 (1500, 19900), # Bank 1
(1500, 19900), # Bank 2 (1500, 19900), # Bank 2
...@@ -26,6 +22,10 @@ tof_cropping_ranges = [ ...@@ -26,6 +22,10 @@ tof_cropping_ranges = [
(1500, 19900) # Bank 14 (1500, 19900) # Bank 14
] ]
script_params = {
"spline_coefficient": 60,
"bank_tof_crop_values": tof_cropping_ranges,
}
variable_help = { variable_help = {
"file_names": { "file_names": {
...@@ -46,7 +46,6 @@ variable_help = { ...@@ -46,7 +46,6 @@ variable_help = {
} }
variables = { variables = {
"bank_tof_crop_values" : tof_cropping_ranges,
"file_names_dict": file_names, "file_names_dict": file_names,
"script_params_dict": script_params "script_params_dict": script_params
} }
from __future__ import (absolute_import, division, print_function)
# Maps friendly user name -> script name
attr_mapping = [("attenuation_file_name", "attenuation_file_name"),
("config_file", "config_file_name"),
("calibration_config_path", "cal_map_path"),
("calibration_directory", "calibration_dir"),
("do_absorb_corrections", "absorb_corrections"),
("focus_mode", "focus_mode"),
("long_mode", "long_mode"),
("output_directory", "output_dir"),
("perform_attenuation", "perform_atten"),
("spline_coefficient", "spline_coefficient"),
("tt88_grouping", "tt88_grouping"),
("tt70_grouping", "tt70_grouping"),
("tt35_grouping", "tt35_grouping"),
("tt_mode", "tt_mode"),
("user_name", "user_name"),
("vanadium_absorb_file", "van_absorb_file"),
("vanadium_normalisation", "van_norm")]
...@@ -5,24 +5,25 @@ import os ...@@ -5,24 +5,25 @@ import os
import mantid.simpleapi as mantid import mantid.simpleapi as mantid
import isis_powder.routines.common as common import isis_powder.routines.common as common
from isis_powder.routines import yaml_parser from isis_powder.routines import yaml_parser, InstrumentSettings
from isis_powder.abstract_inst import AbstractInst from isis_powder.abstract_inst import AbstractInst
from isis_powder.polaris_routines import polaris_advanced_config, polaris_algs, polaris_output from isis_powder.polaris_routines import polaris_advanced_config, polaris_algs, polaris_output, polaris_param_mapping
class Polaris(AbstractInst): class Polaris(AbstractInst):
# Instrument specific properties def __init__(self, **kwargs):
expected_keys = ["user_name", "calibration_dir", "output_dir", "cal_mapping_file",
"solid_angle_on", "chopper_on"]
basic_config_dict = yaml_parser.open_yaml_file_as_dictionary(kwargs.get("config_file", None))
self._inst_settings = InstrumentSettings.InstrumentSettings(
attr_mapping=polaris_param_mapping.attr_mapping, adv_conf_dict=polaris_advanced_config.variables,
basic_conf_dict=basic_config_dict, kwargs=kwargs)
def __init__(self, chopper_on, config_file=None, **kwargs): self._inst_settings.check_expected_attributes_are_set(expected_attr_names=expected_keys)
expected_keys = ["user_name", "calibration_directory", "output_directory", super(Polaris, self).__init__(user_name=self._inst_settings.user_name,
"apply_solid_angle", "calibration_mapping_file"] calibration_dir=self._inst_settings.calibration_dir,
yaml_parser.set_kwargs_from_config_file(config_path=config_file, kwargs=kwargs, keys_to_find=expected_keys) output_dir=self._inst_settings.output_dir)
super(Polaris, self).__init__(user_name=kwargs["user_name"], calibration_dir=kwargs["calibration_directory"],
output_dir=kwargs["output_directory"])
self._calibration_mapping_path = kwargs["calibration_mapping_file"]
self._chopper_on = chopper_on
# Hold the last dictionary later to avoid us having to keep parsing the YAML # Hold the last dictionary later to avoid us having to keep parsing the YAML
self._run_details_last_run_number = None self._run_details_last_run_number = None
...@@ -52,10 +53,11 @@ class Polaris(AbstractInst): ...@@ -52,10 +53,11 @@ class Polaris(AbstractInst):
if self._run_details_last_run_number == first_run: if self._run_details_last_run_number == first_run:
return self._run_details_cached_obj return self._run_details_cached_obj
solid_angle_on = bool(polaris_advanced_config.standard_variables["apply_solid_angle_corrections"]) # TODO use _inst_settings instead
run_details = polaris_algs.get_run_details(chopper_on=self._chopper_on, sac_on=solid_angle_on, run_details = polaris_algs.get_run_details(
run_number=first_run, calibration_dir=self._calibration_dir, chopper_on=self._inst_settings.chopper_on, sac_on=self._inst_settings.solid_angle_on,
mapping_path=self._calibration_mapping_path) run_number=first_run, calibration_dir=self._inst_settings.calibration_dir,
mapping_path=self._inst_settings.cal_mapping_file)
# Hold obj in case same run range is requested # Hold obj in case same run range is requested
self._run_details_last_run_number = first_run self._run_details_last_run_number = first_run
...@@ -76,7 +78,7 @@ class Polaris(AbstractInst): ...@@ -76,7 +78,7 @@ class Polaris(AbstractInst):
return normalised_ws return normalised_ws
def apply_solid_angle_efficiency_corr(self, ws_to_correct, run_details): def apply_solid_angle_efficiency_corr(self, ws_to_correct, run_details):
solid_angle_on = bool(polaris_advanced_config.standard_variables["apply_solid_angle_corrections"]) solid_angle_on = bool(polaris_advanced_config.script_params["apply_solid_angle_corrections"])
if not solid_angle_on: if not solid_angle_on:
return ws_to_correct return ws_to_correct
...@@ -88,25 +90,13 @@ class Polaris(AbstractInst): ...@@ -88,25 +90,13 @@ class Polaris(AbstractInst):
ws_to_correct = corrected_ws ws_to_correct = corrected_ws
return ws_to_correct return ws_to_correct
def correct_sample_vanadium(self, focused_ws, vanadium_ws=None):
spectra_name = "sample_ws-" + str(self._ads_workaround + 1)
self._ads_workaround += 1
if vanadium_ws:
van_rebinned = mantid.RebinToWorkspace(WorkspaceToRebin=vanadium_ws, WorkspaceToMatch=focused_ws)
mantid.Divide(LHSWorkspace=focused_ws, RHSWorkspace=van_rebinned, OutputWorkspace=spectra_name)
common.remove_intermediate_workspace(van_rebinned)
return spectra_name
def spline_vanadium_ws(self, focused_vanadium_spectra, instrument_version=''): def spline_vanadium_ws(self, focused_vanadium_spectra, instrument_version=''):
masking_file_name = polaris_advanced_config.file_names["bragg_peaks_masking"] masking_file_name = polaris_advanced_config.file_names["bragg_peaks_masking"]
spline_coeff = polaris_advanced_config.standard_variables["b_spline_coefficient"] spline_coeff = polaris_advanced_config.script_params["b_spline_coefficient"]
masking_file_path = os.path.join(self.calibration_dir, masking_file_name) masking_file_path = os.path.join(self.calibration_dir, masking_file_name)
output = polaris_algs.process_vanadium_for_focusing(bank_spectra=focused_vanadium_spectra, output = polaris_algs.process_vanadium_for_focusing(bank_spectra=focused_vanadium_spectra,
spline_number=spline_coeff, spline_number=spline_coeff,
mask_path=masking_file_path) mask_path=masking_file_path)
return output return output
def generate_vanadium_absorb_corrections(self, calibration_full_paths, ws_to_match): def generate_vanadium_absorb_corrections(self, calibration_full_paths, ws_to_match):
......
...@@ -2,7 +2,7 @@ file_names = { ...@@ -2,7 +2,7 @@ file_names = {
"bragg_peaks_masking": "VanaPeaks.dat" "bragg_peaks_masking": "VanaPeaks.dat"
} }
standard_variables = { script_params = {
"apply_solid_angle_corrections": False, "apply_solid_angle_corrections": False,
"b_spline_coefficient": 100 "b_spline_coefficient": 100
} }
...@@ -20,3 +20,9 @@ absorption_correction_params = { ...@@ -20,3 +20,9 @@ absorption_correction_params = {
"number_of_wavelength_points": 100, "number_of_wavelength_points": 100,
"exponential_method": "Normal" "exponential_method": "Normal"
} }
variables = {
"absorb_param_dict": absorption_correction_params,
"file_names_dict": file_names,
"script_params": script_params
}
from __future__ import (absolute_import, division, print_function)
# Maps friendly user name -> script name
attr_mapping = [("apply_solid_angle", "solid_angle_on"),
("calibration_directory", "calibration_dir"),
("calibration_mapping_file", "cal_mapping_file"),
("chopper_on", "chopper_on"),
("config_file", "config_file"),
("output_directory", "output_dir"),
("user_name", "user_name")]
...@@ -15,10 +15,11 @@ warnings.simplefilter('always', UserWarning) ...@@ -15,10 +15,11 @@ warnings.simplefilter('always', UserWarning)
class InstrumentSettings(object): class InstrumentSettings(object):
# Holds instance variables updated at runtime # Holds instance variables updated at runtime
def __init__(self, attr_mapping, adv_conf_dict=None, basic_conf_dict=None, kwargs=None): def __init__(self, attr_mapping, adv_conf_dict=None, basic_conf_dict=None, kwargs=None):
self._attr_mapping = attr_mapping
self._unknown_keys_found = False self._unknown_keys_found = False
self._parse_attributes(dict_to_parse=adv_conf_dict, attribute_mapping=attr_mapping) self._parse_attributes(dict_to_parse=adv_conf_dict)
self._parse_attributes(dict_to_parse=basic_conf_dict, attribute_mapping=attr_mapping) self._parse_attributes(dict_to_parse=basic_conf_dict)
self._parse_attributes(dict_to_parse=kwargs, attribute_mapping=attr_mapping) self._parse_attributes(dict_to_parse=kwargs)
if self._unknown_keys_found: if self._unknown_keys_found:
_print_known_keys(attr_mapping) _print_known_keys(attr_mapping)
...@@ -28,21 +29,21 @@ class InstrumentSettings(object): ...@@ -28,21 +29,21 @@ class InstrumentSettings(object):
"skipped or a script attribute name has changed." "skipped or a script attribute name has changed."
"\nPlease contact the development team.\n") "\nPlease contact the development team.\n")
def check_expected_attributes_are_set(self, attr_mapping, expected_attr_names): def check_expected_attributes_are_set(self, expected_attr_names):
for expected_attr in expected_attr_names: for expected_attr in expected_attr_names:
if not [attr_entry for attr_entry in attr_mapping if expected_attr == attr_entry[-1]]: if not [attr_entry for attr_entry in self._attr_mapping if expected_attr == attr_entry[-1]]:
raise ValueError("Expected attribute '" + str(expected_attr) + "' is unknown to attribute mapping") raise ValueError("Expected attribute '" + str(expected_attr) + "' is unknown to attribute mapping")
# Filter down the full mapping list # Filter down the full mapping list
found_tuple_list = [tuple_entry for tuple_entry in attr_mapping if tuple_entry[-1] in expected_attr_names] found_tuple_list = [tuple_entry for tuple_entry in self._attr_mapping if tuple_entry[-1] in expected_attr_names]
expected_params_dict = dict(found_tuple_list) expected_params_dict = dict(found_tuple_list)
self._check_attribute_is_set(expected_params_dict) self._check_attribute_is_set(expected_params_dict)
def update_attributes_from_kwargs(self, attr_mapping, kwargs): def update_attributes_from_kwargs(self, kwargs):
has_known_keys_already_been_printed = self._unknown_keys_found has_known_keys_already_been_printed = self._unknown_keys_found
self._parse_attributes(dict_to_parse=kwargs, attribute_mapping=attr_mapping) self._parse_attributes(dict_to_parse=kwargs)
if not has_known_keys_already_been_printed and self._unknown_keys_found: if not has_known_keys_already_been_printed and self._unknown_keys_found:
_print_known_keys(attr_mapping) _print_known_keys(self._attr_mapping)
def _check_attribute_is_set(self, expected_attributes_dict): def _check_attribute_is_set(self, expected_attributes_dict):
for config_name in expected_attributes_dict: for config_name in expected_attributes_dict:
...@@ -52,19 +53,19 @@ class InstrumentSettings(object): ...@@ -52,19 +53,19 @@ class InstrumentSettings(object):
raise ValueError("Required parameter '" + str(config_name) + raise ValueError("Required parameter '" + str(config_name) +
"' was not set in any of the config files or passed as a parameter.\n") "' was not set in any of the config files or passed as a parameter.\n")
def _parse_attributes(self, dict_to_parse, attribute_mapping): def _parse_attributes(self, dict_to_parse):
if not dict_to_parse: if not dict_to_parse:
return return
for config_key in dict_to_parse: for config_key in dict_to_parse:
# Recurse down all dictionaries # Recurse down all dictionaries
if isinstance(dict_to_parse[config_key], dict): if isinstance(dict_to_parse[config_key], dict):
self._parse_attributes(dict_to_parse[config_key], attribute_mapping) self._parse_attributes(dict_to_parse[config_key])
continue # Skip so we don't accidentally re-add this dictionary continue # Skip so we don't accidentally re-add this dictionary
# Update attributes from said dictionary # Update attributes from said dictionary
found_attribute = next((attr_tuple for attr_tuple in attribute_mapping if config_key == attr_tuple[0]), found_attribute = next((attr_tuple for attr_tuple in self._attr_mapping
None) if config_key == attr_tuple[0]), None)
if found_attribute: if found_attribute:
# The first element of the attribute is the config name and the last element is the name scripts use # The first element of the attribute is the config name and the last element is the name scripts use
self._update_attribute(attr_name=found_attribute[-1], attr_val=dict_to_parse[found_attribute[0]]) self._update_attribute(attr_name=found_attribute[-1], attr_val=dict_to_parse[found_attribute[0]])
...@@ -80,6 +81,7 @@ class InstrumentSettings(object): ...@@ -80,6 +81,7 @@ class InstrumentSettings(object):
def _print_known_keys(master_mapping): def _print_known_keys(master_mapping):
print ("\nKnown keys are:") print ("\nKnown keys are:")
print("----------------------------------") print("----------------------------------")
for tuple_entry in master_mapping: sorted_attributes = sorted(master_mapping, key=lambda tup: tup[0])
for tuple_entry in sorted_attributes:
print (tuple_entry[0] + '\t', end="") print (tuple_entry[0] + '\t', end="")
print("\n----------------------------------") print("\n----------------------------------")
...@@ -39,9 +39,9 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm): ...@@ -39,9 +39,9 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm):
focused_ws = mantid.DiffractionFocussing(InputWorkspace=input_workspace, focused_ws = mantid.DiffractionFocussing(InputWorkspace=input_workspace,
GroupingFileName=run_details.grouping_file_path) GroupingFileName=run_details.grouping_file_path)
calibrated_spectra = _divide_sample_by_vanadium(instrument=instrument, run_number=run_number, calibrated_spectra = _apply_vanadium_corrections(instrument=instrument, run_number=run_number,
input_workspace=focused_ws, input_workspace=focused_ws,
perform_vanadium_norm=perform_vanadium_norm) perform_vanadium_norm=perform_vanadium_norm)
# Output # Output
processed_nexus_files = instrument.output_focused_ws(calibrated_spectra, run_details=run_details) processed_nexus_files = instrument.output_focused_ws(calibrated_spectra, run_details=run_details)
...@@ -64,27 +64,30 @@ def _batched_run_focusing(input_batching, instrument, perform_vanadium_norm, run ...@@ -64,27 +64,30 @@ def _batched_run_focusing(input_batching, instrument, perform_vanadium_norm, run
return output return output
def _divide_sample_by_vanadium(instrument, run_number, input_workspace, perform_vanadium_norm): def _apply_vanadium_corrections(instrument, run_number, input_workspace, perform_vanadium_norm):
processed_spectra = []
run_details = instrument.get_run_details(run_number_string=run_number) run_details = instrument.get_run_details(run_number_string=run_number)
split_ws = common.extract_and_crop_spectra(input_workspace, instrument=instrument) converted_ws = mantid.ConvertUnits(InputWorkspace=input_workspace, OutputWorkspace=input_workspace, Target="TOF")
split_data_spectra = common.extract_and_crop_spectra(converted_ws, instrument=instrument)
if perform_vanadium_norm: if perform_vanadium_norm:
vanadium_ws_list = mantid.LoadNexus(Filename=run_details.splined_vanadium_file_path) processed_spectra = _divide_by_vanadium_splines(spectra_list=split_data_spectra,
for focus_spectra, van_spectra in zip(split_ws, vanadium_ws_list[1:]): spline_file_path=run_details.splined_vanadium_file_path)
processed_spectra.append(
instrument.correct_sample_vanadium(focused_ws=focus_spectra, vanadium_ws=van_spectra))
common.remove_intermediate_workspace(vanadium_ws_list[0])
else: else:
for focus_spectra in split_ws: processed_spectra = split_data_spectra
processed_spectra.append(instrument.correct_sample_vanadium(focused_ws=focus_spectra))
common.remove_intermediate_workspace(split_ws)
return processed_spectra return processed_spectra
def _divide_by_vanadium_splines(spectra_list, spline_file_path):
vanadium_ws_list = mantid.LoadNexus(Filename=spline_file_path)
output_list = []
for data_ws, van_ws in zip(spectra_list, vanadium_ws_list[1:]):
vanadium_ws = mantid.RebinToWorkspace(WorkspaceToRebin=van_ws, WorkspaceToMatch=data_ws)
output_ws = mantid.Divide(LHSWorkspace=data_ws, RHSWorkspace=vanadium_ws, OutputWorkspace=data_ws)
output_list.append(output_ws)
return output_list
def _individual_run_focusing(input_batching, instrument, perform_vanadium_norm, run_number): def _individual_run_focusing(input_batching, instrument, perform_vanadium_norm, run_number):
# Load and process one by one # Load and process one by one
run_numbers = common.generate_run_numbers(run_number_string=run_number) run_numbers = common.generate_run_numbers(run_number_string=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