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

Re #18108 Tidied some hooks out of abstract_inst

parent d18b335c
No related branches found
No related tags found
No related merge requests found
......@@ -155,14 +155,7 @@ class AbstractInst(object):
def get_monitor_spectra_index(self, run_number):
return _empty_hook_return_empty_string()
def _old_api_PEARL_filename_is_full_path(self):
"""
Only used by PEARL to maintain compatibility with old routines code
@return: Whether the "filename" is actually a full path
"""
return False
def _spline_vanadium(self, focused_vanadium_ws, instrument_version=''):
def spline_vanadium_ws(self, focused_vanadium_ws, instrument_version=''):
"""
Splines the background in a way specific to the instrument
@param focused_vanadium_ws: The workspace to perform spline backgrounds on
......@@ -171,26 +164,22 @@ class AbstractInst(object):
"""
return _empty_hook_return_none()
def _skip_appending_cycle_to_raw_dir(self):
return True
# TODO set this to False if they just dump their raw files in one folder
def _do_tof_rebinning_focus(self, input_workspace):
def pearl_focus_tof_rebinning(self, input_workspace):
return input_workspace
def _process_focus_output(self, processed_spectra, run_details, attenuate=False):
def output_focused_ws(self, processed_spectra, run_details, attenuate=False):
return _empty_hook_return_none()
def apply_solid_angle_efficiency_corr(self, ws_to_correct, run_details):
return ws_to_correct
def _apply_van_calibration_tof_rebinning(self, vanadium_ws, tof_rebin_pass, return_units):
def pearl_van_calibration_tof_rebinning(self, vanadium_ws, tof_rebin_pass, return_units):
return vanadium_ws
def _generate_vanadium_absorb_corrections(self, calibration_full_paths, ws_to_match):
raise NotImplementedError("Not implemented for this instrument yet")
def _calibration_rebin_to_workspace(self, ws_to_rebin, ws_to_match):
def pearl_rebin_to_workspace(self, ws_to_rebin, ws_to_match):
return ws_to_rebin
def correct_sample_vanadium(self, focused_ws, index, vanadium_ws=None):
......@@ -199,9 +188,17 @@ class AbstractInst(object):
def calculate_focus_binning_params(self, sample):
return None
def _old_api_PEARL_setup_input_dirs(self, run_number):
def _old_api_pearl_setup_input_dirs(self, run_number):
return None
def _old_api_pearl_filename_is_full_path(self):
"""
Only used by PEARL to maintain compatibility with old routines code
@return: Whether the "filename" is actually a full path
"""
return False
# ----- Private Implementation ----- #
# These should only be called by the abstract instrument class
......
......@@ -43,9 +43,6 @@ class MockInstrument(AbstractInst):
"instrument_version": "test_v1"}
return cycle_information
def _skip_appending_cycle_to_raw_dir(self):
return self.generate_cycle_dir_flag
def test_set_raw_data_dir(self, new_dir):
# Used for testing to set a new raw_data_dir
self._raw_data_dir = new_dir
......@@ -141,28 +141,26 @@ class Pearl(AbstractInst):
def get_monitor_spectra_index(self, run_number):
return get_monitor_spectra(run_number=run_number, focus_mode=self._focus_mode)
def _skip_appending_cycle_to_raw_dir(self):
return self._disable_appending_cycle_to_raw_dir
def _spline_vanadium(self, focused_vanadium_ws, instrument_version=''):
def spline_vanadium_ws(self, focused_vanadium_ws, instrument_version=''):
# TODO move spline number into the class
return pearl_spline.spline_vanadium_for_focusing(focused_vanadium_ws=focused_vanadium_ws,
spline_number=self._spline_coeff,
instrument_version=instrument_version)
def _do_tof_rebinning_focus(self, input_workspace):
def pearl_focus_tof_rebinning(self, input_workspace):
input_workspace = mantid.Rebin(InputWorkspace=input_workspace, Params=self._focus_tof_binning)
return input_workspace
def _focus_processing(self, run_number, input_workspace, perform_vanadium_norm):
return self._perform_focus_loading(run_number, input_workspace, perform_vanadium_norm)
def _process_focus_output(self, processed_spectra, run_details, attenuate=False):
def output_focused_ws(self, processed_spectra, run_details, attenuate=False):
return pearl_output.generate_and_save_focus_output(self, processed_spectra=processed_spectra,
run_details=run_details, focus_mode=self._focus_mode,
perform_attenuation=attenuate)
def _apply_van_calibration_tof_rebinning(self, vanadium_ws, tof_rebin_pass, return_units):
def pearl_van_calibration_tof_rebinning(self, vanadium_ws, tof_rebin_pass, return_units):
tof_rebin_param_dict = self.get_create_van_tof_binning()
tof_rebin_param = tof_rebin_param_dict[str(tof_rebin_pass)]
......@@ -174,7 +172,7 @@ class Pearl(AbstractInst):
def _generate_vanadium_absorb_corrections(self, run_details, ws_to_match):
return pearl_algs.generate_vanadium_absorb_corrections(van_ws=ws_to_match)
def _calibration_rebin_to_workspace(self, ws_to_rebin, ws_to_match):
def pearl_rebin_to_workspace(self, ws_to_rebin, ws_to_match):
rebinned_ws = mantid.RebinToWorkspace(WorkspaceToRebin=ws_to_rebin, WorkspaceToMatch=ws_to_match)
common.remove_intermediate_workspace(ws_to_rebin)
ws_to_rebin = rebinned_ws
......
......@@ -60,10 +60,10 @@ class PearlRoutinesWrapper(Pearl):
def _old_api_set_full_paths(self, val):
self._old_api_uses_full_paths = val
def _old_api_PEARL_filename_is_full_path(self):
def _old_api_pearl_filename_is_full_path(self):
return self._old_api_uses_full_paths
def _old_api_PEARL_setup_input_dirs(self, run_number):
def _old_api_pearl_setup_input_dirs(self, run_number):
run_details = self.get_run_details(run_number=run_number)
generated_path = self._generate_raw_data_cycle_dir(run_cycle=run_details.label)
user_dirs = config['datasearch.directories']
......@@ -75,7 +75,7 @@ class PearlRoutinesWrapper(Pearl):
return self._focus_tof_binning
def _generate_raw_data_cycle_dir(self, run_cycle):
if self._skip_appending_cycle_to_raw_dir():
if self._disable_appending_cycle_to_raw_dir:
return self.raw_data_dir
str_run_cycle = str(run_cycle)
......
......@@ -104,7 +104,7 @@ class Polaris(AbstractInst):
return spectra_name
def _spline_vanadium(self, focused_vanadium_ws, instrument_version=''):
def spline_vanadium_ws(self, focused_vanadium_ws, instrument_version=''):
extracted_spectra = common.extract_bank_spectra(focused_vanadium_ws, self._number_of_banks)
mode = "spline"
......@@ -126,7 +126,7 @@ class Polaris(AbstractInst):
num_of_banks=self._number_of_banks)
return calculated_binning_params
def _process_focus_output(self, processed_spectra, run_details, attenuate=False):
def output_focused_ws(self, processed_spectra, run_details, attenuate=False):
d_spacing_group, tof_group = polaris_algs.split_into_tof_d_spacing_groups(processed_spectra)
output_paths = self._generate_out_file_paths(run_details=run_details)
......
......@@ -17,8 +17,8 @@ def create_van(instrument, van, empty, output_van_file_name, absorb, gen_absorb)
run_details = instrument.get_run_details(run_number=van)
corrected_van_ws = instrument. _apply_van_calibration_tof_rebinning(vanadium_ws=corrected_van_ws,
tof_rebin_pass=1, return_units="TOF")
corrected_van_ws = instrument. pearl_van_calibration_tof_rebinning(vanadium_ws=corrected_van_ws,
tof_rebin_pass=1, return_units="TOF")
corrected_van_ws = mantid.AlignDetectors(InputWorkspace=corrected_van_ws,
CalibrationFile=run_details.calibration)
......@@ -34,14 +34,14 @@ def create_van(instrument, van, empty, output_van_file_name, absorb, gen_absorb)
GroupingFileName=run_details.grouping)
# Optional
focused_van_file = instrument. _apply_van_calibration_tof_rebinning(vanadium_ws=focused_van_file,
tof_rebin_pass=2, return_units="dSpacing")
focused_van_file = instrument. pearl_van_calibration_tof_rebinning(vanadium_ws=focused_van_file,
tof_rebin_pass=2, return_units="dSpacing")
common.remove_intermediate_workspace(corrected_van_ws)
splined_ws_list = instrument._spline_vanadium(focused_van_file, run_details.instrument_version)
splined_ws_list = instrument.spline_vanadium_ws(focused_van_file, run_details.instrument_version)
# Figure out who will provide the path name
if instrument._old_api_PEARL_filename_is_full_path():
if instrument._old_api_pearl_filename_is_full_path():
out_van_file_path = output_van_file_name
elif output_van_file_name:
# The user has manually specified the output file
......@@ -70,7 +70,7 @@ def _apply_absorb_corrections(instrument, run_details, corrected_van_ws, gen_abs
absorb_ws = mantid.LoadNexus(Filename=run_details.vanadium_absorption)
# PEARL rebins whilst POLARIS does not as some of the older absorption files have different number of bins
corrected_van_ws = instrument._calibration_rebin_to_workspace(ws_to_rebin=corrected_van_ws, ws_to_match=absorb_ws)
corrected_van_ws = instrument.pearl_rebin_to_workspace(ws_to_rebin=corrected_van_ws, ws_to_match=absorb_ws)
corrected_van_ws = mantid.Divide(LHSWorkspace=corrected_van_ws, RHSWorkspace=absorb_ws)
corrected_van_ws = mantid.ConvertUnits(InputWorkspace=corrected_van_ws, Target="dSpacing")
common.remove_intermediate_workspace(absorb_ws)
......
......@@ -75,7 +75,7 @@ def _create_blank_cal_file(calibration_runs, out_grouping_file_name, instrument,
def _load_raw_files(run_number_string, instrument):
run_number_list = generate_run_numbers(run_number_string=run_number_string)
instrument._old_api_PEARL_setup_input_dirs(run_number=run_number_list[0])
instrument._old_api_pearl_setup_input_dirs(run_number=run_number_list[0])
load_raw_ws = _load_sum_file_range(run_number_list, instrument)
return load_raw_ws
......
......@@ -10,7 +10,7 @@ def focus(run_number, instrument, perform_attenuation=True, perform_vanadium_nor
# Read
read_ws = common.load_current_normalised_ws(run_number_string=run_number, instrument=instrument)
input_workspace = instrument._do_tof_rebinning_focus(read_ws) # Rebins for PEARL
input_workspace = instrument.pearl_focus_tof_rebinning(read_ws) # Rebins for PEARL
run_details = instrument.get_run_details(run_number=run_number)
# Check the necessary splined vanadium file has been created
......@@ -43,8 +43,8 @@ def focus(run_number, instrument, perform_attenuation=True, perform_vanadium_nor
_apply_binning_to_spectra(spectra_list=calibrated_spectra, binning_list=rebinning_params)
# Output
processed_nexus_files = instrument._process_focus_output(calibrated_spectra, run_details=run_details,
attenuate=perform_attenuation)
processed_nexus_files = instrument.output_focused_ws(calibrated_spectra, run_details=run_details,
attenuate=perform_attenuation)
# Tidy
common.remove_intermediate_workspace(read_ws)
......
......@@ -57,7 +57,7 @@ class isis_powder_AbstractInstTest(unittest.TestCase):
inst = self._get_abstract_inst_defaults()
# Use type this isn't None to make sure its not returning to us
unused_param = "unused"
output = inst._spline_vanadium(unused_param, unused_param, unused_param)
output = inst.spline_vanadium_ws(unused_param, unused_param, unused_param)
self.assertEquals(isinstance(output, type(None)), True)
......
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