runtraj.concentration.describe_grid#

runtraj.concentration.describe_grid(ds, units, long_name)[source]#

Give a grid’s coordinates and variables their units and meanings, in place, and return it.

A transport model that makes concentration calls it on each grid it reads, so that every model’s grids say the same about the coordinates. What the variables hold depends on the model and its settings, so the model says it.

Parameters:
  • ds (Dataset) – A grid, with the coordinates of CONCENTRATION_DIMS and time_end.

  • units (str) – The units attribute of every variable.

  • long_name (str) – The long_name attribute of every variable, where {name} is the variable’s own name.

Return type:

Dataset

Examples

>>> import numpy as np
>>> ds = xr.Dataset(
...     {"TEST": (CONCENTRATION_DIMS, np.zeros((1, 1, 1, 1)))},
...     coords={
...         "time": [0],
...         "time_end": ("time", [0]),
...         "z": [100],
...         "lat": [40.0],
...         "lon": [-112.0],
...     },
... )
>>> describe_grid(ds, "mass m-3", "{name} concentration")["TEST"].attrs["long_name"]
'TEST concentration'