concatenate_patches

function of dascore.utils.patch source

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

Concatenate the patches together.

Only patches which are compatible with the first patch are concatenated together.

Parameters

Parameter Description
check_behavior Indicates what to do when an incompatible patch is found in the
spool. None 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()

# Concatenate patches along time axis
spool = dc.spool([patch, patch])
spool_concat = spool.concatenate(time=None)
assert len(spool_concat) == 1

# Concatenate patches along a new dimension.
# Note: This will only include the first patch if existing
# dimensions are not identical.
spool_concat = spool.concatenate(wave_rank=None)
assert "wave_rank" in spool_concat[0].dims

# Concatenate patches in groups of 3.
big_spool = dc.spool([patch] * 12)
spool_concat = big_spool.concatenate(time=3)
assert len(spool_concat) == 4
Note