xdas.coordinates.ScalarCoordinate#
- class xdas.coordinates.ScalarCoordinate(data=None, dim=None, dtype=None)[source]#
Non-dimensional coordinate that carries a single scalar value.
Unlike dimensional coordinates, a
ScalarCoordinateis not tied to an array axis and has no length. Typical use: metadata attached to aDataArray(e.g. an instrument identifier or a shot time).- Parameters:
data (scalar-like) – The scalar value. Cannot be
None.dim (must be
None) – Passing a non-Nonevalue raisesValueError.dtype (dtype-like, optional) – Cast data to this dtype.
Methods
__init__([data, dim, dtype])concat(other)Concatenate other coordinate to this one.
copy([deep])Return a copy of this coordinate.
equals(other)Return
Trueif other is aScalarCoordinatewith the same value.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
None— scalar coordinates have no sample spacing.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
True(this is aScalarCoordinate).isvalid(data)Return
Trueif data converts to a 0-d non-object numpy array.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 to
{"dim": None, "data": ..., "dtype": ...}.to_index(item[, method, endpoint])Not supported — raises
NotImplementedError.Attributes
dimAlways
None— scalar coordinates have no associated dimension.dtypeNumPy dtype of the underlying data array.
emptyTrueif the coordinate has zero length.nameThe name under which this coordinate is stored in its parent container.
ndimNumber of dimensions of the underlying data array (always 1 for dimensional coords).
parentThe parent
Coordinatescontainer, orNoneif unattached.shapeShape tuple of the underlying data array.
valuesMaterialised numpy array of coordinate values.