cf.Data.concatenate

classmethod Data.concatenate(data, axis=0, _preserve=True)[source]

Join a sequence of data arrays together.

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.

_preserve: bool, optional

If False then the time taken to do the concatenation is reduced at the expense of changing the input data arrays given by the data parameter in place and these in place changes will render the input data arrays unusable. Therefore, only set to False if it is 100% certain that the input data arrays will not be accessed again. By default the input data arrays are preserved.

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]