ess.reduce.live.raw.RollingDetectorView#
- class ess.reduce.live.raw.RollingDetectorView(*, detector_number, window, projection=None)[source]#
Rolling view of a detector.
The view keeps a history of counts and allows to access the sum of counts over a window of the most recent counts.
- __init__(*, detector_number, window, projection=None)[source]#
Create a rolling detector view.
- Parameters:
detector_number (
Variable
) – Detector number for each pixel. This is used for mapping event_id to pixel.window (
int
) – Size of the rolling window. This is the maximum window size, smaller windows can be accessed using the get method.projection (
Optional
[Callable
[[DataArray
],DataArray
]], default:None
) – Optional projection function to apply to the counts before storing them in the history. This can be used to project the data onto a different coordinate system or to reduce the dimensionality of the data.
Methods
__init__
(*, detector_number, window[, ...])Create a rolling detector view.
add_counts
(data)Add counts in the form of a sequence of pixel IDs.
add_events
(data)Add counts in the form of events grouped by pixel ID.
bincount
(data)Clear counts.
from_detector_and_histogrammer
(detector, ...)Helper for constructing via a Sciline workflow.
from_detector_and_logical_view
(detector, ...)Helper for constructing via a Sciline workflow.
from_nexus
(nexus_file, *, detector_name, ...)Create a rolling detector view from a NeXus file using GenericNeXusWorkflow.
get
(*[, window])Get the sum of counts over a window of the most recent counts.
Return a ROI filter operating via the projection plane of the view.
transform_weights
([weights, threshold])Transform raw pixel weights to the projection plane.
Attributes
data
detector_number
- clear_counts()[source]#
Clear counts.
Overrides Detector.clear_counts, to properly clear sliding window history and cache.
- Return type:
- static from_detector_and_histogrammer(detector, window, projection)[source]#
Helper for constructing via a Sciline workflow.
- Return type:
- static from_detector_and_logical_view(detector, window, projection)[source]#
Helper for constructing via a Sciline workflow.
- Return type:
- static from_nexus(nexus_file, *, detector_name, window, projection, resolution=None, pixel_noise=None)[source]#
Create a rolling detector view from a NeXus file using GenericNeXusWorkflow.
The configuration parameters are preliminary for testing and are expected to change in the future.
- Parameters:
nexus_file (
str
) – NeXus file providing detector parameters such as detector_number and pixel positions.detector_name (
str
) – Name of the detector in the NeXus file.window (
int
) – Size of the rolling window.projection (
Union
[Literal
['xy_plane'
,'cylinder_mantle_z'
],LogicalView
]) – Projection to use for the detector data. This can be a string selecting a predefined projection or a LogicalView instance.resolution (
Optional
[dict
[str
,int
]], default:None
) – Resolution to use for histogramming the detector data. Not required when the projection is a LogicalView.pixel_noise (
Union
[Literal
['cylindrical'
],Variable
,None
], default:None
) – Noise to add to the pixel positions. This can be a scalar value to add Gaussian noise to the pixel positions or the string ‘cylindrical’ to add noise to the pixel positions of a cylindrical detector. Adding noise can be useful to avoid artifacts when projecting the data.
- Return type:
- make_roi_filter()[source]#
Return a ROI filter operating via the projection plane of the view.
- Return type:
- transform_weights(weights=None, *, threshold=0.1)[source]#
Transform raw pixel weights to the projection plane.
- Parameters:
weights (
Union
[Variable
,DataArray
,None
], default:None
) – Raw pixel weights to transform. If None, default weights of 1 are used.threshold (
float
, default:0.1
) – Threshold for identifying bins with a low weight. If the weight is below the threshold times the median weight, the bin is marked as invalid. This is relevant to avoid issues with color scales in plots, where noise in bins with low weight may dominate the color scale if auto-scaling is used.
- Return type: