xarray.Dataset.bounds.add_bounds#
- Dataset.bounds.add_bounds(axis)#
Add bounds for an axis using its coordinates as midpoints.
This method loops over the axis’s coordinate variables and attempts to add bounds for each of them if they don’t exist. Each coordinate point is the midpoint between their lower and upper bounds.
To add bounds for an axis its coordinates must meet the following criteria, otherwise an error is thrown:
Axis is either X”, “Y”, “T”, or “Z”
Coordinates are single dimensional, not multidimensional
Coordinates are a length > 1 (not singleton)
Bounds must not already exist
Coordinates are mapped to bounds using the “bounds” attr. For example, bounds exist if
ds.time.attrs["bounds"]
is set to"time_bnds"
andds.time_bnds
is present in the dataset.
- Parameters
axis (
CFAxisKey
) – The CF axis key (“X”, “Y”, “T”, “Z”).- Returns
xr.Dataset
– The dataset with bounds added.Raises