xdas.coordinates.SampledCoordinate#

class xdas.coordinates.SampledCoordinate(data=None, dim=None, dtype=None)[source]#

Coordinate sampled at a fixed interval, with optional gaps between segments.

More compact and numerically stable than InterpCoordinate for strictly uniform grids. Each contiguous block is described by its start value and element count; all blocks share the same sampling_interval.

Parameters:
  • data (dict with keys tie_values, tie_lengths, and sampling_interval) –

    tie_valuessequence of float or datetime64

    Start value of each segment.

    tie_lengthssequence of int

    Number of samples in each segment. All values must be > 0.

    sampling_intervalscalar

    Fixed step between consecutive samples, shared across all segments. Must be numpy.timedelta64 when tie_values are numpy.datetime64.

  • dim (str, optional) – Name of the dimension this coordinate is associated with.

  • dtype (dtype-like, optional) – Desired dtype for tie_values.

Examples

>>> import numpy as np
>>> from xdas.coordinates import SampledCoordinate
>>> coord = SampledCoordinate(
...     {
...         "tie_values": [np.datetime64("2024-01-01T00:00:00", "ms")],
...         "tie_lengths": [1000],
...         "sampling_interval": np.timedelta64(4, "ms"),
...     }
... )
>>> coord
2024-01-01T00:00:00.000 to 2024-01-01T00:00:03.996
__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.

sampling_interval

Fixed step between consecutive samples (shared across all segments).

shape

Shape tuple (len(self),).

size

Number of elements along this coordinate's axis.

start

Value at index 0 (first element).

tie_indices

Start integer index of each segment within the full coordinate array.

tie_lengths

Number of samples in each regularly-sampled segment.

tie_values

Start values of each regularly-sampled segment.

values

Materialised numpy array of coordinate values.