Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _make_layers_variables(layer_name):
"""Translate metadata template to actual variable metadata."""
from .variables import layers_grid_variables
lvars = xr.core.pycompat.OrderedDict()
layer_num = layer_name[0]
# should always be int
assert isinstance(int(layer_num), int)
layer_id = 'l' + layer_num
for key, vals in layers_grid_variables.items():
# replace the name template with the actual name
# e.g. layer_NAME_bounds -> layer_1RHO_bounds
varname = key.replace('NAME', layer_name)
metadata = _recursively_replace(vals, 'NAME', layer_name)
# now fix dimension
metadata['dims'] = [metadata['dims'][0].replace('l', layer_id)]
lvars[varname] = metadata
return lvars