scipp.concat

scipp.concat(x, dim)

Concatenate input arrays along the given dimension.

Concatenation can happen in two ways:

  • Along an existing dimension, yielding a new dimension extent given by the sum of the input’s extents.

  • Along a new dimension that is not contained in either of the inputs, yielding an output with one extra dimensions.

In the case of a data array or dataset, the coords and masks are also concatenated. Coords and masks for any but the given dimension are required to match and are copied to the output without changes.

Parameters
  • x – Sequence of input variables, data arraus, or datasets.

  • dim – Dimension along which to concatenate.

Raises

If the dtype or unit does not match, or if the dimensions and shapes are incompatible.

Returns

Concatenation of the inputs.

Examples:

>>> a = sc.arange('x', 3)
>>> b = 100 * sc.arange('x', 3)
>>> c = sc.concat([a, b], dim='x')
>>> c
<scipp.Variable> (x: 6)      int64  [dimensionless]  [0, 1, ..., 100, 200]
>>> c.values
array([  0,   1,   2,   0, 100, 200])
>>> d = sc.concat([a, b], dim='y')
>>> d
<scipp.Variable> (y: 2, x: 3)      int64  [dimensionless]  [0, 1, ..., 100, 200]
>>> d.values
array([[  0,   1,   2],
       [  0, 100, 200]])
>>> x = sc.DataArray(sc.arange('x', 3), coords={'x': sc.arange('x', 3)})
>>> y = sc.DataArray(100 * sc.arange('x', 3), coords={'x': 100 * sc.arange('x', 3)})
>>> z = sc.concat([x, y], dim='x')
>>> z
<scipp.DataArray>
Dimensions: Sizes[x:6, ]
Coordinates:
  x                           int64  [dimensionless]  (x)  [0, 1, ..., 100, 200]
Data:
                              int64  [dimensionless]  (x)  [0, 1, ..., 100, 200]
>>> z.values
array([  0,   1,   2,   0, 100, 200])