Skip to content
Snippets Groups Projects
Commit bb126283 authored by Elliot Oram's avatar Elliot Oram
Browse files

Avoid supplying workspace to total_scattering function

This is to match other isis_powder style functions (e.g. create_vanadium and focus)

Given the nature of it being post reduction analysis, it might be worth adding the ability to provide a workspace.
This would have to be discussed with an instrument scientist to see if it of use.

Refs #21294
parent 6c43079e
No related branches found
No related tags found
No related merge requests found
...@@ -44,9 +44,11 @@ class Polaris(AbstractInst): ...@@ -44,9 +44,11 @@ class Polaris(AbstractInst):
def create_total_scattering_pdf(self, **kwargs): def create_total_scattering_pdf(self, **kwargs):
self._inst_settings.update_attributes(kwargs=kwargs) self._inst_settings.update_attributes(kwargs=kwargs)
# Validate that required files exist # Generate pdf
# generate pdf run_details = self._get_run_details(self._inst_settings.run_number)
pdf_output = polaris_algs.generate_ts_pdf(focused_ws=self._inst_settings.focused_ws, focus_file_path = self._generate_out_file_paths(run_details)["nxs_filename"]
pdf_output = polaris_algs.generate_ts_pdf(run_number=self._inst_settings.run_number,
focus_file_path=focus_file_path,
merge_banks=self._inst_settings.merge_banks) merge_banks=self._inst_settings.merge_banks)
return pdf_output return pdf_output
......
...@@ -76,8 +76,9 @@ def save_unsplined_vanadium(vanadium_ws, output_path): ...@@ -76,8 +76,9 @@ def save_unsplined_vanadium(vanadium_ws, output_path):
mantid.DeleteWorkspace(converted_group) mantid.DeleteWorkspace(converted_group)
def generate_ts_pdf(focused_ws, merge_banks=False): def generate_ts_pdf(run_number, focus_file_path, merge_banks=False):
pdf_output = mantid.ConvertUnits(InputWorkspace=focused_ws, Target="MomentumTransfer") focused_ws = _obtain_focused_run(run_number, focus_file_path)
pdf_output = mantid.ConvertUnits(InputWorkspace=focused_ws.getName(), Target="MomentumTransfer")
if merge_banks: if merge_banks:
raise RuntimeError("Merging banks is currently not supported") raise RuntimeError("Merging banks is currently not supported")
pdf_output = mantid.PDFFourierTransform(Inputworkspace=pdf_output, InputSofQType="S(Q)", PDFType="G(r)", pdf_output = mantid.PDFFourierTransform(Inputworkspace=pdf_output, InputSofQType="S(Q)", PDFType="G(r)",
...@@ -85,6 +86,32 @@ def generate_ts_pdf(focused_ws, merge_banks=False): ...@@ -85,6 +86,32 @@ def generate_ts_pdf(focused_ws, merge_banks=False):
return pdf_output return pdf_output
def _obtain_focused_run(run_number, focus_file_path):
"""
Searches for the focused workspace to use (based on user specified run number) in the ADS and then the output
directory.
If unsuccessful, a ValueError exception is thrown.
:param run_number: The run number to search for.
:param focus_file_path: The expected file path for the focused file.
:return: The focused workspace.
"""
# Try the ADS first to avoid undesired loading
if mantid.mtd.doesExist('%s-Results-TOF-Grp' % run_number):
focused_ws = mantid.mtd['%s-Results-TOF-Grp' % run_number]
elif mantid.mtd.doesExist('%s-Results-D-Grp' % run_number):
focused_ws = mantid.mtd['%s-Results-D-Grp' % run_number]
else:
# Check output directory
print('No loaded focused files found. Searching in output directory...')
try:
focused_ws = mantid.LoadNexus(Filename=focus_file_path, OutputWorkspace='focused_ws').OutputWorkspace
except ValueError:
raise ValueError("Could not find focused file for run number:%s\n"
"Please ensure a focused file has been produced and is located in the output directory."
% run_number)
return focused_ws
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)
......
...@@ -16,7 +16,6 @@ attr_mapping = \ ...@@ -16,7 +16,6 @@ attr_mapping = \
ParamMapEntry(ext_name="first_cycle_run_no", int_name="run_in_range"), ParamMapEntry(ext_name="first_cycle_run_no", int_name="run_in_range"),
ParamMapEntry(ext_name="focused_cropping_values", int_name="focused_cropping_values"), ParamMapEntry(ext_name="focused_cropping_values", int_name="focused_cropping_values"),
ParamMapEntry(ext_name="focused_bin_widths", int_name="focused_bin_widths"), ParamMapEntry(ext_name="focused_bin_widths", int_name="focused_bin_widths"),
ParamMapEntry(ext_name="focused_workspace", int_name="focused_ws"),
ParamMapEntry(ext_name="grouping_file_name", int_name="grouping_file_name"), ParamMapEntry(ext_name="grouping_file_name", int_name="grouping_file_name"),
ParamMapEntry(ext_name="input_mode", int_name="input_mode", enum_class=INPUT_BATCHING), ParamMapEntry(ext_name="input_mode", int_name="input_mode", enum_class=INPUT_BATCHING),
ParamMapEntry(ext_name="merge_banks", int_name="merge_banks"), ParamMapEntry(ext_name="merge_banks", int_name="merge_banks"),
......
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