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

Re #17949 Moved generating calib from taking cycle to run no.

parent 279fc5e6
No related branches found
No related tags found
No related merge requests found
a21f83421257de6da7fb7c2dd66d3eef
...@@ -24,7 +24,7 @@ class AbstractInst(object): ...@@ -24,7 +24,7 @@ class AbstractInst(object):
self._calibration_dir = calibration_dir self._calibration_dir = calibration_dir
self._raw_data_dir = raw_data_dir self._raw_data_dir = raw_data_dir
self._output_dir = output_dir self._output_dir = output_dir
self._default_input_ext = _append_dot_to_ext(default_input_ext) self._default_input_ext = _prefix_dot_to_ext(default_input_ext)
self._focus_mode = None self._focus_mode = None
@property @property
...@@ -45,7 +45,7 @@ class AbstractInst(object): ...@@ -45,7 +45,7 @@ class AbstractInst(object):
@default_input_ext.setter @default_input_ext.setter
def default_input_ext(self, new_ext): def default_input_ext(self, new_ext):
self._default_input_ext = _append_dot_to_ext(new_ext) self._default_input_ext = _prefix_dot_to_ext(new_ext)
@property @property
def focus_mode(self): def focus_mode(self):
...@@ -162,13 +162,7 @@ class AbstractInst(object): ...@@ -162,13 +162,7 @@ class AbstractInst(object):
# Instrument specific methods # Instrument specific methods
@abstractmethod @abstractmethod
def _get_calibration_full_paths(self, cycle): def _get_calibration_full_paths(self, run_number):
"""
Gets the current calibration file names for this cycle
@param cycle: The cycle string to lookup for this run
@return: A dictionary the containing the full paths as values for the following keys:
"calibration", "grouping", "vanadium_absorption", "vanadium"
"""
pass pass
@staticmethod @staticmethod
...@@ -179,7 +173,7 @@ class AbstractInst(object): ...@@ -179,7 +173,7 @@ class AbstractInst(object):
@param run_number: The run number to turn into a filename @param run_number: The run number to turn into a filename
@return: The filename of the file - Without the path or extension @return: The filename of the file - Without the path or extension
""" """
pass
@staticmethod @staticmethod
@abstractmethod @abstractmethod
...@@ -293,7 +287,7 @@ class AbstractInst(object): ...@@ -293,7 +287,7 @@ class AbstractInst(object):
# These should only be called by the abstract instrument class # These should only be called by the abstract instrument class
def _append_dot_to_ext(ext): def _prefix_dot_to_ext(ext):
if not ext.startswith('.'): if not ext.startswith('.'):
return '.' + ext return '.' + ext
else: else:
......
...@@ -7,8 +7,6 @@ import isis_powder.common as common ...@@ -7,8 +7,6 @@ import isis_powder.common as common
def create_van(instrument, van, empty, output_van_file_name, num_of_splines, absorb, gen_absorb): def create_van(instrument, van, empty, output_van_file_name, num_of_splines, absorb, gen_absorb):
cycle_information = instrument._get_cycle_information(van)
input_van_ws = common._load_current_normalised_ws(number=van, instrument=instrument) input_van_ws = common._load_current_normalised_ws(number=van, instrument=instrument)
input_empty_ws = common._load_current_normalised_ws(number=empty, instrument=instrument) input_empty_ws = common._load_current_normalised_ws(number=empty, instrument=instrument)
...@@ -17,7 +15,7 @@ def create_van(instrument, van, empty, output_van_file_name, num_of_splines, abs ...@@ -17,7 +15,7 @@ def create_van(instrument, van, empty, output_van_file_name, num_of_splines, abs
common.remove_intermediate_workspace(input_empty_ws) common.remove_intermediate_workspace(input_empty_ws)
common.remove_intermediate_workspace(input_van_ws) common.remove_intermediate_workspace(input_van_ws)
calibration_full_paths = instrument._get_calibration_full_paths(cycle=cycle_information["cycle"]) calibration_full_paths = instrument._get_calibration_full_paths(run_number=van)
# Absorb was here # Absorb was here
...@@ -43,6 +41,7 @@ def create_van(instrument, van, empty, output_van_file_name, num_of_splines, abs ...@@ -43,6 +41,7 @@ def create_van(instrument, van, empty, output_van_file_name, num_of_splines, abs
common.remove_intermediate_workspace(corrected_van_ws) common.remove_intermediate_workspace(corrected_van_ws)
cycle_information = instrument._get_cycle_information(run_number=van)
splined_ws_list = instrument._spline_background(focused_van_file, num_of_splines, splined_ws_list = instrument._spline_background(focused_van_file, num_of_splines,
cycle_information["instrument_version"]) cycle_information["instrument_version"])
......
...@@ -14,8 +14,7 @@ def _run_focus(instrument, run_number, perform_attenuation, perform_vanadium_nor ...@@ -14,8 +14,7 @@ def _run_focus(instrument, run_number, perform_attenuation, perform_vanadium_nor
read_ws = common._load_current_normalised_ws(number=run_number, instrument=instrument) read_ws = common._load_current_normalised_ws(number=run_number, instrument=instrument)
input_workspace = instrument._do_tof_rebinning_focus(read_ws) # Rebins for PEARL input_workspace = instrument._do_tof_rebinning_focus(read_ws) # Rebins for PEARL
cycle_information = instrument._get_cycle_information(run_number=run_number) calibration_file_paths = instrument._get_calibration_full_paths(run_number=run_number)
calibration_file_paths = instrument._get_calibration_full_paths(cycle=cycle_information["cycle"])
# Compensate for empty sample if specified # Compensate for empty sample if specified
input_workspace = instrument._subtract_sample_empty(input_workspace) input_workspace = instrument._subtract_sample_empty(input_workspace)
...@@ -57,9 +56,9 @@ def _run_focus(instrument, run_number, perform_attenuation, perform_vanadium_nor ...@@ -57,9 +56,9 @@ def _run_focus(instrument, run_number, perform_attenuation, perform_vanadium_nor
def _divide_sample_by_vanadium(instrument, run_number, input_workspace, perform_vanadium_norm): def _divide_sample_by_vanadium(instrument, run_number, input_workspace, perform_vanadium_norm):
processed_spectra = [] processed_spectra = []
cycle_information = instrument._get_cycle_information(run_number=run_number) input_file_paths = instrument._get_calibration_full_paths(run_number=run_number)
input_file_paths = instrument._get_calibration_full_paths(cycle=cycle_information["cycle"])
cycle_information = instrument._get_cycle_information(run_number=run_number)
alg_range, save_range = instrument._get_instrument_alg_save_ranges(cycle_information["instrument_version"]) alg_range, save_range = instrument._get_instrument_alg_save_ranges(cycle_information["instrument_version"])
for index in range(0, alg_range): for index in range(0, alg_range):
......
...@@ -21,7 +21,7 @@ class MockInstrument(AbstractInst): ...@@ -21,7 +21,7 @@ class MockInstrument(AbstractInst):
def _get_default_group_names(self): def _get_default_group_names(self):
return None return None
def _get_calibration_full_paths(self, cycle): def _get_calibration_full_paths(self, run_number):
# This is here to help remind people of the dict that is expected # This is here to help remind people of the dict that is expected
calibration_details = {"calibration": "cal", calibration_details = {"calibration": "cal",
"grouping": "group", "grouping": "group",
......
...@@ -63,10 +63,11 @@ class Pearl(AbstractInst): ...@@ -63,10 +63,11 @@ class Pearl(AbstractInst):
# Methods # # Methods #
def _get_calibration_full_paths(self, cycle): def _get_calibration_full_paths(self, run_number):
cycle_dict = self._get_cycle_information(run_number=run_number)
calibration_file, grouping_file, van_absorb, van_file =\ calibration_file, grouping_file, van_absorb, van_file =\
pearl_calib_factory.get_calibration_filename(cycle=cycle, tt_mode=self._tt_mode) pearl_calib_factory.get_calibration_filename(cycle=cycle_dict["cycle"], tt_mode=self._tt_mode)
calibration_dir = self.calibration_dir calibration_dir = self.calibration_dir
...@@ -86,7 +87,18 @@ class Pearl(AbstractInst): ...@@ -86,7 +87,18 @@ class Pearl(AbstractInst):
@staticmethod @staticmethod
def _get_cycle_information(run_number): def _get_cycle_information(run_number):
cycle, instrument_version = pearl_cycle_factory.get_cycle_dir(run_number) run_input = ""
if not run_number.isdigit():
# Only take first valid number as it is probably of the form 12345_12350
for character in run_number:
if character.isdigit():
run_input += character
else:
break
else:
run_input = run_number
cycle, instrument_version = pearl_cycle_factory.get_cycle_dir(run_input)
cycle_information = {'cycle': cycle, cycle_information = {'cycle': cycle,
'instrument_version': instrument_version} 'instrument_version': instrument_version}
......
...@@ -14,7 +14,7 @@ import isis_powder.common as common ...@@ -14,7 +14,7 @@ import isis_powder.common as common
class Polaris(AbstractInst): class Polaris(AbstractInst):
_lower_lambda_range = 0.25 _lower_lambda_range = 0.25
_upper_lambda_range = 2.50 # TODO populate this _upper_lambda_range = 2.50
_focus_crop_start = 2 # These are used when calculating binning range _focus_crop_start = 2 # These are used when calculating binning range
_focus_crop_end = 0.95 _focus_crop_end = 0.95
...@@ -43,10 +43,10 @@ class Polaris(AbstractInst): ...@@ -43,10 +43,10 @@ class Polaris(AbstractInst):
def _get_default_group_names(self): def _get_default_group_names(self):
return self._calibration_grouping_names return self._calibration_grouping_names
def _get_calibration_full_paths(self, cycle): def _get_calibration_full_paths(self, run_number):
# offset_file_name, grouping_file_name, vanadium_file_name = polaris_calib_factory.get_calibration_file(cycle) # offset_file_name, grouping_file_name, vanadium_file_name = polaris_calib_factory.get_calibration_file(cycle)
cycle_dict = self._get_cycle_information(run_number=run_number)
configuration = polaris_calib_parser.get_calibration_dict(cycle) configuration = polaris_calib_parser.get_calibration_dict(cycle_dict["cycle"])
calibration_dir = self.calibration_dir calibration_dir = self.calibration_dir
# Assume the raw vanadium is with other raw files # Assume the raw vanadium is with other raw files
...@@ -112,7 +112,6 @@ class Polaris(AbstractInst): ...@@ -112,7 +112,6 @@ class Polaris(AbstractInst):
return corrections_ws return corrections_ws
def _subtract_sample_empty(self, input_sample): def _subtract_sample_empty(self, input_sample):
# TODO move this to be generated by calibration factory so we don't have to use the full fname
if self._sample_empty is not None: if self._sample_empty is not None:
empty_sample_path = os.path.join(self.calibration_dir, self._sample_empty) empty_sample_path = os.path.join(self.calibration_dir, self._sample_empty)
empty_sample = mantid.Load(Filename=empty_sample_path) empty_sample = mantid.Load(Filename=empty_sample_path)
...@@ -350,4 +349,3 @@ def _create_d_spacing_tof_output(processed_spectra): ...@@ -350,4 +349,3 @@ def _create_d_spacing_tof_output(processed_spectra):
tof_group = mantid.GroupWorkspaces(InputWorkspaces=tof_output, OutputWorkspace=tof_group_name) tof_group = mantid.GroupWorkspaces(InputWorkspaces=tof_output, OutputWorkspace=tof_group_name)
return d_spacing_group, tof_group return d_spacing_group, tof_group
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