import pandas as pd
import dascore as dc
spool = dc.get_example_spool()
start = spool.get_contents()["time_min"].min()
frame = pd.DataFrame({"time": [start + pd.Timedelta("10s")]})
picks = dc.AnnotationSet(frame, dims=("distance", "time"))
cut = spool.cut(picks, time=("-1s", "3s"))
assert len(cut) == 1cut
cut(
self ,
annotations: AnnotationSet ,
**pads ,
)-> ‘Self’
Return one lazy patch per feature of an annotation set.
Each feature, lone rows included, is cut to its bounds (see AnnotationSet.bounds) and merged across source patches along every dimension, as chunk merges, so a gap still leaves several patches. Selection includes both ends, so the sample at a range’s (half-open) maximum is kept; an empty range gives nothing. A feature spanning a dimension keeps the spool’s full extent along it, one holding no samples gives nothing, and overlapping features duplicate data. On a coordinate with no fixed step, a window between samples may yield an empty patch. Nothing is loaded.
Each output states feature_id (blank for a lone row) and annotation (a lone row’s index label, blank for a feature), as attrs and as get_contents columns, which join back to the set.
Parameters
| Parameter | Description |
|---|---|
| annotations | The set to cut by. |
| **pads |
dim=(before, after): offsets added to a feature’s ends alongdim which are stated values, before (usually negative) toits minimum and after to its maximum; range ends are kept. Afeature at a single value needs one. Time offsets are timedeltas, strings with units such as “-1s”, or seconds. |