diff --git a/python/extpar_era_to_buffer.py b/python/extpar_era_to_buffer.py index dc5eb59a4..08c28a8ef 100755 --- a/python/extpar_era_to_buffer.py +++ b/python/extpar_era_to_buffer.py @@ -144,8 +144,13 @@ logging.info('') # calculate weights -utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, f'genycon,{grid}', - tg.cdo_sellonlat(), raw_data_sst, weights) +era_5_resolution = 31.0 # approximate ERA5 resolution [km] +if (tg.resolution < era_5_resolution): + utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, f'genbil,{grid}', + tg.cdo_sellonlat(), raw_data_sst, weights) +else: + utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, f'genycon,{grid}', + tg.cdo_sellonlat(), raw_data_sst, weights) # regrid SST utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, diff --git a/python/lib/grid_def.py b/python/lib/grid_def.py index a1c9aec4a..36d8b8db5 100644 --- a/python/lib/grid_def.py +++ b/python/lib/grid_def.py @@ -72,6 +72,9 @@ def __init__(self, namelist): self.lats, self.lons = self.latlon_cosmo_to_latlon_regular() + self.resolution = ( + (2.0 * np.pi * 6.371229 * 10**3) / 360.0 * self.dlon) # [km] + def create_grid_description(self, name): ''' write grid description required for cdo @@ -263,6 +266,9 @@ def __init__(self, gridfile): self.vlons = np.rad2deg(self.grid.variables["vlon"][:]) self.vlats = np.rad2deg(self.grid.variables["vlat"][:]) + self.resolution = ( + 5050.0 / (self.grid.grid_root * 2**self.grid.grid_level)) # [km] + def cdo_sellonlat(self, dlon=1.0, dlat=1.0): ''' create the string for the cdo option "-sellonlatbox"