scippnexus.compute_positions#

scippnexus.compute_positions(dg, *, store_position='position', store_transform=None)#

Recursively compute positions from depends_on attributes as well as the [xyz]_pixel_offset fields of NXdetector groups.

This function does not operate directly on a NeXus file but on the result of loading a NeXus file or sub-group into a scipp.DataGroup. NeXus puts no limitations on the structure of the depends_on chains, i.e., they may reference parent groups. If this is the case, a call to this function will fail if only the subgroup is passed as input.

Note that this does not consider “legacy” ways of storing positions. In particular, NXmonitor.distance, NXdetector.distance, NXdetector.polar_angle, and NXdetector.azimuthal_angle are ignored.

Note that transformation chains may be time-dependent. In this case it will not be applied to the pixel offsets, since the result may consume too much memory and the shape is in general incompatible with the shape of the data. Use the store_transform argument to store the resolved transformation chain in this case.

If a transformation chain has an invalid ‘depends_on’ value, e.g., a path beyond the root data group, then the chain is ignored and no position is computed. This does not affect other chains.

Parameters:
  • dg (DataGroup) – Data group with depends_on entry points into transformation chains.

  • store_position (str, default: 'position') – Name used to store result of resolving each depends_on chain.

  • store_transform (Optional[str], default: None) – If not None, store the resolved transformation chain in this field.

Returns:

DataGroup – New data group with added positions.