Skip to content

Commit

Permalink
Merge pull request #1336 from knutfrode/dev
Browse files Browse the repository at this point in the history
Hack in generic reader since ECMWF contains winds at several levels. …
  • Loading branch information
knutfrode authored Jun 27, 2024
2 parents 65d2ed0 + ff212b8 commit be490cd
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 be490cd

Please sign in to comment.