Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mslice/models/alg_workspace_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def get_number_of_steps(axis):
return int(np.ceil(step_num))


def get_range_end(start, end, width):
return min(start + width, end) if width is not None else end


def get_axis_range(workspace, dimension_name):
workspace = get_workspace_handle(workspace)
return tuple(workspace.limits[dimension_name])
Expand Down
10 changes: 5 additions & 5 deletions src/mslice/presenters/cut_plotter_presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cut_figure_exists,
get_current_plot,
)
from mslice.models.alg_workspace_ops import get_range_end
from mslice.models.cut.cut import SampleTempValueError
from mslice.models.cut.cut_functions import compute_cut
from mslice.models.labels import generate_legend
Expand Down Expand Up @@ -122,16 +123,15 @@ def _plot_with_width(self, workspace, cut, plot_over):
"""This function handles the width parameter."""
integration_start = cut.integration_axis.start
integration_end = cut.integration_axis.end
cut_start, cut_end = (
integration_start,
min(integration_start + cut.width, integration_end),
)
cut_start = integration_start
cut_end = get_range_end(integration_start, integration_end, cut.width)
while cut_start != cut_end:
cut.integration_axis.start = cut_start
cut.integration_axis.end = cut_end
final_plot = True if cut_start + cut.width == integration_end else False
self._plot_cut(workspace, cut, plot_over, final_plot=final_plot)
cut_start, cut_end = cut_end, min(cut_end + cut.width, integration_end)
cut_start = cut_end
cut_end = get_range_end(cut_end, integration_end, cut.width)
cut.cut_ws = None
# The first plot will respect which button the user pressed. The rest will over plot
plot_over = True
Expand Down
11 changes: 6 additions & 5 deletions src/mslice/scripting/helperfunctions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
from mslice.models.alg_workspace_ops import get_range_end
from mslice.models.labels import get_recoil_key
from mslice.util.intensity_correction import IntensityType, IntensityCache
import re
Expand Down Expand Up @@ -220,10 +221,8 @@ def add_cut_lines_with_width(errorbars, script_lines, cuts, intensity_correction
for cut in cuts:
integration_start = cut.integration_axis.start
integration_end = cut.integration_axis.end
cut_start, cut_end = (
integration_start,
min(integration_start + cut.width, integration_end),
)
cut_start = integration_start
cut_end = get_range_end(integration_start, integration_end, cut.width)
intensity_range = (cut.intensity_start, cut.intensity_end)
norm_to_one = cut.norm_to_one
algo_str = "" if "Rebin" in cut.algorithm else f', Algorithm="{cut.algorithm}"'
Expand Down Expand Up @@ -253,6 +252,7 @@ def add_cut_lines_with_width(errorbars, script_lines, cuts, intensity_correction
f"IntensityCorrection={intensity_correction_arg}, SampleTemperature={cut.raw_sample_temp})\n"
)
return_ws_vars.append(cut_ws)

plot_over = False if index == 0 else True
if intensity_range != (None, None):
script_lines.append(
Expand All @@ -265,7 +265,8 @@ def add_cut_lines_with_width(errorbars, script_lines, cuts, intensity_correction
f"lw={width}, plot_over={plot_over})\n\n"
)

cut_start, cut_end = cut_end, min(cut_end + cut.width, integration_end)
cut_start = cut_end
cut_end = get_range_end(cut_end, integration_end, cut.width)
index += 1
cut.reset_integration_axis(cut.start, cut.end)
return return_ws_vars
Expand Down
Loading