stream_sparse#

anri.io.stream_sparse(sparsefile, ybinedges, omega_motor, dty_motor, chunk, groups=None, gridstep=1, dataset_dty=None, scans=None, monitor=None, monitor_ref=None, masterfile=None, dataset_omega=None, spatial=None)[source]#

Read sparse pixels a chunk at a time, with each frame’s dty row.

A frame’s omega and dty are the DataSet’s, where the DataSet has the frame (dataset_omega, dataset_dty: ImageD11 has binned the scan into rotations by then, e.g. replacing the dty of a fly scan by its mean over each rotation), else the sparse group’s own readings of omega_motor and dty_motor. Its row is the bin of ybinedges holding its dty, divided by gridstep (rows summed in groups); frames outside the bins, or that the DataSet slices out, get row -1. With a monitor, intensities are normalised to the flux as ImageD11’s DataSet.set_monitor does: multiplied by monitor_ref / monitor frame by frame, so beam decay within a rotation and between the dty rows’ scans does not show in the data.

Parameters:
  • sparsefile (str) – ImageD11 sparse pixels file, one group per scan

  • ybinedges (Array | ndarray | bool | number | bool | int | float | complex) – [n_rows + 1] dty bin edges

  • omega_motor (str) – Motor names in each group’s measurement

  • dty_motor (str) – Motor names in each group’s measurement

  • chunk (int) – Pixels per chunk at most

  • groups (list | None, default: None) – Groups to read (default: all)

  • gridstep (int, default: 1) – Rows summed in groups of this

  • dataset_dty (ndarray | None, default: None) – [scans, frames] dty and scan names from the DataSet (read_dataset()). A DataSet scan is a sparse group (“1.1”) or a slice of one (“1.1::[0:1440]”: a fly scan split into its rotations)

  • scans (list | None, default: None) – [scans, frames] dty and scan names from the DataSet (read_dataset()). A DataSet scan is a sparse group (“1.1”) or a slice of one (“1.1::[0:1440]”: a fly scan split into its rotations)

  • monitor (str | None, default: None) – Name of a counter in each group’s measurement, e.g. “fpico6”; None (default) for no normalisation. Frames where it is not positive are dropped.

  • monitor_ref (float | None, default: None) – Reference value; default the counter’s mean over the groups read

  • masterfile (str | None, default: None) – Where to find the monitor if the sparse file lacks it, see read_monitor()

  • dataset_omega (ndarray | None, default: None) – [scans, frames] omega from the DataSet, as dataset_dty

  • spatial (tuple | None, default: None) – (dx, dy) [n_slow, n_fast] detector distortion maps (read_spatial()): each pixel is yielded at (row + dy[row, col], col + dx[row, col]), as ImageD11 corrects its peaks. None: the raw pixel positions

Yields:

tuple – (slow, fast, omega, row, value): NumPy arrays of at most chunk pixels