split_gaps

function of dascore.proc.coords source

split_gaps(
    self: Patch ,
)-> ‘dc.Spool’

Split the patch into contiguous patches.

The patch splits between its coordinates’ segments; one list of irregular labels stays one piece. Two dimensions of several segments give one piece per pair of segments. Each output is a view of the patch’s data; a patch without gaps comes back unchanged. A spool holds a patch with gaps whole, so this is the one way to split it.

Parameters

Parameter Description
self The Patch object.

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