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:

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

  2. Coordinates are single dimensional, 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 (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.