Skip to content

Commit

Permalink
Merge pull request #1221 from knutfrode/dev
Browse files Browse the repository at this point in the history
reader_netCDF_CF_generic: Removing unnecessary ensemble dimension for…
  • Loading branch information
knutfrode authored Feb 5, 2024
2 parents 84069a3 + dab71fb commit 8a1af32
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions opendrift/readers/reader_netCDF_CF_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ def __init__(self, filename=None, zarr_storage_options=None, name=None, proj4=No

self.variables = list(self.variable_mapping.keys())

# Workaround for datasets with unnecessary ensemble dimension for static variables
for vn, va in self.variable_mapping.items():
if vn == 'sea_floor_depth_below_sea_level':
var = self.Dataset.variables[va]
if 'ensemble_member' in var.dims:
logger.info(f'Removing ensemble dimension from {vn}')
var = var.isel(ensemble_member=0).squeeze()
self.Dataset[va] = var

# Run constructor of parent Reader class
super().__init__()

Expand Down

0 comments on commit 8a1af32

Please sign in to comment.