split_gaps

function of dascore.proc.coords source

split_gaps(
    self: Patch ,
    dim: str | None[str, None] = None,
)-> ‘dc.Spool’

Split the patch into contiguous patches at coordinate gaps.

The patch splits wherever its coordinate’s runs break (e.g. from concatenating nearly-contiguous data) and at every hole missing reports, however the labels are stored. Each output is a view of the patch’s data.

Parameters

Parameter Description
self The Patch object.
dim The dimension to split along. If None (default), split along every
dimension. A patch with no holes comes back unchanged (as a length 1
spool).

Examples

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) == 2