Skip to content
Snippets Groups Projects
Commit f875ce8b authored by Joseph Ramsay's avatar Joseph Ramsay
Browse files

re #20603 Enabled saving unsplined vanadium for POLARIS

parent 04733415
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,10 @@ class Polaris(AbstractInst): ...@@ -35,7 +35,10 @@ class Polaris(AbstractInst):
self._inst_settings.update_attributes(kwargs=kwargs) self._inst_settings.update_attributes(kwargs=kwargs)
vanadium_d = self._create_vanadium(run_number_string=self._inst_settings.run_in_range, vanadium_d = self._create_vanadium(run_number_string=self._inst_settings.run_in_range,
do_absorb_corrections=self._inst_settings.do_absorb_corrections) do_absorb_corrections=self._inst_settings.do_absorb_corrections)
# TODO: save vanadium_d
run_details = self._get_run_details(run_number_string=self._inst_settings.run_in_range)
polaris_algs.save_unsplined_vanadium(vanadium_ws=vanadium_d,
output_path=run_details.unsplined_vanadium_file_path)
return vanadium_d return vanadium_d
def set_sample_details(self, **kwargs): def set_sample_details(self, **kwargs):
......
...@@ -2,7 +2,7 @@ from __future__ import (absolute_import, division, print_function) ...@@ -2,7 +2,7 @@ from __future__ import (absolute_import, division, print_function)
import mantid.simpleapi as mantid import mantid.simpleapi as mantid
from isis_powder.routines import absorb_corrections, common from isis_powder.routines import absorb_corrections, common, common_enums
from isis_powder.routines.run_details import create_run_details_object, \ from isis_powder.routines.run_details import create_run_details_object, \
CustomFuncForRunDetails, RunDetailsWrappedCommonFuncs CustomFuncForRunDetails, RunDetailsWrappedCommonFuncs
from isis_powder.polaris_routines import polaris_advanced_config from isis_powder.polaris_routines import polaris_advanced_config
...@@ -57,6 +57,11 @@ def process_vanadium_for_focusing(bank_spectra, mask_path, spline_number): ...@@ -57,6 +57,11 @@ def process_vanadium_for_focusing(bank_spectra, mask_path, spline_number):
return output return output
def save_unsplined_vanadium(vanadium_ws, output_path):
# TODO: convert vanadium_ws to TOF
mantid.SaveNexus(InputWorkspace=vanadium_ws, Filename=output_path, Append=False)
def _apply_bragg_peaks_masking(workspaces_to_mask, mask_list): def _apply_bragg_peaks_masking(workspaces_to_mask, mask_list):
output_workspaces = list(workspaces_to_mask) output_workspaces = list(workspaces_to_mask)
......
...@@ -148,6 +148,23 @@ def generate_run_numbers(run_number_string): ...@@ -148,6 +148,23 @@ def generate_run_numbers(run_number_string):
return run_list return run_list
def _generate_vanadium_name(vanadium_string, is_spline, *args):
out_name = 'Van'
if is_spline:
out_name += 'Splined'
out_name += '_' + str(vanadium_string)
for passed_arg in args:
if isinstance(passed_arg, list):
for arg in passed_arg:
out_name += '_' + str(arg)
else:
out_name += '_' + (str(passed_arg))
out_name += ".nxs"
return out_name
def generate_splined_name(vanadium_string, *args): def generate_splined_name(vanadium_string, *args):
""" """
Generates a unique splined vanadium name which encapsulates Generates a unique splined vanadium name which encapsulates
...@@ -159,16 +176,21 @@ def generate_splined_name(vanadium_string, *args): ...@@ -159,16 +176,21 @@ def generate_splined_name(vanadium_string, *args):
:param args: Any identifying properties to append to the name :param args: Any identifying properties to append to the name
:return: The splined vanadium name :return: The splined vanadium name
""" """
out_name = "VanSplined" + '_' + str(vanadium_string) return _generate_vanadium_name(vanadium_string, True, *args)
for passed_arg in args:
if isinstance(passed_arg, list):
for arg in passed_arg:
out_name += '_' + str(arg)
else:
out_name += '_' + (str(passed_arg))
out_name += ".nxs"
return out_name def generate_unsplined_name(vanadium_string, *args):
"""
Generates a unique unsplined vanadium name which encapsulates
any properties passed into this method so that the vanadium
can be later loaded. This acts as a fingerprint for the vanadium
as some properties (such as offset file used) can impact
on the correct splined vanadium file to use.
:param vanadium_string: The name of this vanadium run
:param args: Any identifying properties to append to the name
:return: The splined vanadium name
"""
return _generate_vanadium_name(vanadium_string, False, *args)
def get_first_run_number(run_number_string): def get_first_run_number(run_number_string):
......
...@@ -67,13 +67,15 @@ def create_run_details_object(run_number_string, inst_settings, is_vanadium_run, ...@@ -67,13 +67,15 @@ def create_run_details_object(run_number_string, inst_settings, is_vanadium_run,
# Offset and splined vanadium is within the correct label folder # Offset and splined vanadium is within the correct label folder
offset_file_path = os.path.join(calibration_dir, label, offset_file_name) offset_file_path = os.path.join(calibration_dir, label, offset_file_name)
splined_van_path = os.path.join(calibration_dir, label, results_dict["splined_van_name"]) splined_van_path = os.path.join(calibration_dir, label, results_dict["splined_van_name"])
unsplined_van_path = os.path.join(calibration_dir, label, results_dict["unsplined_van_name"])
van_absorb_path = os.path.join(calibration_dir, van_abs_file_name) if van_abs_file_name else None van_absorb_path = os.path.join(calibration_dir, van_abs_file_name) if van_abs_file_name else None
return _RunDetails(empty_run_number=results_dict["empty_runs"], file_extension=file_extension, return _RunDetails(empty_run_number=results_dict["empty_runs"], file_extension=file_extension,
run_number=run_number, output_run_string=output_run_string, label=label, run_number=run_number, output_run_string=output_run_string, label=label,
offset_file_path=offset_file_path, grouping_file_path=grouping_file_path, offset_file_path=offset_file_path, grouping_file_path=grouping_file_path,
splined_vanadium_path=splined_van_path, vanadium_run_number=vanadium_run_string, splined_vanadium_path=splined_van_path, vanadium_run_number=vanadium_run_string,
sample_empty=sample_empty, vanadium_abs_path=van_absorb_path) sample_empty=sample_empty, vanadium_abs_path=van_absorb_path,
unsplined_vanadium_path=unsplined_van_path)
def _get_customisable_attributes(cal_dict, inst_settings, empty_run_call, grouping_name_call, vanadium_run_call, def _get_customisable_attributes(cal_dict, inst_settings, empty_run_call, grouping_name_call, vanadium_run_call,
...@@ -98,6 +100,7 @@ def _get_customisable_attributes(cal_dict, inst_settings, empty_run_call, groupi ...@@ -98,6 +100,7 @@ def _get_customisable_attributes(cal_dict, inst_settings, empty_run_call, groupi
dict_to_return["grouping_file_name"] = grouping_name dict_to_return["grouping_file_name"] = grouping_name
dict_to_return["splined_van_name"] = common.generate_splined_name(vanadium_runs, splined_name_list) dict_to_return["splined_van_name"] = common.generate_splined_name(vanadium_runs, splined_name_list)
dict_to_return["unsplined_van_name"] = common.generate_unsplined_name(vanadium_runs, splined_name_list)
return dict_to_return return dict_to_return
...@@ -180,7 +183,7 @@ class _RunDetails(object): ...@@ -180,7 +183,7 @@ class _RunDetails(object):
def __init__(self, empty_run_number, file_extension, run_number, output_run_string, label, def __init__(self, empty_run_number, file_extension, run_number, output_run_string, label,
offset_file_path, grouping_file_path, splined_vanadium_path, vanadium_run_number, offset_file_path, grouping_file_path, splined_vanadium_path, vanadium_run_number,
sample_empty, vanadium_abs_path): sample_empty, vanadium_abs_path, unsplined_vanadium_path):
# Essential attribute # Essential attribute
self.empty_runs = empty_run_number self.empty_runs = empty_run_number
...@@ -193,6 +196,7 @@ class _RunDetails(object): ...@@ -193,6 +196,7 @@ class _RunDetails(object):
self.grouping_file_path = grouping_file_path self.grouping_file_path = grouping_file_path
self.splined_vanadium_file_path = splined_vanadium_path self.splined_vanadium_file_path = splined_vanadium_path
self.unsplined_vanadium_file_path = unsplined_vanadium_path
self.vanadium_run_numbers = vanadium_run_number self.vanadium_run_numbers = vanadium_run_number
# Optional # Optional
......
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