split_gaps

function of dascore.proc.coords source

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

Split the patch into contiguous patches.

The patch splits at every hole missing reports and where runs sharing no step change step or leave a gap; irregular labels sharing no step stay one piece. Two gapped dimensions give one piece per pair of stretches. Each output is a view of the patch’s data; a patch without holes comes back unchanged. A spool holds a patch with holes 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