diff --git a/scripts/Diffraction/isis_powder/abstract_inst.py b/scripts/Diffraction/isis_powder/abstract_inst.py index fb2877827efb014977b08154519b9cfd3c03dcab..e9894fd212eb58f10396659dbab73df68d608482 100644 --- a/scripts/Diffraction/isis_powder/abstract_inst.py +++ b/scripts/Diffraction/isis_powder/abstract_inst.py @@ -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 diff --git a/scripts/Diffraction/isis_powder/mock_instrument.py b/scripts/Diffraction/isis_powder/mock_instrument.py index f8ab44ba340df0ba0ee6d8c073fb77c42276805b..6c328cd314636c161743f1cd5000e2d13f6e9268 100644 --- a/scripts/Diffraction/isis_powder/mock_instrument.py +++ b/scripts/Diffraction/isis_powder/mock_instrument.py @@ -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 diff --git a/scripts/Diffraction/isis_powder/pearl.py b/scripts/Diffraction/isis_powder/pearl.py index c126bb66e80c2cd2a7702a94c005c7c50eee8ace..8dc1623fd1c1d70a3bfd9f322cba2fe96b54c793 100644 --- a/scripts/Diffraction/isis_powder/pearl.py +++ b/scripts/Diffraction/isis_powder/pearl.py @@ -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 diff --git a/scripts/Diffraction/isis_powder/pearl_routines/PearlRoutinesWrapper.py b/scripts/Diffraction/isis_powder/pearl_routines/PearlRoutinesWrapper.py index 5830e35d5dd36cdd96c071af8e34647111807d7c..145aff1226b9b3be02eff0797e21e51023c9b395 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/PearlRoutinesWrapper.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/PearlRoutinesWrapper.py @@ -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) diff --git a/scripts/Diffraction/isis_powder/polaris.py b/scripts/Diffraction/isis_powder/polaris.py index 72e48c118884cd60ab292d4c9d9e8728dbd508d7..70f91bc73336030c30b4de891b69d1a5a194e94a 100644 --- a/scripts/Diffraction/isis_powder/polaris.py +++ b/scripts/Diffraction/isis_powder/polaris.py @@ -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) diff --git a/scripts/Diffraction/isis_powder/routines/calibrate.py b/scripts/Diffraction/isis_powder/routines/calibrate.py index b2b9167014b003687e5d563dc31ca39f5c075c75..afc0a8a29910bce0858129b82129660eca564dc0 100644 --- a/scripts/Diffraction/isis_powder/routines/calibrate.py +++ b/scripts/Diffraction/isis_powder/routines/calibrate.py @@ -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) diff --git a/scripts/Diffraction/isis_powder/routines/common.py b/scripts/Diffraction/isis_powder/routines/common.py index 940e881980fe6bb6ff29a684f292dfe67237ea6a..2c4b3d4489461380252082db9035e4eec6b144dc 100644 --- a/scripts/Diffraction/isis_powder/routines/common.py +++ b/scripts/Diffraction/isis_powder/routines/common.py @@ -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 diff --git a/scripts/Diffraction/isis_powder/routines/focus.py b/scripts/Diffraction/isis_powder/routines/focus.py index 4b8d4664a0c17977fbb0bf59c5692fbf42d9fb70..50fb0f0ee4cbf9627c3328b91a97fd86b1d51e22 100644 --- a/scripts/Diffraction/isis_powder/routines/focus.py +++ b/scripts/Diffraction/isis_powder/routines/focus.py @@ -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) diff --git a/scripts/test/ISIS_Powder_AbstractInstTest.py b/scripts/test/ISIS_Powder_AbstractInstTest.py index 49723c6d54679b913f95ebaa4eea27857849768f..b37a1fdc74d59d700e92f1aa9c23eed28645833e 100644 --- a/scripts/test/ISIS_Powder_AbstractInstTest.py +++ b/scripts/test/ISIS_Powder_AbstractInstTest.py @@ -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)