concatenate

method of dascore.core.spool.BaseSpool source

concatenate(
    self ,
    check_behavior: Literal[‘warn’, ‘raise’, None] = warn,
    **kwargs ,
)

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