Skip to content

Commit

Permalink
Updates to tools/python/025gridGeneration
Browse files Browse the repository at this point in the history
using latest version of MIDAS. Does not change answers.
  • Loading branch information
MJHarrison-GFDL committed Oct 2, 2014
1 parent dabfdd5 commit d2ce721
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 43 deletions.
23 changes: 7 additions & 16 deletions tools/python/025gridGeneration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ scap_topog_gebco.nc so_topog_gebco.nc: mercator_supergrid.nc ncap_supergrid.nc a

# Sets char tile='tile1'
ocean_hgrid.nc: supergrid.nc
ncks -h -d ny,80, -d nyp,80, supergrid.nc ocean_hgrid.nc
module load nco; ncks -h -d ny,80, -d nyp,80, supergrid.nc ocean_hgrid.nc
./changeChar.py ocean_hgrid.nc tile tile1

topog.nc: edit_topog.nc
./ice9.py edit_topog.nc --output topog.nc

ocean_topog.nc: topog.nc
ncks -h -d ny,40, topog.nc ocean_topog.nc
ncap -h -s 'jEdit=jEdit-40' --overwrite ocean_topog.nc ocean_topog.nc
module load nco; /usr/local/nco-4.0.3/bin/ncks -h -d ny,40, topog.nc ocean_topog.nc
/usr/local/nco-4.0.3/bin/ncap -h -s 'jEdit=jEdit-40' --overwrite ocean_topog.nc ocean_topog.nc
./addDimension.py ocean_topog.nc ntiles 1
# Removes rows 1-40
# Adjusts jEdit values
Expand Down Expand Up @@ -87,20 +87,11 @@ tpxo7_atlas_netcdf.tar.Z:
MIDAS:
git clone https://github.com/mjharriso/MIDAS.git

local: MIDAS MIDAS/fms_build/libfms.a MIDAS/MOM6_ALE/build_ale/libale.a
local: MIDAS
-rm -rf MIDAS/build/*
module load python netcdf/4.2 intel_compilers; cd MIDAS ; python setup.py config_fc --f90flags="-i4 -r8 -DPY_SOLO" --fcompiler=intelem build
cd MIDAS; python setup.py install --home=../local
touch local

MIDAS/fms_build/libfms.a:
cd MIDAS/fms;tar xvf fms_tikal_201312.tar
module load python netcdf/4.2 intel_compilers; cd MIDAS ; (cd fms_build;./build_fms.csh)
MIDAS/MOM6_ALE/build_ale/libale.a: MIDAS/MOM6_ALE/src/*
module load python netcdf/4.2 intel_compilers; cd MIDAS ; (cd MOM6_ALE/build_ale;./build_ale.csh)

MIDAS/README.md:
cd ../../../; git submodule update
module load python netcdf/4.2 intel_compilers; setenv INSTALL_DIR `pwd`/local ; cd MIDAS;make -f Makefile_GFDL;cd ..;touch local



bedmap2.nc GEBCO_08_v1.nc IBCAO_V3_500m_RR.grd:
cp /archive/gold/datasets/topography/$@ .
Expand Down
5 changes: 3 additions & 2 deletions tools/python/025gridGeneration/create_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@



from midas import *

from midas.rectgrid_gen import *
from midas.rectgrid import *
import numpy as np


refine=2 # Set to 2 for GIS_025 grid and 4 for GIS_0125
Expand Down
42 changes: 22 additions & 20 deletions tools/python/025gridGeneration/create_topo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!python

#============================================================
# Generate tiles for the northern/southern caps
Expand All @@ -20,7 +20,10 @@



from midas import *
from midas.rectgrid import *
from midas.rectgrid_gen import *
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, cm
from mpl_toolkits.basemap import interp
import argparse
Expand Down Expand Up @@ -63,20 +66,20 @@ def csv(value):
#### Begin Mercator Grid

mercator=supergrid(file='mercator_supergrid.nc')
mercator_grid=rectgrid(supergrid=mercator,is_latlon=True,cyclic=True)
mercator_grid=quadmesh(supergrid=mercator,is_latlon=True,cyclic=True)

#### Begin Tripolar Cap

tripolar_n=supergrid(file='ncap_supergrid.nc')
tripolar_n_grid=rectgrid(supergrid=tripolar_n,is_latlon=True,cyclic=True)
tripolar_n_grid=quadmesh(supergrid=tripolar_n,is_latlon=True,cyclic=True)

#### Begin Antarctic Cap

antarctic_sph=supergrid(file='antarctic_spherical_supergrid.nc')
antarctic_sph_grid=rectgrid(supergrid=antarctic_sph,is_latlon=True,cyclic=True)
antarctic_sph_grid=quadmesh(supergrid=antarctic_sph,is_latlon=True,cyclic=True)

antarctic_cap=supergrid(file='scap_supergrid.nc')
antarctic_cap_grid=rectgrid(supergrid=antarctic_cap,is_latlon=True,cyclic=True)
antarctic_cap_grid=quadmesh(supergrid=antarctic_cap,is_latlon=True,cyclic=True)


if do_ncap:
Expand All @@ -85,7 +88,7 @@ def csv(value):
######## on a np stereo projection

if use_gebco:
ingrid=rectgrid('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
ingrid=quadmesh('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
# np_reg=ingrid.geo_region(y=(mercator.y.max()-1.0,90.0))
np_reg=ingrid.indexed_region(j=(18360,21599),i=(0,43199))
print np_reg['y'][0],np_reg['x'][0]
Expand All @@ -105,14 +108,14 @@ def csv(value):

fnam = 'ncap_topog_gebco.nc'

R=TOPO.grid_overlay('topo',target=tripolar_n_grid)
R=TOPO.subtile('topo',target=tripolar_n_grid)
R.write_nc(fnam,['mean','max','min','std','count'])

else:
xlen=2904000.0*2.0
x=np.linspace(0.0,xlen,11617)
X,Y=np.meshgrid(x,x)
grid_ibcao = rectgrid(lon=X,lat=Y,is_latlon=False,is_cartesian=True)
grid_ibcao = quadmesh(lon=X,lat=Y,is_latlon=False,is_cartesian=True)

m = Basemap(projection='stere',width=xlen,height=xlen,lon_0=0.0,lat_0=90.0,resolution='l')

Expand All @@ -130,23 +133,22 @@ def csv(value):

fnam = 'ncap_topog.nc'

R=IBCAO.grid_overlay('topo',target=cart_grid_ncap)
R=IBCAO.subtile('topo',target=cart_grid_ncap)
R.write_nc(fnam,['mean','max','min','std','count'])

#### Begin Mercator

if do_mercator:

ingrid=rectgrid('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
ingrid=quadmesh('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
merc_reg=ingrid.geo_region(y=(mercator.y.min()-1.0,mercator.y.max()+1.0))

TOPO=state('GEBCO_08_v1.nc',grid=ingrid,geo_region=merc_reg,fields=['depth'])
TOPO.rename_field('depth','topo')
TOPO.var_dict['topo']['Ztype']='Fixed'

fnam = 'mercator_topog_gebco.nc'

R=TOPO.grid_overlay('topo',target=mercator_grid)
R=TOPO.subtile('topo',target=mercator_grid)
R.write_nc(fnam,['mean','max','min','std','count'])


Expand All @@ -161,7 +163,7 @@ def csv(value):

if use_gebco:

ingrid=rectgrid('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
ingrid=quadmesh('GEBCO_08_v1.nc',var='depth',simple_grid=True,cyclic=True)
sp_reg=ingrid.geo_region(y=(-90.0,antarctic_sph.y.max()+1.0))

TOPO=state('GEBCO_08_v1.nc',grid=ingrid,geo_region=sp_reg,fields=['depth'])
Expand All @@ -171,10 +173,10 @@ def csv(value):
fnam = 'scap_topog_gebco.nc'
fnam2 = 'so_topog_gebco.nc'

R=TOPO.grid_overlay('topo',target=antarctic_cap_grid)
R=TOPO.subtile('topo',target=antarctic_cap_grid)
R.write_nc(fnam,['mean','max','min','std','count'])

R=TOPO.grid_overlay('topo',target=antarctic_sph_grid)
R=TOPO.subtile('topo',target=antarctic_sph_grid)
R.write_nc(fnam2,['mean','max','min','std','count'])


Expand All @@ -184,15 +186,15 @@ def csv(value):
ht=6667000.0
m = Basemap(projection='stere',width=wd,height=ht,lon_0=0.0,lat_ts=-71.,lat_0=-90.,resolution='l')

f=nc.Dataset('bedmap2.nc')
f=netCDF4.Dataset('bedmap2.nc')
x1=sq(f.variables['x'][:])*1000 + 3333000.0
y1=x1
nx1=len(x1)
ny1=len(y1)
wd=6667000.0
ht=6667000.0
x1,y1=np.meshgrid(x1,y1)
grid_bedmap = rectgrid(lon=x1,lat=y1,is_latlon=False,is_cartesian=True,simple_grid=True)
grid_bedmap = quadmesh(lon=x1,lat=y1,is_latlon=False,is_cartesian=True,simple_grid=True)

if use_ice_sheet_mask:
TOPO=state('bedmap2.nc',grid=grid_bedmap,fields=['elev_bed','mask_ice','elev_surf','height_gl04c_wgs84'])
Expand Down Expand Up @@ -221,7 +223,7 @@ def csv(value):

cart_grid_so = supergrid(config='cartesian',axis_units='none',xdat=x2,ydat=y2)

R=TOPO.grid_overlay('topo',target=cart_grid_so)
R=TOPO.subtile('topo',target=cart_grid_so)

R.write_nc(fnam2,['mean','max','min','std','count'])

Expand All @@ -236,7 +238,7 @@ def csv(value):

cart_grid_cap = supergrid(config='cartesian',axis_units='none',xdat=x2,ydat=y2)

R=TOPO.grid_overlay('topo',target=cart_grid_cap)
R=TOPO.subtile('topo',target=cart_grid_cap)
R.write_nc(fnam,['mean','max','min','std','count'])


6 changes: 4 additions & 2 deletions tools/python/025gridGeneration/interpCHL.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python

from midas import *
from midas.rectgrid import *
import netCDF4 as nc
import numpy as np

sgrid=supergrid(file='ocean_hgrid.nc')
grid=rectgrid(supergrid=sgrid,cyclic=True)
grid=quadmesh(supergrid=sgrid,cyclic=True)
O=state('/archive/gold/datasets/global/siena_201204/INPUT/seawifs_1998-2006_GOLD_smoothed_2X.nc',fields=['CHL_A'])
O.var_dict['CHL_A']['Z']=None
OM=O.horiz_interp('CHL_A',target=grid,src_modulo=True)
Expand Down
7 changes: 5 additions & 2 deletions tools/python/025gridGeneration/interpSaltRestore.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env python

from midas import *
from midas.rectgrid import *
import numpy as np
import netCDF4 as nc

sgrid=supergrid(file='ocean_hgrid.nc',cyclic_x=True,tripolar_n=True)
grid=rectgrid(supergrid=sgrid)
grid=quadmesh(supergrid=sgrid)
O=state('/archive/gold/datasets/obs/WOA05_pottemp_salt.nc',fields=['SALT'],z_indices=np.arange(0,1),default_calendar='noleap')
O.grid.cyclic_x=True
O.var_dict['SALT']['Z'] = None
Expand Down
2 changes: 2 additions & 0 deletions tools/python/025gridGeneration/merge_grids.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python

from midas import *
import netCDF4 as nc
import numpy as np

f=nc.Dataset('scap_supergrid.nc')
f2=nc.Dataset('antarctic_spherical_supergrid.nc')
Expand Down

0 comments on commit d2ce721

Please sign in to comment.