xdas.coordinates.SampledCoordinate#
- class xdas.coordinates.SampledCoordinate(data=None, dim=None, dtype=None)[source]#
A coordinate that is sampled at regular intervals.
- Parameters:
data (dict-like) – The data of the coordinate.
dim (str, optional) – The dimension name of the coordinate, by default None.
dtype (str or numpy.dtype, optional) – The data type of the coordinate, by default None.
Methods
__init__([data, dim, dtype])concat(other)Append other
SampledCoordinatesegments after this one.copy([deep])Return a copy of this coordinate.
decimate(q)Return a new coordinate keeping every q-th sample (integer decimation).
equals(other)Return
Trueif other has identical tie values, lengths, sampling interval, dim, and dtype.format_index(idx[, bounds])Normalise integer index idx, handling negative indices and optional bounds checking.
from_array(arr[, dim, sampling_interval])Not supported — raises
NotImplementedError.from_block(start, size, step[, dim, dtype])Build a single-segment
SampledCoordinatestarting at start with size samples and step step.from_dataset(dataset, name)Read sampled coordinates from dataset using the
coordinate_samplingattribute.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_indexer(value[, method])Return the integer index for label value using the segment structure.
get_sampling_interval([cast])Return the sampling interval.
get_split_indices([kind, tolerance])Return integer indices of segment boundaries (start of each segment except the first).
get_value(index)Compute coordinate value(s) at integer position(s) index using the stored segments.
is_monotonic_increasing()Return
Trueif no segment starts before the end of the previous one.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
True(this is aSampledCoordinate).isscalar()Return
Trueif this is aScalarCoordinate(non-dimensional).isvalid(data)Return
Trueif data hastie_values,tie_lengths, andsampling_intervalkeys.simplify([tolerance])Merge adjacent segments whose gap is within tolerance of the sampling interval.
slice_index(index_slice)Return a new
SampledCoordinatefor the integer slice index_slice.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 sampling metadata into an xarray dataset using CF tie-point conventions.
to_dict()Serialise to
{"dim": ..., "data": {"tie_values": ..., "tie_lengths": ..., "sampling_interval": ...}, "dtype": ...}.to_index(item[, method, endpoint])Convert a label-based selector to an integer index or slice.
Attributes
Dtype of the tie values (and of all materialised coordinate values).
Trueif no segments have been set.endValue one step past the last sample (exclusive upper bound).
Full integer index array from 0 to
len(self) - 1.nameThe name under which this coordinate is stored in its parent container.
Always 1.
parentThe parent
Coordinatescontainer, orNoneif unattached.Fixed step between consecutive samples (shared across all segments).
Shape tuple
(len(self),).startValue at index 0 (first tie value).
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.
Materialised numpy array of all coordinate values.