Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cdo_sellonlat for extpar_aot_to_buffer.py #393

Open
wants to merge 3 commits into
base: port_aot_to_python
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions python/extpar_aot_to_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions python/lib/grid_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def __init__(self, gridfile):
self.lons = np.rad2deg(self.grid.variables["clon"][:])
self.lats = np.rad2deg(self.grid.variables["clat"][:])

def cdo_sellonlat(self):
def cdo_sellonlat(self, dlon=1.0, dlat=1.0):
'''
create the string for the cdo option "-sellonlatbox"

Expand All @@ -270,11 +270,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']},"
Expand Down
1 change: 0 additions & 1 deletion python/lib/namelist_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@
'raw_data_aot_filename': 'aot_GACP.nc',
'aot_buffer_file': 'aot_buffer.nc',
}