spectrochempy.concatenate

concatenate(*datasets, **kwargs)[source]

Concatenation of NDDataset objects along a given axis.

Any number of NDDataset objects can be concatenated (by default the last on the last dimension). For this operation to be defined the following must be true :

  1. all inputs must be valid NDDataset objects;

  2. units of data must be compatible

  3. concatenation is along the axis specified or the last one;

  4. coordinate values and labels on the concatenated dimension must each be present for every input or absent from every input. A label-only coordinate is valid.

  5. a coordinate reference involving the concatenated dimension is rejected, whether that dimension is the reference or its target, because changing only one dimension cannot preserve their shared geometry.

  6. along the non-concatenated dimensions, shapes must match.

Parameters
  • *datasets (positional NDDataset arguments) – The dataset(s) to be concatenated to the current dataset. The datasets must have the same shape, except in the dimension corresponding to axis (the last, by default).

  • **kwargs – Optional keyword parameters (see Other Parameters).

Returns

out – A NDDataset created from the contenations of the NDDataset input objects.

Other Parameters
  • dims (str, optional, default=’x’) – The dimension along which the operation is applied.

  • axis (int, optional) – The axis along which the operation is applied.

    For 1D datasets, axis=1 promotes inputs to a 2D dataset and concatenates them as columns.

Raises

DimensionsCompatibilityError – If coordinate values or labels on the concatenated dimension are present for only some inputs, or if that dimension is a coordinate reference or the target of one.

See also

stack

Stack of NDDataset objects along a new dimension.

Examples

>>> A = scp.read('irdata/nh4y-activation.spg', protocol='omnic')
>>> B = scp.read('irdata/nh4y-activation.scp')
>>> C = scp.concatenate(A[10:], B[3:5], A[:10], axis=0)
>>> A[10:].shape, B[3:5].shape, A[:10].shape, C.shape
((45, 5549), (2, 5549), (10, 5549), (57, 5549))

or

>>> D = A.concatenate(B, B, axis=0)
>>> A.shape, B.shape, D.shape
((55, 5549), (55, 5549), (165, 5549))
>>> E = A.concatenate(B, axis=1)
>>> A.shape, B.shape, E.shape
((55, 5549), (55, 5549), (55, 11098))