scipp.transform_coords(x, targets, graph, *, rename_dims=True, keep_aliases=True, keep_intermediate=True, keep_inputs=True, quiet=False)#

Compute new coords based on transformations of input coords.

See the section in the user guide on Coordinate transformations for detailed explanations.

  • x (Union[DataArray, Dataset]) – Input object with coords.

  • targets (Union[str, Iterable[str]]) – Name or list of names of desired output coords.

  • graph (Dict[Union[str, Tuple[str, ...]], Union[str, Callable]]) –

    A graph defining how new coords can be computed from existing coords. This may be done in multiple steps. The graph is given by a dict where:

    • Dict keys are str or tuple of str, defining the names of outputs generated by a dict value.

    • Dict values are str or a callable (function). If str, this is a synonym for renaming a coord. If a callable, it must either return a single variable or a dict of variables. The argument names of callables must be coords in x or be computable by other nodes in graph.

  • rename_dims (bool, default: True) – Rename dimensions if the corresponding dimension coords are used as inputs and there is a single output coord that can be associated with that dimension. See the user guide for more details and examples. Default is True.

  • keep_aliases (bool, default: True) – If True, aliases for coords defined in graph are included in the output. Default is True.

  • keep_intermediate (bool, default: True) – Keep attributes created as intermediate results. Default is True.

  • keep_inputs (bool, default: True) – Keep consumed input coordinates or attributes. Default is True.

  • quiet (bool, default: False) – If True, no log output is produced. Otherwise, transform_coords produces a log of its actions.


Union[DataArray, Dataset] – New object with desired coords. Existing data and meta-data is shallow-copied.