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_indices and tie_values) –

    tie_indicessequence of int

    Positions of the tie points. Must start at 0 and be strictly increasing.

    tie_valuessequence of float or datetime64

    Values 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
__init__(data=None, dim=None, dtype=None)[source]#

Methods

__init__([data, dim, dtype])

copy([deep])

Return a copy of this coordinate.

equals(other)

Return True if 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.

get_availabilities()

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 True if this coordinate is a dimensional coordinate.

isscalar()

Return True if this is a ScalarCoordinate.

simplify([tolerance])

Return a simplified copy of this coordinate with redundant tie points removed.

to_dataarray()

Convert this coordinate to a DataArray with a single dimension.

to_index(item[, method, endpoint])

Convert a label-based selector to an integer index or slice.

Attributes

dim

Name of the dimension this coordinate is associated with, or None.

dtype

NumPy dtype of the underlying coordinate values.

empty

True if the coordinate has zero length.

end

Value at the last element.

indices

Integer array [0, 1, ..., len(self) - 1].

name

The name under which this coordinate is stored in its parent container.

ndim

Number of dimensions (always 1 for dimensional coordinates).

parent

The parent Coordinates container, or None if unattached.

shape

Shape tuple (len(self),).

size

Number of elements along this coordinate's axis.

start

Value at index 0 (first element).

tie_indices

Integer array of tie-point positions (starts at 0, strictly increasing).

tie_values

Array of tie-point values (numeric or datetime64, strictly increasing).

values

Materialised numpy array of coordinate values.