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
InterpCoordinatefor strictly uniform grids. Each contiguous block is described by its start value and element count; all blocks share the samesampling_interval.- Parameters:
data (dict with keys
tie_values,tie_lengths, andsampling_interval) –tie_valuessequence of float or datetime64Start value of each segment.
tie_lengthssequence of intNumber of samples in each segment. All values must be > 0.
sampling_intervalscalarFixed step between consecutive samples, shared across all segments. Must be
numpy.timedelta64whentie_valuesarenumpy.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
Methods
__init__([data, dim, dtype])copy([deep])Return a copy of this coordinate.
equals(other)Return
Trueif 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.
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
Trueif this coordinate is a dimensional coordinate.isscalar()Return
Trueif this is aScalarCoordinate.simplify([tolerance])Return a simplified copy of this coordinate with redundant tie points removed.
to_dataarray()Convert this coordinate to a
DataArraywith a single dimension.to_index(item[, method, endpoint])Convert a label-based selector to an integer index or slice.
Attributes
dimName of the dimension this coordinate is associated with, or
None.dtypeNumPy dtype of the underlying coordinate values.
emptyTrueif the coordinate has zero length.endValue at the last element.
indicesInteger array
[0, 1, ..., len(self) - 1].nameThe name under which this coordinate is stored in its parent container.
ndimNumber of dimensions (always 1 for dimensional coordinates).
parentThe parent
Coordinatescontainer, orNoneif unattached.Fixed step between consecutive samples (shared across all segments).
shapeShape tuple
(len(self),).sizeNumber of elements along this coordinate's axis.
startValue at index 0 (first element).
Start integer index of each segment within the full coordinate array.
Number of samples in each regularly-sampled segment.
Start values of each regularly-sampled segment.
valuesMaterialised numpy array of coordinate values.