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)
| 261 | |
| 262 | |
| 263 | def _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 | |
| 291 | def _update_bounds_encoding(variables: T_Variables) -> None: |
searching dependent graphs…