Skip to content

Commit

Permalink
Hack in generic reader since ECMWF contains winds at several levels. …
Browse files Browse the repository at this point in the history
…A new format for reader-lists is needed.
  • Loading branch information
knutfrode committed Jun 27, 2024
1 parent 65d2ed0 commit ff212b8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions opendrift/readers/reader_netCDF_CF_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ def __init__(self, filename=None, zarr_storage_options=None, name=None, proj4=No
self.variable_mapping[standard_name] = str(var_name)
else:
skipvars.append(var_name)
# Necessary hack for ECMWF with winds at several levels
# TODO: must provide variable mapping along with URLs to create readers
if self.variable_mapping.get('x_wind') is not None:
if 'x_wind_200m' in self.Dataset.variables and 'x_wind_10m' in self.Dataset.variables:
logger.warning('Shifting variable names of ECMWF data, to get winds at 10m')
self.variable_mapping['x_wind'] = 'x_wind_10m'
self.variable_mapping['y_wind'] = 'y_wind_10m'
if self.dimensions.get('y') == 'latitude1' and 'latitude' in self.Dataset.variables:
self.dimensions['x'] = 'longitude'
self.dimensions['y'] = 'latitude'

if len(skipvars) > 0:
logger.debug('Skipped variables without standard_name: %s' % skipvars)
Expand Down

0 comments on commit ff212b8

Please sign in to comment.