forked from pism/pism-ais
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_cdo_targetgrids.py
executable file
·29 lines (22 loc) · 1.01 KB
/
create_cdo_targetgrids.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Create grids based on the ALBMAP dimensions, that are compatible with PISM.
That means, if they are fed into PISM, PISM will not need to regrid internally.
The here created grids are used as input for the cdo remapping, which is done
for each dataset separately. See for example bedmap2/remap.py
"""
import os, sys
import numpy as np
from pyproj import Proj
import netCDF4
## this hack is needed to import config.py from the project root
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path: sys.path.append(project_root)
import config as cf; reload(cf)
import pism_input.pism_input as pi; reload(pi)
if __name__ == "__main__":
for name, grid in cf.grids.iteritems():
#if "initmip" not in name: continue
# cdo_targetgrid_file = os.path.join(cf.cdo_remapgridpath,
# 'pism_'+str(int(resolution))+'km.nc')
gridfile = pi.create_grid_for_cdo_remap(cf.cdo_remapgridpath, name, grid)
pi.prepare_ncfile_for_cdo(gridfile)