xdas.coordinates.InterpCoordinate#
- class xdas.coordinates.InterpCoordinate(data=None, dim=None, dtype=None)[source]#
Piecewise-linear coordinate described by tie points (CF convention).
Values between tie points are recovered by linear interpolation. Discontinuities are represented by two consecutive tie points at adjacent indices. Supports label-based selection via
to_index().- Parameters:
data (dict with keys
tie_indicesandtie_values) –tie_indicessequence of intPositions of the tie points. Must start at 0 and be strictly increasing.
tie_valuessequence of float or datetime64Values at the tie points. Must be strictly increasing to enable label-based selection. Length must match
tie_indices.
dim (str, optional) – Name of the dimension this coordinate is associated with.
dtype (dtype-like, optional) – Desired dtype for
tie_values.
Examples
>>> import xdas as xd >>> coord = xd.Coordinate( ... {"tie_indices": [0, 9, 10, 19], "tie_values": [0.0, 90.0, 200.0, 290.0]} ... ) >>> coord 0.000 to 290.000
Methods
__init__([data, dim, dtype])copy([deep])Return a copy of this coordinate.
equals(other)Return
Trueif other is the same coordinate type with identical dim and data.from_block(start, size, step[, dim, dtype])Construct a coordinate from a start value, element count, and step size.
Return a DataFrame containing information about the data availability.
get_discontinuities([tolerance])Return a DataFrame containing information about the discontinuities.
get_sampling_interval([cast])Return the nominal sample spacing for this coordinate.
get_split_indices([kind, tolerance])Return integer indices where this coordinate should be split.
isdim()Return
Trueif this coordinate is a dimensional coordinate.isscalar()Return
Trueif this is aScalarCoordinate.simplify([tolerance])Return a simplified copy of this coordinate with redundant tie points removed.
to_dataarray()Convert this coordinate to a
DataArraywith a single dimension.to_index(item[, method, endpoint])Convert a label-based selector to an integer index or slice.
Attributes
dimName of the dimension this coordinate is associated with, or
None.dtypeNumPy dtype of the underlying coordinate values.
emptyTrueif the coordinate has zero length.endValue at the last element.
indicesInteger array
[0, 1, ..., len(self) - 1].nameThe name under which this coordinate is stored in its parent container.
ndimNumber of dimensions (always 1 for dimensional coordinates).
parentThe parent
Coordinatescontainer, orNoneif unattached.shapeShape tuple
(len(self),).sizeNumber of elements along this coordinate's axis.
startValue at index 0 (first element).
Integer array of tie-point positions (starts at 0, strictly increasing).
Array of tie-point values (numeric or datetime64, strictly increasing).
valuesMaterialised numpy array of coordinate values.