xdas.coordinates.InterpCoordinate#
- class xdas.coordinates.InterpCoordinate(data=None, dim=None, dtype=None)[source]#
Array-like object representing piecewise evenly spaced coordinates (CF convention).
The coordinate ticks are described by tie points that are interpolated when intermediate values are required. Coordinate objects provide label-based selection methods.
- Parameters:
tie_indices (sequence of integers) – The indices of the tie points. Must include index 0 and be strictly increasing.
tie_values (sequence of float or datetime64) – The values of the tie points. Must be strictly increasing to enable label-based selection. The len of tie_indices and tie_values sizes must match.
Methods
__init__([data, dim, dtype])concat(other)Append other
InterpCoordinateafter this one, shifting its tie indices.copy([deep])Return a copy of this coordinate.
decimate(q)Return a new coordinate keeping every q-th sample (integer decimation).
equals(other)Return
Trueif other has identical tie points, dim, and dtype.format_index(idx[, bounds])Normalise integer index idx, handling negative indices and optional bounds checking.
from_array(arr[, dim, tolerance])Build an
InterpCoordinatefrom a full array arr, optionally simplified.from_block(start, size, step[, dim, dtype])Build a two-point
InterpCoordinatecovering [start, start + step*(size-1)].from_dataset(dataset, name)Read interpolated coordinates from dataset using the
coordinate_interpolationattribute.from_dict(dct)Reconstruct a coordinate from the dict returned by
to_dict().get_availabilities()Return a DataFrame containing information about the data availability.
get_discontinuities([tolerance])Return a DataFrame containing information about the discontinuities.
get_indexer(value[, method])Return the integer index for a label value via inverse interpolation.
get_sampling_interval([cast])Return the median sample spacing across all tie-point segments.
get_split_indices([kind, tolerance])Return tie-point indices where consecutive segments are discontinuous.
get_value(index)Interpolate coordinate values at integer position(s) index.
is_monotonic_increasing()Return
Trueif no segment starts before the end of the previous one.isdefault()Return
Trueif this is aDefaultCoordinate(integer range).isdense()Return
Trueif this is aDenseCoordinate(explicit numpy array).isdim()Return
Trueif this coordinate is a dimensional coordinate in its parent container.isinterp()Return
True(this is anInterpCoordinate).issampled()Return
Trueif this is aSampledCoordinate(regularly sampled).isscalar()Return
Trueif this is aScalarCoordinate(non-dimensional).isvalid(data)Return
Trueif data is a dict withtie_indicesandtie_valueskeys.simplify([tolerance])Reduce the number of tie points using the Douglas-Peucker algorithm.
slice_index(index_slice)Return a new
InterpCoordinatefor the integer slice index_slice.slice_indexer([start, stop, step, endpoint])Return an integer
slicecorresponding to the label range [start, stop].to_dataarray()Convert this coordinate to a
DataArraywith a single dimension.to_dataset(dataset, attrs)Write tie points into an xarray dataset using CF coordinate interpolation conventions.
to_dict()Serialise to
{"dim": ..., "data": {"tie_indices": ..., "tie_values": ...}, "dtype": ...}.to_index(item[, method, endpoint])Convert a label-based selector to an integer index or slice.
Attributes
Dtype of the tie values (and of all materialised coordinate values).
Trueif no tie points have been set.Full integer index array from 0 to the last tie-point index (inclusive).
nameThe name under which this coordinate is stored in its parent container.
Always 1.
parentThe parent
Coordinatescontainer, orNoneif unattached.Shape tuple
(len(self),).Integer array of tie-point positions (starts at 0, strictly increasing).
Array of tie-point values (numeric or datetime64, strictly increasing).
Materialised numpy array of all coordinate values via piecewise interpolation.