import numpy as np
import dascore as dc
from dascore.core.coords import concat_coords, get_coord
# A patch whose distance coordinate has a gap.
dist = concat_coords(
get_coord(start=0.0, stop=10.0, step=1.0),
get_coord(start=15.0, stop=25.0, step=1.0),
)
patch = dc.Patch(
data=np.zeros((len(dist), 5)),
coords={"distance": dist, "time": dc.to_datetime64(np.arange(5))},
dims=("distance", "time"),
)
spool = patch.split_gaps()
assert len(spool) == 2split_gaps
split_gaps(
self: Patch ,
dim: str | None[str, None] = None,
)-> ‘dc.Spool’
Split the patch into contiguous patches at coordinate gaps.
Dimensional coordinates that are segmented (CoordSegmented, e.g. produced by concatenating nearly-contiguous data) mark where the patch is not contiguous. This splits the patch at every segment boundary so each output patch has a plain, contiguous coordinate.
Parameters
| Parameter | Description |
|---|---|
| self | The Patch object. |
| dim |
The dimension to split along. If None (default), split along every dimension with a segmented coordinate. Patches without segmented coordinates come back unchanged (as a length 1 spool). |