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
ds.time_bndsis present in the dataset.
CFAxisKey) – The CF axis key (“X”, “Y”, “T”, “Z”).
xr.Dataset– The dataset with bounds added.