xarray.Dataset.bounds.add_bounds#

Dataset.bounds.add_bounds(axis, width=0.5)#

Add bounds for an axis using its coordinate points.

The coordinates must meet the following criteria in order to add bounds:

  1. The axis for the coordinates are “X”, “Y”, “T”, or “Z”

  2. Coordinates are a single dimension, not multidimensional

  3. Coordinates are a length > 1 (not singleton)

  4. 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 (CFAxisName) – The CF-compliant axis name (“X”, “Y”, “T”, “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.