Skip to content

Commit ab9acf4

Browse files
committed
Add support for specifying the beam width of error bars
1 parent f7dd194 commit ab9acf4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

extra_foam/special_suite/correlator_w.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,15 @@ def handle_rich_output():
812812
if label in self._errors:
813813
error_data = self._errors[label].data()
814814

815+
# Set a default beam width
815816
beam_width = self.xbinning_resolution if self.xbinning_enabled else 1
817+
818+
# But override it if the user set it manually
819+
for data in data_list:
820+
if isinstance(data, xr.DataArray):
821+
if label in data.attrs["series_errors_beam_widths"]:
822+
beam_width = data.attrs["series_errors_beam_widths"][label]
823+
816824
if label not in self._error_plots:
817825
self._error_plots[label] = self._plot_widget.plotStatisticsBar(pen=self._plots[label]._pen,
818826
beam=beam_width)

extra_foam/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ def get_available_port(default_port):
294294
#: :param float/np.ndarray data: The series data for the current train.
295295
#: :param str name: The name of the series, to be displayed in a legend (optional).
296296
#: :param float/np.ndarray error: The error of :code:`data`, shown as ± :code:`error` (optional).
297-
Series = namedtuple("Series", ["data", "name", "error"], defaults=[None, None])
297+
#: :param float/np.ndarray error_beam_width: The
298+
Series = namedtuple("Series", ["data", "name", "error", "error_beam_width"], defaults=[None, None, None])
298299

299300

300301
def rich_output(x, xlabel="x", ylabel="y", title=None, max_points=None, **kwargs):
@@ -356,6 +357,7 @@ def rich_output(x, xlabel="x", ylabel="y", title=None, max_points=None, **kwargs
356357
"ylabel": ylabel,
357358
"y_series_labels": [],
358359
"series_errors": { },
360+
"series_errors_beam_widths": { }
359361
}
360362

361363
# Copy optional arguments without a default value
@@ -375,6 +377,8 @@ def rich_output(x, xlabel="x", ylabel="y", title=None, max_points=None, **kwargs
375377

376378
if data.error is not None:
377379
xr_attrs["series_errors"][label] = data.error
380+
if data.error_beam_width is not None:
381+
xr_attrs["series_errors_beam_widths"][label] = data.error_beam_width
378382
else:
379383
y_series_labels.append(key)
380384
full_data.append(data)

0 commit comments

Comments
 (0)