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

Re #18666 Seperate generated and user run numbers for output

parent 1b43a679
No related merge requests found
Showing
with 119 additions and 87 deletions
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
import os import os
from isis_powder.routines import calibrate, focus from isis_powder.routines import calibrate, focus, common_enums
# This class provides common hooks for instruments to override # This class provides common hooks for instruments to override
...@@ -47,16 +47,15 @@ class AbstractInst(object): ...@@ -47,16 +47,15 @@ class AbstractInst(object):
return calibrate.create_van(instrument=self, van=vanadium_runs, empty=empty_runs, return calibrate.create_van(instrument=self, van=vanadium_runs, empty=empty_runs,
absorb=do_absorb_corrections, gen_absorb=gen_absorb_correction) absorb=do_absorb_corrections, gen_absorb=gen_absorb_correction)
def _focus(self, run_number, input_batching, do_van_normalisation): def _focus(self, run_number_string, do_van_normalisation):
""" """
Focuses the user specified run - should be called by the concrete instrument Focuses the user specified run - should be called by the concrete instrument
:param run_number: The run number(s) to be processed :param run_number_string: The run number(s) to be processed
:param input_batching: How to process the runs specified if a range. E.g. Individual/Batched. See common enums.
:param do_van_normalisation: True to divide by the vanadium run, false to not. :param do_van_normalisation: True to divide by the vanadium run, false to not.
:return: :return:
""" """
return focus.focus(run_number=run_number, input_batching=input_batching, return focus.focus(run_number_string=run_number_string, perform_vanadium_norm=do_van_normalisation,
perform_vanadium_norm=do_van_normalisation, instrument=self) instrument=self)
# Mandatory overrides # Mandatory overrides
...@@ -160,6 +159,14 @@ class AbstractInst(object): ...@@ -160,6 +159,14 @@ class AbstractInst(object):
# automatic calibration # automatic calibration
raise NotImplementedError("Automatic vanadium corrections have not been implemented for this instrument.") raise NotImplementedError("Automatic vanadium corrections have not been implemented for this instrument.")
def _get_input_batching_mode(self):
"""
Returns the user specified input batching (e.g. summed or individual processing). This is set to summed
by default for instruments who do not with to specify it
:return: The current input batching type from the InputBatchingEnum
"""
return common_enums.InputBatchingEnum.Summed
def _get_monitor_spectra_index(self, run_number): def _get_monitor_spectra_index(self, run_number):
""" """
Returns the spectra number a monitor is located at Returns the spectra number a monitor is located at
...@@ -196,7 +203,7 @@ class AbstractInst(object): ...@@ -196,7 +203,7 @@ class AbstractInst(object):
:return: A dictionary containing the various output paths and generated output name :return: A dictionary containing the various output paths and generated output name
""" """
output_directory = os.path.join(self._output_dir, run_details.label, self._user_name) output_directory = os.path.join(self._output_dir, run_details.label, self._user_name)
file_name = str(self._generate_output_file_name(run_number_string=run_details.run_number)) file_name = str(self._generate_output_file_name(run_number_string=run_details.user_input_run_number))
nxs_file = os.path.join(output_directory, (file_name + ".nxs")) nxs_file = os.path.join(output_directory, (file_name + ".nxs"))
gss_file = os.path.join(output_directory, (file_name + ".gsas")) gss_file = os.path.join(output_directory, (file_name + ".gsas"))
tof_xye_file = os.path.join(output_directory, (file_name + "_tof_xye.dat")) tof_xye_file = os.path.join(output_directory, (file_name + "_tof_xye.dat"))
......
...@@ -27,7 +27,7 @@ class Pearl(AbstractInst): ...@@ -27,7 +27,7 @@ class Pearl(AbstractInst):
def focus(self, **kwargs): def focus(self, **kwargs):
self._switch_long_mode_inst_settings(kwargs.get("long_mode")) self._switch_long_mode_inst_settings(kwargs.get("long_mode"))
self._inst_settings.update_attributes(kwargs=kwargs) self._inst_settings.update_attributes(kwargs=kwargs)
return self._focus(run_number=self._inst_settings.run_number, input_batching=InputBatchingEnum.Summed, return self._focus(run_number_string=self._inst_settings.run_number,
do_van_normalisation=self._inst_settings.van_norm) do_van_normalisation=self._inst_settings.van_norm)
def create_vanadium(self, **kwargs): def create_vanadium(self, **kwargs):
...@@ -53,14 +53,12 @@ class Pearl(AbstractInst): ...@@ -53,14 +53,12 @@ class Pearl(AbstractInst):
# Params # # Params #
def _get_run_details(self, run_number_string): def _get_run_details(self, run_number_string):
input_run_number_list = common.generate_run_numbers(run_number_string=run_number_string) if self._cached_run_details_number == run_number_string:
first_run = input_run_number_list[0]
if self._cached_run_details_number == first_run:
return self._cached_run_details return self._cached_run_details
run_details = pearl_algs.get_run_details(run_number_string=run_number_string, inst_settings=self._inst_settings) run_details = pearl_algs.get_run_details(run_number_string=run_number_string, inst_settings=self._inst_settings)
self._cached_run_details_number = first_run self._cached_run_details_number = run_number_string
self._cached_run_details = run_details self._cached_run_details = run_details
return run_details return run_details
...@@ -102,7 +100,8 @@ class Pearl(AbstractInst): ...@@ -102,7 +100,8 @@ class Pearl(AbstractInst):
pearl_output.generate_and_save_focus_output(self, processed_spectra=processed_spectra, pearl_output.generate_and_save_focus_output(self, processed_spectra=processed_spectra,
run_details=run_details, focus_mode=output_mode, run_details=run_details, focus_mode=output_mode,
perform_attenuation=self._inst_settings.perform_atten) perform_attenuation=self._inst_settings.perform_atten)
group_name = "PEARL" + str(run_details.run_number) + '_' + self._inst_settings.tt_mode + "-Results-D-Grp" group_name = "PEARL" + str(run_details.user_input_run_number)
group_name += '_' + self._inst_settings.tt_mode + "-Results-D-Grp"
grouped_d_spacing = mantid.GroupWorkspaces(InputWorkspaces=output_spectra, OutputWorkspace=group_name) grouped_d_spacing = mantid.GroupWorkspaces(InputWorkspaces=output_spectra, OutputWorkspace=group_name)
return grouped_d_spacing return grouped_d_spacing
......
...@@ -70,7 +70,12 @@ def generate_vanadium_absorb_corrections(van_ws): ...@@ -70,7 +70,12 @@ def generate_vanadium_absorb_corrections(van_ws):
def get_run_details(run_number_string, inst_settings): def get_run_details(run_number_string, inst_settings):
mapping_dict = yaml_parser.get_run_dictionary(run_number=run_number_string, file_path=inst_settings.cal_map_path) if isinstance(run_number_string, str) and not run_number_string.isdigit():
run_number_list = common.generate_run_numbers(run_number_string=run_number_string)
first_run_number = run_number_list[0]
else:
first_run_number = run_number_string
mapping_dict = yaml_parser.get_run_dictionary(run_number_string=first_run_number, file_path=inst_settings.cal_map_path)
calibration_file_name = mapping_dict["calibration_file"] calibration_file_name = mapping_dict["calibration_file"]
empty_run_numbers = mapping_dict["empty_run_numbers"] empty_run_numbers = mapping_dict["empty_run_numbers"]
...@@ -95,7 +100,8 @@ def get_run_details(run_number_string, inst_settings): ...@@ -95,7 +100,8 @@ def get_run_details(run_number_string, inst_settings):
splined_vanadium_path = os.path.join(cycle_calibration_dir, splined_vanadium_name) splined_vanadium_path = os.path.join(cycle_calibration_dir, splined_vanadium_name)
run_details = RunDetails(run_number=run_number_string) run_details = RunDetails(run_number=first_run_number)
run_details.user_input_run_number = run_number_string
run_details.calibration_file_path = calibration_file_path run_details.calibration_file_path = calibration_file_path
run_details.grouping_file_path = grouping_file_path run_details.grouping_file_path = grouping_file_path
run_details.empty_runs = empty_run_numbers run_details.empty_runs = empty_run_numbers
......
...@@ -24,12 +24,12 @@ def generate_and_save_focus_output(instrument, processed_spectra, run_details, p ...@@ -24,12 +24,12 @@ def generate_and_save_focus_output(instrument, processed_spectra, run_details, p
return processed_nexus_files return processed_nexus_files
def _attenuate_workspace(instrument, output_file_paths, ws_to_attenuate): def _attenuate_workspace(instrument, output_file_paths, attenuated_ws):
# Clone a workspace which is not attenuated # Clone a workspace which is not attenuated
no_att = output_file_paths["output_name"] + "_noatten" no_att = output_file_paths["output_name"] + "_noatten"
mantid.CloneWorkspace(InputWorkspace=ws_to_attenuate, OutputWorkspace=no_att) mantid.CloneWorkspace(InputWorkspace=attenuated_ws, OutputWorkspace=no_att)
ws_to_attenuate = instrument._attenuate_workspace(ws_to_attenuate) attenuated_ws = instrument._attenuate_workspace(attenuated_ws)
return ws_to_attenuate return attenuated_ws
def _focus_mode_mods(output_file_paths, calibrated_spectra): def _focus_mode_mods(output_file_paths, calibrated_spectra):
......
...@@ -29,7 +29,7 @@ class Polaris(AbstractInst): ...@@ -29,7 +29,7 @@ class Polaris(AbstractInst):
def focus(self, **kwargs): def focus(self, **kwargs):
self._inst_settings.update_attributes(kwargs=kwargs) self._inst_settings.update_attributes(kwargs=kwargs)
return self._focus(run_number=self._inst_settings.run_number, input_batching=self._inst_settings.input_mode, return self._focus(run_number_string=self._inst_settings.run_number,
do_van_normalisation=self._inst_settings.do_van_normalisation) do_van_normalisation=self._inst_settings.do_van_normalisation)
def create_vanadium(self, **kwargs): def create_vanadium(self, **kwargs):
...@@ -42,19 +42,31 @@ class Polaris(AbstractInst): ...@@ -42,19 +42,31 @@ class Polaris(AbstractInst):
do_absorb_corrections=self._inst_settings.do_absorb_corrections, do_absorb_corrections=self._inst_settings.do_absorb_corrections,
gen_absorb_correction=None) # TODO POLARIS doesn't need this flag to gen abs. corrections does PEARL? gen_absorb_correction=None) # TODO POLARIS doesn't need this flag to gen abs. corrections does PEARL?
def _get_run_details(self, run_number_string): # Overrides
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
run_details = polaris_algs.get_run_details(run_number=first_run, inst_settings=self._inst_settings) def _apply_absorb_corrections(self, run_details, van_ws, gen_absorb=False):
return polaris_algs.calculate_absorb_corrections(ws_to_correct=van_ws,
multiple_scattering=self._inst_settings.multiple_scattering)
# Hold obj in case same run range is requested @staticmethod
self._run_details_last_run_number = first_run def _can_auto_gen_vanadium_cal():
self._run_details_cached_obj = run_details return True
return run_details def _crop_banks_to_user_tof(self, focused_banks):
return common.crop_banks_in_tof(focused_banks, self._inst_settings.tof_cropping_values)
def _crop_raw_to_expected_tof_range(self, ws_to_crop):
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_van_to_expected_tof_range(self, van_ws_to_crop):
cropped_ws = common.crop_banks_in_tof(bank_list=van_ws_to_crop,
crop_values_list=self._inst_settings.van_crop_values)
return cropped_ws
def _generate_auto_vanadium_calibration(self, run_details):
self.create_vanadium(run_in_range=run_details.run_number)
@staticmethod @staticmethod
def _generate_input_file_name(run_number): def _generate_input_file_name(run_number):
...@@ -70,15 +82,34 @@ class Polaris(AbstractInst): ...@@ -70,15 +82,34 @@ class Polaris(AbstractInst):
return updated_list return updated_list
else: else:
# Select between old and new prefix # Select between old and new prefix
prefix = polaris_new_name if int(run_number) >= first_run_new_name else polaris_old_name # Test if it can be converted to an int or if we need to ask Mantid to do it for us
if isinstance(run_number, str) and not run_number.isdigit():
# Convert using Mantid and take the first element which is most likely to be the lowest digit
use_new_name = True if int(common.generate_run_numbers(run_number)[0]) >= first_run_new_name else False
else:
use_new_name = True if int(run_number) >= first_run_new_name else False
prefix = polaris_new_name if use_new_name else polaris_old_name
return prefix + str(run_number) return prefix + str(run_number)
def _generate_output_file_name(self, run_number_string): def _generate_output_file_name(self, run_number_string):
return self._generate_input_file_name(run_number=run_number_string) return self._generate_input_file_name(run_number=run_number_string)
@staticmethod def _get_input_batching_mode(self):
def _can_auto_gen_vanadium_cal(): return self._inst_settings.input_mode
return True
def _get_run_details(self, run_number_string):
if self._run_details_last_run_number == run_number_string:
return self._run_details_cached_obj
run_details = polaris_algs.get_run_details(run_number_string=run_number_string,
inst_settings=self._inst_settings)
# Hold obj in case same run range is requested
self._run_details_last_run_number = run_number_string
self._run_details_cached_obj = run_details
return run_details
def _normalise_ws_current(self, ws_to_correct, run_details=None): def _normalise_ws_current(self, ws_to_correct, run_details=None):
normalised_ws = mantid.NormaliseByCurrent(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct) normalised_ws = mantid.NormaliseByCurrent(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct)
...@@ -93,32 +124,13 @@ class Polaris(AbstractInst): ...@@ -93,32 +124,13 @@ class Polaris(AbstractInst):
mask_path=masking_file_path) mask_path=masking_file_path)
return output return output
def _apply_absorb_corrections(self, run_details, van_ws, gen_absorb=False):
return polaris_algs.calculate_absorb_corrections(ws_to_correct=van_ws,
multiple_scattering=self._inst_settings.multiple_scattering)
def _output_focused_ws(self, processed_spectra, run_details, output_mode=None): def _output_focused_ws(self, processed_spectra, run_details, output_mode=None):
d_spacing_group, tof_group = polaris_algs.split_into_tof_d_spacing_groups(run_details=run_details, d_spacing_group, tof_group = polaris_algs.split_into_tof_d_spacing_groups(run_details=run_details,
processed_spectra=processed_spectra) processed_spectra=processed_spectra)
output_paths = self._generate_out_file_paths(run_details=run_details) output_paths = self._generate_out_file_paths(run_details=run_details)
polaris_output.save_polaris_focused_data(d_spacing_group=d_spacing_group, tof_group=tof_group, polaris_output.save_polaris_focused_data(d_spacing_group=d_spacing_group, tof_group=tof_group,
output_paths=output_paths, run_number=run_details.run_number) output_paths=output_paths,
run_number_string=run_details.user_input_run_number)
return d_spacing_group return d_spacing_group
def _crop_raw_to_expected_tof_range(self, ws_to_crop):
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_van_to_expected_tof_range(self, van_ws_to_crop):
cropped_ws = common.crop_banks_in_tof(bank_list=van_ws_to_crop,
crop_values_list=self._inst_settings.van_crop_values)
return cropped_ws
def _crop_banks_to_user_tof(self, focused_banks):
return common.crop_banks_in_tof(focused_banks, self._inst_settings.tof_cropping_values)
def _generate_auto_vanadium_calibration(self, run_details):
self.create_calibration_vanadium(run_in_range=run_details.run_number)
...@@ -25,8 +25,12 @@ def calculate_absorb_corrections(ws_to_correct, multiple_scattering): ...@@ -25,8 +25,12 @@ def calculate_absorb_corrections(ws_to_correct, multiple_scattering):
return ws_to_correct return ws_to_correct
def get_run_details(run_number, inst_settings): def get_run_details(run_number_string, inst_settings):
yaml_dict = yaml_parser.get_run_dictionary(run_number=run_number, file_path=inst_settings.cal_mapping_file) run_number = common.generate_run_numbers(run_number_string=run_number_string)
if isinstance(run_number, list):
# Only take first run number
run_number = run_number[0]
yaml_dict = yaml_parser.get_run_dictionary(run_number_string=run_number, file_path=inst_settings.cal_mapping_file)
if inst_settings.chopper_on: if inst_settings.chopper_on:
chopper_config = yaml_dict["chopper_on"] chopper_config = yaml_dict["chopper_on"]
...@@ -47,6 +51,7 @@ def get_run_details(run_number, inst_settings): ...@@ -47,6 +51,7 @@ def get_run_details(run_number, inst_settings):
splined_vanadium = os.path.join(in_calib_dir, splined_vanadium_name) splined_vanadium = os.path.join(in_calib_dir, splined_vanadium_name)
run_details = RunDetails(run_number=run_number) run_details = RunDetails(run_number=run_number)
run_details.user_input_run_number = run_number_string
run_details.empty_runs = empty_runs run_details.empty_runs = empty_runs
run_details.vanadium_run_numbers = vanadium_runs run_details.vanadium_run_numbers = vanadium_runs
run_details.label = label run_details.label = label
...@@ -59,14 +64,12 @@ def get_run_details(run_number, inst_settings): ...@@ -59,14 +64,12 @@ def get_run_details(run_number, inst_settings):
def split_into_tof_d_spacing_groups(run_details, processed_spectra): def split_into_tof_d_spacing_groups(run_details, processed_spectra):
name_index = 1
d_spacing_output = [] d_spacing_output = []
tof_output = [] tof_output = []
run_number = str(run_details.run_number) run_number = str(run_details.user_input_run_number)
for ws in processed_spectra: for name_index, ws in enumerate(processed_spectra):
d_spacing_out_name = run_number + "-ResultD-" + str(name_index) d_spacing_out_name = run_number + "-ResultD-" + str(name_index + 1)
tof_out_name = run_number + "-ResultTOF-" + str(name_index) tof_out_name = run_number + "-ResultTOF-" + str(name_index + 1)
name_index += 1
d_spacing_output.append(mantid.ConvertUnits(InputWorkspace=ws, OutputWorkspace=d_spacing_out_name, d_spacing_output.append(mantid.ConvertUnits(InputWorkspace=ws, OutputWorkspace=d_spacing_out_name,
Target="dSpacing")) Target="dSpacing"))
......
...@@ -4,7 +4,7 @@ import mantid.simpleapi as mantid ...@@ -4,7 +4,7 @@ import mantid.simpleapi as mantid
import os import os
def save_polaris_focused_data(d_spacing_group, tof_group, output_paths, run_number): def save_polaris_focused_data(d_spacing_group, tof_group, output_paths, run_number_string):
mantid.SaveGSS(InputWorkspace=tof_group, Filename=output_paths["gss_filename"], SplitFiles=False, Append=False) mantid.SaveGSS(InputWorkspace=tof_group, Filename=output_paths["gss_filename"], SplitFiles=False, Append=False)
mantid.SaveNexusProcessed(InputWorkspace=tof_group, Filename=output_paths["nxs_filename"], Append=False) mantid.SaveNexusProcessed(InputWorkspace=tof_group, Filename=output_paths["nxs_filename"], Append=False)
...@@ -13,9 +13,9 @@ def save_polaris_focused_data(d_spacing_group, tof_group, output_paths, run_numb ...@@ -13,9 +13,9 @@ def save_polaris_focused_data(d_spacing_group, tof_group, output_paths, run_numb
if not os.path.exists(dat_file_destination): if not os.path.exists(dat_file_destination):
os.makedirs(dat_file_destination) os.makedirs(dat_file_destination)
_save_xye(ws_group=d_spacing_group, ws_units="d", run_number=run_number, _save_xye(ws_group=d_spacing_group, ws_units="d", run_number=run_number_string,
output_folder=dat_file_destination) output_folder=dat_file_destination)
_save_xye(ws_group=tof_group, ws_units="TOF", run_number=run_number, _save_xye(ws_group=tof_group, ws_units="TOF", run_number=run_number_string,
output_folder=dat_file_destination) output_folder=dat_file_destination)
......
...@@ -9,6 +9,7 @@ class RunDetails(object): ...@@ -9,6 +9,7 @@ class RunDetails(object):
def __init__(self, run_number): def __init__(self, run_number):
# Essential attribute # Essential attribute
self.run_number = run_number self.run_number = run_number
self.user_input_run_number = None
self.empty_runs = None self.empty_runs = None
self.label = None self.label = None
......
...@@ -84,7 +84,10 @@ def get_monitor_ws(ws_to_process, run_number_string, instrument): ...@@ -84,7 +84,10 @@ def get_monitor_ws(ws_to_process, run_number_string, instrument):
return load_monitor_ws return load_monitor_ws
def load_current_normalised_ws_list(run_number_string, instrument, input_batching): def load_current_normalised_ws_list(run_number_string, instrument, input_batching=None):
if not input_batching:
input_batching = instrument._get_input_batching_mode()
run_information = instrument._get_run_details(run_number_string=run_number_string) run_information = instrument._get_run_details(run_number_string=run_number_string)
raw_ws_list = _load_raw_files(run_number_string=run_number_string, instrument=instrument) raw_ws_list = _load_raw_files(run_number_string=run_number_string, instrument=instrument)
......
...@@ -8,12 +8,12 @@ import os ...@@ -8,12 +8,12 @@ import os
import warnings import warnings
def focus(run_number, instrument, input_batching, perform_vanadium_norm=True): def focus(run_number_string, instrument, perform_vanadium_norm=True):
input_batching = instrument._get_input_batching_mode()
if input_batching.lower() == InputBatchingEnum.Individual.lower(): if input_batching.lower() == InputBatchingEnum.Individual.lower():
return _individual_run_focusing(input_batching, instrument, perform_vanadium_norm, return _individual_run_focusing(instrument, perform_vanadium_norm, run_number_string)
run_number)
else: else:
return _batched_run_focusing(input_batching, instrument, perform_vanadium_norm, run_number) return _batched_run_focusing(instrument, perform_vanadium_norm, run_number_string)
def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm): def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm):
...@@ -24,13 +24,14 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm): ...@@ -24,13 +24,14 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm):
# Subtract and crop to largest acceptable TOF range # Subtract and crop to largest acceptable TOF range
input_workspace = common.subtract_sample_empty(ws_to_correct=ws, instrument=instrument, input_workspace = common.subtract_sample_empty(ws_to_correct=ws, instrument=instrument,
empty_sample_ws_string=run_details.empty_runs) empty_sample_ws_string=run_details.empty_runs)
input_workspace = instrument._crop_raw_to_expected_tof_range(ws_to_crop=input_workspace) input_workspace = instrument._crop_raw_to_expected_tof_range(ws_to_crop=input_workspace)
# Align / Focus # Align / Focus
input_workspace = mantid.AlignDetectors(InputWorkspace=input_workspace, aligned_ws = mantid.AlignDetectors(InputWorkspace=input_workspace,
CalibrationFile=run_details.calibration_file_path) CalibrationFile=run_details.calibration_file_path)
focused_ws = mantid.DiffractionFocussing(InputWorkspace=input_workspace, focused_ws = mantid.DiffractionFocussing(InputWorkspace=aligned_ws,
GroupingFileName=run_details.grouping_file_path) GroupingFileName=run_details.grouping_file_path)
calibrated_spectra = _apply_vanadium_corrections(instrument=instrument, run_number=run_number, calibrated_spectra = _apply_vanadium_corrections(instrument=instrument, run_number=run_number,
...@@ -42,6 +43,7 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm): ...@@ -42,6 +43,7 @@ def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm):
# Tidy workspaces from Mantid # Tidy workspaces from Mantid
common.remove_intermediate_workspace(input_workspace) common.remove_intermediate_workspace(input_workspace)
common.remove_intermediate_workspace(aligned_ws)
common.remove_intermediate_workspace(focused_ws) common.remove_intermediate_workspace(focused_ws)
common.remove_intermediate_workspace(calibrated_spectra) common.remove_intermediate_workspace(calibrated_spectra)
...@@ -62,12 +64,12 @@ def _apply_vanadium_corrections(instrument, run_number, input_workspace, perform ...@@ -62,12 +64,12 @@ def _apply_vanadium_corrections(instrument, run_number, input_workspace, perform
return processed_spectra return processed_spectra
def _batched_run_focusing(input_batching, instrument, perform_vanadium_norm, run_number): def _batched_run_focusing(instrument, perform_vanadium_norm, run_number_string):
read_ws_list = common.load_current_normalised_ws_list(run_number_string=run_number, read_ws_list = common.load_current_normalised_ws_list(run_number_string=run_number_string,
input_batching=input_batching, instrument=instrument) instrument=instrument)
output = None output = None
for ws in read_ws_list: for ws in read_ws_list:
output = _focus_one_ws(ws=ws, run_number=run_number, instrument=instrument, output = _focus_one_ws(ws=ws, run_number=run_number_string, instrument=instrument,
perform_vanadium_norm=perform_vanadium_norm) perform_vanadium_norm=perform_vanadium_norm)
return output return output
...@@ -82,13 +84,12 @@ def _divide_by_vanadium_splines(spectra_list, spline_file_path): ...@@ -82,13 +84,12 @@ def _divide_by_vanadium_splines(spectra_list, spline_file_path):
return output_list return output_list
def _individual_run_focusing(input_batching, instrument, perform_vanadium_norm, run_number): def _individual_run_focusing(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)
output = None output = None
for run in run_numbers: for run in run_numbers:
ws = common.load_current_normalised_ws_list(run_number_string=run, instrument=instrument, ws = common.load_current_normalised_ws_list(run_number_string=run, instrument=instrument)
input_batching=input_batching)
output = _focus_one_ws(ws=ws[0], run_number=run, instrument=instrument, output = _focus_one_ws(ws=ws[0], run_number=run, instrument=instrument,
perform_vanadium_norm=perform_vanadium_norm) perform_vanadium_norm=perform_vanadium_norm)
return output return output
......
...@@ -6,17 +6,17 @@ from isis_powder.routines import common as common ...@@ -6,17 +6,17 @@ from isis_powder.routines import common as common
from isis_powder.routines import yaml_sanity from isis_powder.routines import yaml_sanity
def get_run_dictionary(run_number, file_path): def get_run_dictionary(run_number_string, file_path):
if isinstance(run_number, str): if isinstance(run_number_string, str):
run_number_list = common.generate_run_numbers(run_number_string=run_number) run_number_list = common.generate_run_numbers(run_number_string=run_number_string)
run_number = run_number_list[0] run_number_string = run_number_list[0]
config_file = open_yaml_file_as_dictionary(file_path) config_file = open_yaml_file_as_dictionary(file_path)
yaml_sanity.calibration_file_sanity_check(config_file) yaml_sanity.calibration_file_sanity_check(config_file)
run_key = _find_dictionary_key(dict_to_search=config_file, run_number=run_number) run_key = _find_dictionary_key(dict_to_search=config_file, run_number=run_number_string)
if not run_key: if not run_key:
raise ValueError("Run number " + str(run_number) + " not recognised in calibration mapping") raise ValueError("Run number " + str(run_number_string) + " not recognised in calibration mapping")
return config_file[run_key] return config_file[run_key]
......
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