Skip to content
Snippets Groups Projects
Commit 01753a01 authored by Harriet Brown's avatar Harriet Brown
Browse files

Add exception if any bin range will include an infinite value

This commit adds a catch for if the workspaces or q_lims file have an infinite range

Re #27444
parent 31bbc729
No related branches found
No related tags found
No related merge requests found
...@@ -150,6 +150,8 @@ def _merge_workspace_with_limits(focused_ws, q_lims): ...@@ -150,6 +150,8 @@ def _merge_workspace_with_limits(focused_ws, q_lims):
if ws_range > ws_max_range: if ws_range > ws_max_range:
largest_range_spectrum = i + 1 largest_range_spectrum = i + 1
ws_max_range = ws_range ws_max_range = ws_range
if min_x == -np.inf or max_x == np.inf:
raise AttributeError("Workspace x range contains an infinite value.")
focused_ws = mantid.Rebin(InputWorkspace=focused_ws, Params=[min_x, (max_x-min_x)/num_x, max_x]) focused_ws = mantid.Rebin(InputWorkspace=focused_ws, Params=[min_x, (max_x-min_x)/num_x, max_x])
while focused_ws.size() > 1: while focused_ws.size() > 1:
mantid.ConjoinWorkspaces(InputWorkspace1=focused_ws[0], mantid.ConjoinWorkspaces(InputWorkspace1=focused_ws[0],
...@@ -167,6 +169,9 @@ def _merge_workspace_with_limits(focused_ws, q_lims): ...@@ -167,6 +169,9 @@ def _merge_workspace_with_limits(focused_ws, q_lims):
q_min[i] = pdf_x_array[tmp2] q_min[i] = pdf_x_array[tmp2]
q_max[i] = pdf_x_array[np.amax(np.where(pdf_x_array <= q_max[i]))] q_max[i] = pdf_x_array[np.amax(np.where(pdf_x_array <= q_max[i]))]
bin_width = min(pdf_x_array[1] - pdf_x_array[0], bin_width) bin_width = min(pdf_x_array[1] - pdf_x_array[0], bin_width)
if min_x == -np.inf or max_x == np.inf:
raise AttributeError("Q lims contains an infinite value.")
focused_data_combined = mantid.CropWorkspaceRagged(InputWorkspace=focused_ws_conjoined, XMin=q_min, XMax=q_max) focused_data_combined = mantid.CropWorkspaceRagged(InputWorkspace=focused_ws_conjoined, XMin=q_min, XMax=q_max)
focused_data_combined = mantid.Rebin(InputWorkspace=focused_data_combined, focused_data_combined = mantid.Rebin(InputWorkspace=focused_data_combined,
Params=[min(q_min), bin_width, max(q_max)]) Params=[min(q_min), bin_width, max(q_max)])
......
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