Dataset.cf.bounds_to_vertices(keys=None, order='counterclockwise')#

Convert bounds variable to vertices.

There 2 covered cases:
  • 1D coordinates, with bounds of shape (N, 2), converted to vertices of shape (N+1,)

  • 2D coordinates, with bounds of shape (N, M, 4). converted to vertices of shape (N+1, M+1).

keysstr or Iterable[str], optional

The names of the variables whose bounds are to be converted to vertices. If not given, converts all available bounds within self.cf.keys().

order{‘counterclockwise’, ‘clockwise’, None}

Valid for 2D coordinates only (bounds of shape (N, M, 4), ignored otherwise. Order the bounds are given in, assuming that ax0-ax1-upward is a right handed coordinate system, where ax0 and ax1 are the two first dimensions of the variable. If None, the counterclockwise version is computed and then verified. If the check fails the clockwise version is returned.


Copy of the dataset with added vertices variables. Either of shape (N+1,) or (N+1, M+1). New vertex dimensions are named from the initial dimension and suffix “_vertices”. Variables with similar names are overwritten.


If any of the keys given doesn’t corresponds to existing bounds.


Getting the correct axes “order” is tricky. There are no real standards for dimension names or even axes order, even though the CF conventions mentions the ax0-ax1-upward (counterclockwise bounds) as being the default. Moreover, xarray can tranpose data without raising any warning or error, which make attributes unreliable.


Please refer to the CF conventions document : http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#cell-boundaries.