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

Re #18666 Add multiple scattering and update output filenames

parent 3c582730
No related branches found
No related tags found
No related merge requests found
......@@ -58,11 +58,20 @@ class Polaris(AbstractInst):
@staticmethod
def _generate_input_file_name(run_number):
polaris_old_name = "POL"
polaris_new_name = "POLARIS"
first_run_new_name = 96912
if isinstance(run_number, list):
updated_list = ["POL" + str(val) for val in run_number]
# Lists use recursion to deal with individual entries
updated_list = []
for run in run_number:
updated_list.append(Polaris._generate_input_file_name(run_number=run))
return updated_list
else:
return "POL" + str(run_number)
# Select between old and new prefix
prefix = polaris_new_name if int(run_number) >= first_run_new_name else polaris_old_name
return prefix + str(run_number)
def _generate_output_file_name(self, run_number_string):
return self._generate_input_file_name(run_number=run_number_string)
......@@ -85,7 +94,8 @@ class Polaris(AbstractInst):
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)
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):
d_spacing_group, tof_group = polaris_algs.split_into_tof_d_spacing_groups(run_details=run_details,
......
......@@ -7,7 +7,7 @@ from isis_powder.routines.RunDetails import RunDetails
from isis_powder.polaris_routines import polaris_advanced_config
def calculate_absorb_corrections(ws_to_correct):
def calculate_absorb_corrections(ws_to_correct, multiple_scattering):
mantid.MaskDetectors(ws_to_correct, SpectraList=list(range(0, 55)))
absorb_dict = polaris_advanced_config.absorption_correction_params
......@@ -18,7 +18,8 @@ def calculate_absorb_corrections(ws_to_correct):
mantid.SetSample(InputWorkspace=ws_to_correct, Geometry=geometry_json, Material=material_json)
ws_to_correct = mantid.ConvertUnits(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct, Target="TOF")
ws_to_correct = mantid.MayersSampleCorrection(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct)
ws_to_correct = mantid.MayersSampleCorrection(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct,
MultipleScattering=multiple_scattering)
ws_to_correct = mantid.ConvertUnits(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct, Target="dSpacing")
return ws_to_correct
......
......@@ -8,16 +8,22 @@ def save_polaris_focused_data(d_spacing_group, tof_group, output_paths, run_numb
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)
_save_xye(ws_group=d_spacing_group, ws_units="d_spacing", run_number=run_number,
output_folder=output_paths["output_folder"])
dat_folder_name = "dat_files"
dat_file_destination = os.path.join(output_paths["output_folder"], dat_folder_name)
if not os.path.exists(dat_file_destination):
os.makedirs(dat_file_destination)
_save_xye(ws_group=d_spacing_group, ws_units="d", run_number=run_number,
output_folder=dat_file_destination)
_save_xye(ws_group=tof_group, ws_units="TOF", run_number=run_number,
output_folder=output_paths["output_folder"])
output_folder=dat_file_destination)
def _save_xye(ws_group, ws_units, run_number, output_folder):
bank_index = 1
prefix_filename = "POL" + str(run_number)
for ws in ws_group:
outfile_name = str(run_number) + "-b_" + str(bank_index) + "-" + ws_units + ".dat"
outfile_name = prefix_filename + "-b_" + str(bank_index) + "-" + ws_units + ".dat"
bank_index += 1
full_file_path = os.path.join(output_folder, outfile_name)
......
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