import dascore as dc
patch = dc.get_example_patch()
from dascore.utils.patch import concatenate_patches
# Concatenate patches along time axis
out = concatenate_patches([patch, patch], time=None)
assert len(out) == 1
# Concatenate patches along a new dimension.
# Note: This will only include the first patch if existing
# dimensions are not identical.
out = concatenate_patches([patch, patch], wave_rank=None)
assert "wave_rank" in out[0].dims
# Concatenate patches in groups of 3.
out = concatenate_patches([patch] * 12, time=3)
assert len(out) == 4concatenate_patches
Concatenate the patches together.
Only patches compatible with the first patch are concatenated together: the same kind (see check_kind; compared strictly, so a missing value equals only another missing value), the same data units, the same dimensions, and equal coordinates other than the concatenated one. The output carries the first patch’s attributes.
Parameters
| Parameter | Description |
|---|---|
| check_behavior |
Indicates what to do when an incompatible patch is found in the spool. ‘ignore’ will silently skip any incompatible patches, ‘warn’ will issue a warning and then skip incompatible patches, ‘raise’ will raise an IncompatiblePatchErrorif any incompatible patches are found. |
| **kwargs |
Used to specify the dimension and number of patches to merge together. A value of None attempts to concatenate all patches into as single patch. |
Examples
Note
Spool.concatenateis the spool form: it partitions patches which cannot be concatenated together into separate outputs instead of skipping them.Spool.chunkperforms a similar operation but accounts for coordinate values.- See also the chunk section of the spool tutorial