ess.reduce.live.raw.LogicalView#

class ess.reduce.live.raw.LogicalView(transform, reduction_dim=None, input_sizes=None)[source]#

Logical view for detector data.

Implements a view by applying a user-defined transform (e.g., fold or slice operations) optionally followed by reduction (summing) over specified dimensions. Transformation and reduction must be specified separately for LogicalView to construct a mapping from output indices to input indices. So transform must not perform any reductions.

This class provides both data transformation (__call__) and index mapping (input_indices) using the same transform, ensuring consistency for ROI filtering.

__init__(transform, reduction_dim=None, input_sizes=None)[source]#

Create a logical view.

Parameters:
  • transform (Callable[[DataArray], DataArray]) – Callable that transforms input data by reshaping or selecting pixels. Examples: - Fold: lambda da: da.fold(‘x’, {‘x’: 512, ‘x_bin’: 2}) - Slice: lambda da: da[‘z’, 0] (select front layer of volume) - Combined: lambda da: da.fold(‘x’, {‘x’: 4, ‘z’: 8})[‘z’, 0]

  • reduction_dim (str | list[str] | None, default: None) – Dimension(s) to sum over after applying transform. If None or empty, no reduction is performed (pure transform). Example: ‘x_bin’ or [‘x_bin’, ‘y_bin’]

  • input_sizes (dict[str, int] | None, default: None) – Dictionary defining the input dimension sizes. Required for input_indices(). If not provided, input_indices() will raise an error. When used with RollingDetectorView, this is automatically inferred from detector_number.

Methods

__init__(transform[, reduction_dim, input_sizes])

Create a logical view.

input_indices()

Create index mapping for ROI filtering.

Attributes

replicas

Number of replicas.

input_indices()[source]#

Create index mapping for ROI filtering.

Returns a DataArray mapping output pixels to input indices (as indices into the flattened input array). If reduction dimensions are specified, returns binned data where each output pixel contains a list of contributing input indices. If no reduction, returns dense indices (1:1 mapping).

Returns:

DataArray – DataArray mapping output pixels to input indices.

Raises:

ValueError: – If input_sizes was not provided during initialization.

property replicas: int#

Number of replicas. Always 1 for LogicalView.