spectrochempy.align#

align(dataset, *others, **kwargs)[source]#

Align individual NDDataset along given dimensions using various methods.

Parameters:
  • dataset (NDDataset) – Dataset on which we want to align other objects.

  • *others (NDDataset) – Objects to align.

  • dim (str. Optional, default=’x’) – Along which axis to perform the alignment.

  • dims (list of str, optional, default=None) – Align along all dims defined in dims (if dim is also defined, then dims have higher priority).

  • method (enum [‘outer’, ‘inner’, ‘first’, ‘last’, ‘interpolate’], optional, default=’outer’) – Which method to use for the alignment.

    If align is defined :

    • ‘outer’ means that a union of the different coordinates is achieved (missing values are masked).

    • ‘inner’ means that the intersection of the coordinates is used.

    • ‘first’ uses the first dataset’s coordinates, masking positions with no matching coordinate.

    • ‘last’ does the same using the last dataset’s coordinates.

    • ‘interpolate’ interpolates onto the first dataset’s coordinates. Points outside the source range or depending on masked samples are masked.

    Outer and reference joins match with at least five significant digits at each coordinate’s scale. If any input coordinate disables rounding, those joins use full precision.

  • interpolate_method (enum [‘linear’,’pchip’]. Optional, default=’linear’) – Method of interpolation to performs for the alignment.

  • interpolate_sampling ({‘auto’}, optional, default=’auto’) – Sampling of the target coordinate when method='interpolate'. 'auto' uses the target grid unchanged. Pass coord to supply an explicit grid. A numeric sampling interval is unsupported.

  • coord (Coord , optional, default=None) – Explicit target for interpolation along a single dimension. A unitless target is interpreted in the reference coordinate’s units.

  • copy (bool, optional, default=True) – If False, avoid extra copies where possible. Alignment can still allocate data buffers and does not guarantee memory sharing.

Returns:

tuple of NDDataset – Same objects as datasets with dimensions aligned.

Raises:
  • ValueError – Issued when the dimensions given in dim or dims argument are not compatibles (units, titles, etc.), or an inner join finds no shared coordinates or encounters duplicate coordinates after rounding.

  • NotImplementedError – Issued when interpolate_sampling is not 'auto'.