render_row#

anri.fwd.render_row(entries, hkls, F2, geom, row, det_shape, window=(3, 7, 7), batch=65536, select_chunk=1048576, min_value=0.001, mesh=None, max_frames=None)[source]#

Render all peaks of one phase that reach one dty row into sparse pixels.

Work is split across the devices of mesh (default anri.utils.mesh()): all GPUs, or all XLA CPU devices set up by anri.utils.setup().

Parameters:
  • entries (dict) – Dict with “ubi” [N, 3, 3], “pos” [N, 3] (sample frame, same length units as dty) and “density” [N], for map entries of a single phase. Optionally “sig_rot” [N] (or a scalar): each entry’s intrinsic orientation spread, the standard deviation (radians) of each component of a small sample-frame rotation vector, isotropic. It widens the entry’s peaks in omega and on the detector through the same linearised propagation as the beam’s spreads, so it suits spreads up to a few degrees. Widen window (pixels) for spreads that move spots by several pixels.

  • hkls (ndarray) – [Nh, 3] hkls of that phase and [Nh] their structure factors squared

  • F2 (ndarray) – [Nh, 3] hkls of that phase and [Nh] their structure factors squared

  • geom (dict) – Dict with “wavelength”, “k_in_lab” [3], “wedge”, “chi” (degrees), “y0”, “s_step_lab”, “f_step_lab”, “det_origin_lab” [3] (from anri.geom.detector_basis_vectors_lab()), “sig_wavelength”, “sig_ky”, “sig_kz”, “sig_beam”, “sig_psf” (detector point spread, pixels), “voxel_size” and “pol_factor”; optionally “sig_omega”, an extra spread of every peak in omega (degrees, default 0)

  • row (dict) – From make_row()

  • det_shape (tuple[int, int]) – (n_slow, n_fast)

  • window (tuple[int, int, int], default: (3, 7, 7)) – (n_frames, n_slow, n_fast) window per peak, each odd

  • batch (int, default: 65536) – Maximum number of peaks rendered at once, over all devices

  • select_chunk (int, default: 1048576) – Approximate number of (entry, hkl) pairs per call to select_peaks()

  • min_value (float, default: 0.001) – Contributions below this are dropped

  • mesh (Mesh | None, default: None) – Devices to use, default anri.utils.mesh()

  • max_frames (int | None, default: None) – If set, peaks broad in omega get more frames: each peak’s window has the fewest frames out of window[0], 2 window[0] + 1, … (up to max_frames) that hold +-3.5 sigma of it in omega, and each size is rendered in its own batches. Default None: every peak gets window[0] frames.

Returns:

  • frame, pixel, value (np.ndarray) – Sparse pixels sorted by (frame, pixel), with duplicates summed

  • stats (dict) – “n_peaks” rendered and their “captured” window fractions