diff --git a/python/extpar_aot_to_buffer.py b/python/extpar_aot_to_buffer.py index e141b413..6edc9bf3 100755 --- a/python/extpar_aot_to_buffer.py +++ b/python/extpar_aot_to_buffer.py @@ -123,14 +123,21 @@ logging.info('============= CDO: remap to target grid ========') logging.info('') +# Compute longitude and latitude resolution of the raw dataset +raw_data_aot_nc = nc.Dataset(raw_data_aot, "r") +lon = raw_data_aot_nc.variables['lon'] +lat = raw_data_aot_nc.variables['lat'] +dlon = lon[1] - lon[0] +dlat = lat[1] - lat[0] + # calculate weights utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, f'genbil,{grid}', - raw_data_aot, weights) + tg.cdo_sellonlat(dlon, dlat), raw_data_aot, weights) # regrid aot utils.launch_shell('cdo', '-f', 'nc4', lock, '-P', omp, f'settaxis,1111-01-01,0,1mo', f'-remap,{grid},{weights}', - raw_data_aot, aot_cdo) + tg.cdo_sellonlat(dlon, dlat), raw_data_aot, aot_cdo) #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- diff --git a/python/lib/grid_def.py b/python/lib/grid_def.py index 2eb48256..a1c9aec4 100644 --- a/python/lib/grid_def.py +++ b/python/lib/grid_def.py @@ -213,7 +213,7 @@ def phirot2phi(self, phirot, rlarot, polphi, pollam): return phi - def cdo_sellonlat(self): + def cdo_sellonlat(self, dlon=1.0, dlat=1.0): ''' create the string for the cdo option "-sellonlatbox" @@ -223,11 +223,11 @@ def cdo_sellonlat(self): ''' extent = {} - extent['maxlon'] = min(math.ceil(np.amax(self.lons) + 1), 180.0) - extent['minlon'] = max(math.floor(np.amin(self.lons) - 1), -180.0) + extent['maxlon'] = min(math.ceil(np.amax(self.lons) + dlon), 180.0) + extent['minlon'] = max(math.floor(np.amin(self.lons) - dlon), -180.0) - extent['maxlat'] = min(math.ceil(np.amax(self.lats) + 1), 90.0) - extent['minlat'] = max(math.floor(np.amin(self.lats) - 1), -90.0) + extent['maxlat'] = min(math.ceil(np.amax(self.lats) + dlat), 90.0) + extent['minlat'] = max(math.floor(np.amin(self.lats) - dlat), -90.0) cdo_selbox = ('-sellonlatbox,' f"{extent['minlon']}," @@ -263,7 +263,7 @@ def __init__(self, gridfile): self.vlons = np.rad2deg(self.grid.variables["vlon"][:]) self.vlats = np.rad2deg(self.grid.variables["vlat"][:]) - def cdo_sellonlat(self): + def cdo_sellonlat(self, dlon=1.0, dlat=1.0): ''' create the string for the cdo option "-sellonlatbox" @@ -273,11 +273,11 @@ def cdo_sellonlat(self): ''' extent = {} - extent['maxlon'] = min(math.ceil(np.amax(self.lons) + 1), 180.0) - extent['minlon'] = max(math.floor(np.amin(self.lons) - 1), -180.0) + extent['maxlon'] = min(math.ceil(np.amax(self.lons) + dlon), 180.0) + extent['minlon'] = max(math.floor(np.amin(self.lons) - dlon), -180.0) - extent['maxlat'] = min(math.ceil(np.amax(self.lats) + 1), 90.0) - extent['minlat'] = max(math.floor(np.amin(self.lats) - 1), -90.0) + extent['maxlat'] = min(math.ceil(np.amax(self.lats) + dlat), 90.0) + extent['minlat'] = max(math.floor(np.amin(self.lats) - dlat), -90.0) cdo_selbox = ('-sellonlatbox,' f"{extent['minlon']},"