import dascore as dc
from dascore.core.coords import concat_coords, get_coord
# One evenly sampled run.
coord = get_coord(start=0.0, stop=10.0, step=1.0)
assert coord.runs_count == 1 and coord.evenly_sampled
# Two runs separated by a gap.
other = get_coord(start=15.0, stop=25.0, step=1.0)
gappy = concat_coords(coord, other)
assert gappy.runs_count == 2 and gappy.missing().count == 5
# Runs which continue exactly fuse back into one.
assert concat_coords(coord, get_coord(start=10.0, stop=20.0, step=1.0)) == get_coord(start=0.0, stop=20.0, step=1.0)NumericCoord
NumericCoord(
units: pint.registry.Quantity | str | None[Quantity, str, None] = None,
step: Any = None,
shape: tuple[int, …] = (),
dtype: Any = ““,
runs: tuple[dascore.core.coords.Grid | dascore.core.coords.Labels[Grid, Labels], …] ,
sources: collections.abc.Mapping[str, ndarray] = <FrozenDict {}>,
)-> None
A coordinate whose labels are held as an ordered sequence of runs.
A run is either a Grid, which states an evenly sampled stretch in a handful of numbers, or Labels, which stores them. One grid is the evenly sampled case and answers every question by arithmetic; one stored run is an arbitrary (or N-dimensional) array; several runs are a coordinate with holes in it, where each boundary records a break in sampling without changing any label.
Coordinates are normally built with get_coord rather than directly.
Examples
Methods
| Name | Description |
|---|---|
| align_to | Align the coordinate to another coordinate. |
| approx_equal | Return True if the coordinates are approximately equal. |
| change_length | Adjust the length of the coordinate by changing the end value. |
| convert_units | Convert from one unit to another. Set units if None are set. |
| coord_range | The span of the coordinate; extended, to its exclusive end. |
| empty | Empty out the coordinate. |
| fuse | Return the simplest coordinate representing the same values. |
| get_discontinuities | Return a dataframe describing discontinuities in the coordinate. |
| get_next_index | Get the index a value would have in a coordinate. |
| get_sample_count | Return the number of samples represented by a value. |
| index |
Index the coordinate; a slice keeps the runs, as coord[slice] does.
|
| max | Return max value. |
| min | Return min value. |
| missing | The grid positions between the first and last sample with no sample. |
| model_copy | Copy the model, dropping cached values the update invalidates. |
| new | Update coordinate; the runs are kept unless the labels change. |
| order | Order coordinate according to array values or samples. |
| reduce_coord | Get a reduced coordinate. |
| from_labels | Build a coordinate holding these labels exactly, as one stored run. |
| select | Apply select, return selected coords and index for selecting data. |
| set_units | Set new units on the coordinate. |
| simplify_units | Simplify the coordinate units. |
| snap | Snap the coordinates to evenly sampled grid points. |
| sort | Sort the contents of the coord. Return new coord and slice for sorting. |
| to_summary | Get the summary info about the coord, exact grid and runs included. |
| update | Update parts of the coordinate. |
| update_limits | Update the limits or sampling of the coordinates. |