xarray.Dataset.bounds.add_bounds#
- Dataset.bounds.add_bounds(axis, width=0.5)#
Add bounds for an axis using its coordinate points.
This method loops over the axis’s coordinate variables and attempts to add bounds for each of them if they don’t exist. The coordinates must meet the following criteria in order to add bounds:
The axis for the coordinates are “X”, “Y”, “T”, or “Z”
Coordinates are single dimensional, not multidimensional
Coordinates are a length > 1 (not singleton)
Bounds must not already exist. * Determined by attempting to map the coordinate variable’s “bounds” attr (if set) to the bounds data variable of the same key.
- Parameters:
axis (
CFAxisKey
) – The CF axis key (“X”, “Y”, “T”, or “Z”).width (
float
, optional) – Width of the bounds relative to the position of the nearest points, by default 0.5.
- Returns:
xr.Dataset
– The dataset with bounds added.- Raises:
ValueError – If bounds already exist. They must be dropped first.