cf.Data.concatenate

classmethod Data.concatenate(data, axis=0, cull_graph=False, relaxed_units=False, copy=True)[source]

Join a sequence of data arrays together.

See also

cull_graph

Parameters
data: sequence of Data

The data arrays to be concatenated. Concatenation is carried out in the order given. Each data array must have equivalent units and the same shape, except in the concatenation axis. Note that scalar arrays are treated as if they were one dimensional.

axis: int, optional

The axis along which the arrays will be joined. The default is 0. Note that scalar arrays are treated as if they were one dimensional.

Note

If the axis specified is cyclic, it will become non-cyclic in the output.

cull_graph: bool, optional

If True then unnecessary tasks are removed (culled) from each array’s dask graph before concatenation. This process can have a considerable overhead but can sometimes improve the overall performance of a workflow. If False (the default) then dask graphs are not culled. See dask.optimization.cull for details.

New in version 3.14.0.

relaxed_units: bool, optional

If True then allow the concatenation of data with invalid but otherwise equal units. By default, if any data array has invalid units then the concatenation will fail. A Units object is considered to be invalid if its isvalid attribute is False.

New in version 3.14.1.

copy: bool, optional

If True (the default) then make copies of the data, if required, prior to the concatenation, thereby ensuring that the input data arrays are not changed by the concatenation process. If False then some or all input data arrays might be changed in-place, but the concatenation process will be faster.

New in version 3.15.1.

Returns
Data

The concatenated data.

Examples

>>> d = cf.Data([[1, 2], [3, 4]], 'km')
>>> e = cf.Data([[5.0, 6.0]], 'metre')
>>> f = cf.Data.concatenate((d, e))
>>> print(f.array)
[[ 1.     2.   ]
 [ 3.     4.   ]
 [ 0.005  0.006]]
>>> f.equals(cf.Data.concatenate((d, e), axis=-2))
True
>>> e = cf.Data([[5.0], [6.0]], 'metre')
>>> f = cf.Data.concatenate((d, e), axis=1)
>>> print(f.array)
[[ 1.     2.     0.005]
 [ 3.     4.     0.006]]
>>> d = cf.Data(1, 'km')
>>> e = cf.Data(50.0, 'metre')
>>> f = cf.Data.concatenate((d, e))
>>> print(f.array)
[ 1.    0.05]
>>> e = cf.Data([50.0, 75.0], 'metre')
>>> f = cf.Data.concatenate((d, e))
>>> print(f.array)
[ 1.     0.05   0.075]