opendrift
opendrift copied to clipboard
CROCO Cs_r KeyError
Hi All,
I got into a KeyError when using reader_ROMS_native (OpenDrift v.1.14.2) with some CROCO files. It seems that ROMS uses Cs_r for the vertical coordinate, while in CROCO (v.2) this variable is called Cs_rho.
In case this is useful for others, this was the solution:
- Add 'Cs_rho' to
drop_non_essential_vars_pop
dropvars = [v for v in ds.variables if v not in
list(self.ROMS_variable_mapping.keys()) + gls_param +
['ocean_time', 'time', 'bulk_time', 's_rho',
'Cs_r', 'Cs_rho', 'hc', 'angle', 'Vtransform']
- Add a KeyError Exception under
# Read sigma-coordinate transform parameters:
try:
self.Cs_r = self.Dataset.variables['Cs_r'][:]
except KeyError:
self.Cs_r = self.Dataset.variables['Cs_rho'][:] # CROCO
Thanks, Diego