xdas.coordinates.Coordinate#
- class xdas.coordinates.Coordinate(data=None, dim=None, dtype=None)[source]#
Base class and factory for all coordinate types.
When called as
Coordinate(data), acts as a factory and returns the first registered subclass whoseisvalid()method accepts data. When subclassed, use thename=keyword in the class definition to register the subclass (e.g.class MyCoord(Coordinate, name="mycoord")).Concrete subclasses must implement
isvalid(),equals(), andto_dict()at minimum.- Parameters:
data (array-like or mapping) – The coordinate data. Interpretation is subclass-specific.
dim (str, optional) – Name of the dimension this coordinate is associated with.
dtype (dtype-like, optional) – Desired dtype for the underlying data array.
- __init__()#
Methods
__init__()concat(other)Concatenate other coordinate to this one.
copy([deep])Return a copy of this coordinate.
equals(other)Return
Trueif other represents the same coordinate values.format_index(idx[, bounds])Normalise integer index idx, handling negative indices and optional bounds checking.
from_block(start, size, step[, dim, dtype])Construct a coordinate from a start value, element count, and step size.
from_dataset(dataset, name)Read coordinates named name from an xarray dataset via each registered subclass.
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_sampling_interval([cast])Return the average sample spacing (end-to-end distance divided by N-1).
get_split_indices([kind, tolerance])Return integer indices where this coordinate should be split.
is_monotonic_increasing()Return
Trueif all consecutive differences in this coordinate are positive.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
Trueif this is anInterpCoordinate(piecewise-linear).issampled()Return
Trueif this is aSampledCoordinate(regularly sampled).isscalar()Return
Trueif this is aScalarCoordinate(non-dimensional).isvalid(data)Return
Trueif data is a valid input for this coordinate subclass.simplify([tolerance])Reduce tie-point count within tolerance.
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 this coordinate into an xarray dataset, updating attrs in place.
to_dict()Serialise this coordinate to a plain-dict representation.
to_index(item[, method, endpoint])Convert a label-based selector to an integer index or slice.
Attributes
NumPy dtype of the underlying data array.
emptyTrueif the coordinate has zero length.nameThe name under which this coordinate is stored in its parent container.
Number of dimensions of the underlying data array (always 1 for dimensional coords).
parentThe parent
Coordinatescontainer, orNoneif unattached.Shape tuple of the underlying data array.
Materialised numpy array of coordinate values.