You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default value of metric_vector_pairs in faces_dataset_to_latlon is metric_vector_pairs=[('dxC', 'dyC'), ('dyG', 'dxG')]. The function errors if I call it on a dataset that doesn't have these variables present.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/Code/xarray/xarray/core/dataset.py in _construct_dataarray(self, name)
975 try:
--> 976 variable = self._variables[name]
977 except KeyError:
KeyError: 'dxC'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-11-dc713ebaf709> in <module>()
1 ds = xr.merge([sst, u, v])
----> 2 ds = llcreader.llcmodel.faces_dataset_to_latlon(ds)#, metric_vector_pairs=[])
3 ds
~/Code/xmitgcm/xmitgcm/llcreader/llcmodel.py in faces_dataset_to_latlon(ds, metric_vector_pairs)
289 data_vars[vname_v] = xr.Variable(_drop_facedim(ds[vname_v].dims), data_v, ds[vname_v].attrs)
290 for vname_u, vname_v in metric_vector_pairs:
--> 291 data_u, data_v = _faces_to_latlon_vector(ds[vname_u].data, ds[vname_v].data, metric=True)
292 data_vars[vname_u] = xr.Variable(_drop_facedim(ds[vname_u].dims), data_u, ds[vname_u].attrs)
293 data_vars[vname_v] = xr.Variable(_drop_facedim(ds[vname_v].dims), data_v, ds[vname_v].attrs)
~/Code/xarray/xarray/core/dataset.py in __getitem__(self, key)
1056
1057 if hashable(key):
-> 1058 return self._construct_dataarray(key)
1059 else:
1060 return self._copy_listed(np.asarray(key))
~/Code/xarray/xarray/core/dataset.py in _construct_dataarray(self, name)
977 except KeyError:
978 _, name, variable = _get_virtual_variable(
--> 979 self._variables, name, self._level_coords, self.dims)
980
981 needed_dims = set(variable.dims)
~/Code/xarray/xarray/core/dataset.py in _get_virtual_variable(variables, key, level_vars, dim_sizes)
80 ref_var = dim_var.to_index_variable().get_level_variable(ref_name)
81 else:
---> 82 ref_var = variables[ref_name]
83
84 if var_name is None:
KeyError: 'dxC'
Workaround for now is to just pass metric_vector_pairs=[], but this is obviously a bug.
The text was updated successfully, but these errors were encountered:
The default value of
metric_vector_pairs
infaces_dataset_to_latlon
ismetric_vector_pairs=[('dxC', 'dyC'), ('dyG', 'dxG')]
. The function errors if I call it on a dataset that doesn't have these variables present.Workaround for now is to just pass
metric_vector_pairs=[]
, but this is obviously a bug.The text was updated successfully, but these errors were encountered: