add_feature

method of dascore.core.annotations.AnnotationSet source

add_feature(
    self ,
    id: str ,
    kind: Literal[‘group’, ‘path’, ‘polygon’] = group,
    basis = None,
    members = None,
    **columns ,
)-> ‘AnnotationSet’

Return a set with one more feature.

Parameters

Parameter Description
id The new feature’s id.
kind group, path or polygon.
basis A path’s curve, as a model or its document, stored under id;
or the key of a curve the set already holds.
members Existing rows to adopt, as a boolean mask over annotations or
a sequence of annotation ids. Each must belong to no feature. A
path or polygon takes their order from the mask or the ids.
**columns An array-like (list, tuple, array, Series) is an annotations
column of new member rows, all one length; seq, part and
ring may be among them. Anything else is a features column.
New rows and members are not given together.

Examples

import dascore as dc
empty = dc.AnnotationSet(dims=("time", "distance"))
event = empty.add_feature(
    "event_1", time=[1.0, 1.5], phase=["P", "S"], magnitude=2.1
)
event["event_1"].extra["magnitude"], len(event.annotations)
(2.1, 2)