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 whose isvalid() method accepts data. When subclassed, use the name= keyword in the class definition to register the subclass (e.g. class MyCoord(Coordinate, name="mycoord")).

Concrete subclasses must implement isvalid(), equals(), and to_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 True if 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 True if all consecutive differences in this coordinate are positive.

isdefault()

Return True if this is a DefaultCoordinate (integer range).

isdense()

Return True if this is a DenseCoordinate (explicit numpy array).

isdim()

Return True if this coordinate is a dimensional coordinate in its parent container.

isinterp()

Return True if this is an InterpCoordinate (piecewise-linear).

issampled()

Return True if this is a SampledCoordinate (regularly sampled).

isscalar()

Return True if this is a ScalarCoordinate (non-dimensional).

isvalid(data)

Return True if 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 slice corresponding to the label range [start, stop].

to_dataarray()

Convert this coordinate to a DataArray with 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

dtype

NumPy dtype of the underlying data array.

empty

True if the coordinate has zero length.

name

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

ndim

Number of dimensions of the underlying data array (always 1 for dimensional coords).

parent

The parent Coordinates container, or None if unattached.

shape

Shape tuple of the underlying data array.

values

Materialised numpy array of coordinate values.