xrdantic.Coordinate#
- pydantic model xrdantic.Coordinate#
Base class for coordinate definitions.
A Coordinate represents a labeled array that provides coordinate values for one dimension. It must have exactly one data field with exactly one dimension.
Examples
>>> from xrdantic import Coordinate, Data, Name, Attr, Dim >>> import numpy as np
>>> X = Dim("x") >>> class XCoord(Coordinate): ... data: Data[X, int] ... name: Name ... units: Attr[str] = "length"
>>> x_coord = XCoord(data=np.arange(10), name="x") >>> dim_name, coord_array = x_coord.to_xarray_coord()
- Raises:
ValidationError – If the model doesn’t have exactly one data field:
ValidationError – If the data field doesn’t have exactly one dimension: