Skip to content

Commit a79f6ae

Browse files
committed
Update the shift value to match matlab
1 parent 0ea7df6 commit a79f6ae

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ratapi/utils/plotting.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _extract_plot_data(event_data: PlotEventData, q4: bool, show_error_bar: bool
3636
show_error_bar : bool, default: True
3737
Controls whether the error bars are shown
3838
shift_value : float
39-
A value between 1 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
39+
A value between 0 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
4040
4141
Returns
4242
-------
@@ -46,14 +46,14 @@ def _extract_plot_data(event_data: PlotEventData, q4: bool, show_error_bar: bool
4646
"""
4747
results = {"ref": [], "error": [], "sld": [], "sld_resample": []}
4848

49-
if shift_value < 1 or shift_value > 100:
50-
raise ValueError("Parameter `shift_value` must be between 1 and 100")
49+
if shift_value < 0 or shift_value > 100:
50+
raise ValueError("Parameter `shift_value` must be between 0 and 100")
5151

5252
for i, (r, data, sld) in enumerate(
5353
zip(event_data.reflectivity, event_data.shiftedData, event_data.sldProfiles, strict=False)
5454
):
5555
# Calculate the divisor
56-
div = 1 if i == 0 and not q4 else 10 ** ((i + 1) / 100 * shift_value)
56+
div = 10 ** (i / 100 * shift_value)
5757
q4_data = 1 if not q4 or not event_data.dataPresent[i] else data[:, 0] ** 4
5858
mult = q4_data / div
5959

@@ -137,7 +137,7 @@ def plot_ref_sld_helper(
137137
show_legend : bool, default: True
138138
Controls whether the legend is shown
139139
shift_value : float, default: 100
140-
A value between 1 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
140+
A value between 0 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
141141
animated : bool, default: False
142142
Controls whether the animated property of foreground plot elements should be set.
143143
@@ -168,7 +168,7 @@ def plot_ref_sld_helper(
168168
# Plot confidence intervals if required
169169
if confidence_intervals is not None:
170170
# Calculate the divisor
171-
div = 1 if i == 0 and not q4 else 10 ** ((i + 1) / 100 * shift_value)
171+
div = 10 ** (i / 100 * shift_value)
172172
ref_min, ref_max = confidence_intervals["reflectivity"][i]
173173
mult = (1 if not q4 else plot_data["ref"][i][0] ** 4) / div
174174
ref_plot.fill_between(plot_data["ref"][i][0], ref_min * mult, ref_max * mult, alpha=0.6, color="grey")
@@ -277,7 +277,7 @@ def plot_ref_sld(
277277
show_legend : bool, default: True
278278
Controls whether the legend is shown
279279
shift_value : float, default: 100
280-
A value between 1 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
280+
A value between 0 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
281281
282282
Returns
283283
-------
@@ -387,7 +387,7 @@ class BlittingSupport:
387387
show_legend : bool, default: True
388388
Controls whether the legend is shown
389389
shift_value : float, default: 100
390-
A value between 1 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
390+
A value between 0 and 100 that controls the spacing between the reflectivity plots for each of the contrasts
391391
"""
392392

393393
def __init__(

0 commit comments

Comments
 (0)