MCPcopy
hub / github.com/pydata/xarray / _update_bounds_attributes

Function _update_bounds_attributes

xarray/conventions.py:263–288  ·  view source on GitHub ↗

Adds time attributes to time bounds variables. Variables handling time bounds ("Cell boundaries" in the CF conventions) do not necessarily carry the necessary attributes to be decoded. This copies the attributes from the time variable to the associated boundaries. See Also:

(variables: T_Variables)

Source from the content-addressed store, hash-verified

261
262
263def _update_bounds_attributes(variables: T_Variables) -> None:
264 """Adds time attributes to time bounds variables.
265
266 Variables handling time bounds ("Cell boundaries" in the CF
267 conventions) do not necessarily carry the necessary attributes to be
268 decoded. This copies the attributes from the time variable to the
269 associated boundaries.
270
271 See Also:
272
273 http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/
274 cf-conventions.html#cell-boundaries
275
276 https://github.com/pydata/xarray/issues/2565
277 """
278
279 # For all time variables with bounds
280 for v in variables.values():
281 attrs = v.attrs
282 units = attrs.get("units")
283 has_date_units = isinstance(units, str) and "since" in units
284 if has_date_units and "bounds" in attrs and attrs["bounds"] in variables:
285 bounds_attrs = variables[attrs["bounds"]].attrs
286 bounds_attrs.setdefault("units", attrs["units"])
287 if "calendar" in attrs:
288 bounds_attrs.setdefault("calendar", attrs["calendar"])
289
290
291def _update_bounds_encoding(variables: T_Variables) -> None:

Callers 2

decode_cf_variablesFunction · 0.85

Calls 2

valuesMethod · 0.45
getMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…