import numpy as np
from dascore.core.coords import CoordSegmented
values = np.array([0.0, 1, 2, 3, 10, 11, 12, 13])
coord = CoordSegmented.from_array(values)
assert coord.segment_count == 2
assert len(coord.get_discontinuities("gaps")) == 1from_array
from_array(
array ,
tolerance = None,
units = None,
)-> ‘BaseCoord’
Build a coordinate from a monotonic array, detecting uniform runs.
Values are preserved exactly; each maximal evenly sampled run becomes an evenly sampled segment and each internal sampling break becomes a segment boundary, so gaps inside the array are queryable via get_discontinuities. Fully uniform arrays come back as a plain CoordRange and arrays with no detectable runs as a plain monotonic coordinate.
Parameters
| Parameter | Description |
|---|---|
| array |
A strictly monotonic 1D array (numeric, datetime64, or timedelta64) with no missing values. |
| tolerance |
If not None, applysimplify with thistolerance to the result, re-fitting jittery runs and absorbing small gaps with bounded error. |
| units | Units for the coordinate. |