concatenate_patches

function of dascore.utils.patch source

concatenate_patches(
    patches: collections.abc.Sequence[collections.abc.Sequence[Patch], Spool] ,
    check_behavior: Literal[‘warn’, ‘raise’, ‘ignore’] = warn,
    **kwargs ,
)-> ‘Sequence[dc.Patch]’

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
IncompatiblePatchError
if 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

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) == 4
Note