Skip to content
2 changes: 1 addition & 1 deletion tools/python/025gridGeneration/MIDAS
Submodule MIDAS updated 2 files
+3 −3 Makefile_GFDL
+32 −21 midas/rectgrid.py
38 changes: 26 additions & 12 deletions tools/python/025gridGeneration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
# make supergrid.nc
# make interpolated_topog.nc

# nco module version
NCO = nco/4.3.1

SHELL=tcsh

all: md5sums.txt ocean_hgrid.nc ocean_topog.nc
all: input forcing obs
md5sum -c md5sums.txt

input: ocean_hgrid.nc ocean_topog.nc basin_codes.nc

forcing: salt_restore.nc seawifs_1998-2006_smoothed_2X.nc tidal_amplitude.nc

obs: WOA05_ptemp_salt_monthly.nc WOA05_ptemp_salt_annual.nc

# Grids
supergrid.nc: mercator_supergrid.nc ncap_supergrid.nc antarctic_spherical_supergrid.nc scap_supergrid.nc local
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python merge_grids.py
Expand Down Expand Up @@ -43,36 +51,39 @@ scap_topog_gebco.nc so_topog_gebco.nc: mercator_supergrid.nc ncap_supergrid.nc a

# Sets char tile='tile1'
ocean_hgrid.nc: supergrid.nc
module load nco; 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
topog.nc: edit_topog.nc interpolated_topog.nc
./ice9.py edit_topog.nc --output topog.nc

ocean_topog.nc: topog.nc
module load nco; ncks -h -d ny,40, topog.nc ocean_topog.nc
module load nco;ncap -h -s 'jEdit=jEdit-40' --overwrite ocean_topog.nc ocean_topog.nc
module load $(NCO); ncks -h -d ny,40, topog.nc ocean_topog.nc
module load $(NCO);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
# Adds back the dimension "ntiles"

basin_codes.nc: ocean_topog.nc
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python make_basin_mask.py
module load nco; ncatted -h -a flag_meanings,basin,c,c,'1:Southern Ocean, 2:Atlantic Ocean, 3:Pacific Ocean, 4:Arctic Ocean, 5:Indian Ocean, 6:Mediterranean Sea, 7:Black Sea, 8:Hudson Bay, 9:Baltic Sea, 10:Red Sea, 11:Persian Gulf' basin_codes.nc
module load nco; ncatted -h -a flag_values,basin,c,c,'1,2,3,4,5,6,7,8,9,10,11' basin_codes.nc
module load $(NCO); ncatted -h -a flag_meanings,basin,c,c,'1:Southern Ocean, 2:Atlantic Ocean, 3:Pacific Ocean, 4:Arctic Ocean, 5:Indian Ocean, 6:Mediterranean Sea, 7:Black Sea, 8:Hudson Bay, 9:Baltic Sea, 10:Red Sea, 11:Persian Gulf' basin_codes.nc
module load $(NCO); ncatted -h -a flag_values,basin,c,c,'1,2,3,4,5,6,7,8,9,10,11' basin_codes.nc

WOA05_ptemp_salt_annual.nc: WOA05_ptemp_salt_monthly.nc
module load $(NCO); ncra -h -O $< $@

WOA05_ptemp_salt_monthly.nc: ocean_hgrid.nc ocean_topog.nc /archive/gold/datasets/obs/WOA05_pottemp_salt.nc interpWOA05.py local
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python interpWOA05.py
module load nco; ncatted -h -a modulo,TIME,c,c,' ' WOA05_ptemp_salt_monthly.nc
module load $(NCO); ncatted -h -a modulo,TIME,c,c,' ' WOA05_ptemp_salt_monthly.nc

salt_restore.nc: ocean_hgrid.nc ocean_topog.nc /archive/gold/datasets/obs/WOA05_pottemp_salt.nc interpSaltRestore.py local
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python interpSaltRestore.py
module load nco; ncatted -h -a modulo,TIME,c,c,' ' salt_restore.nc
module load $(NCO); ncatted -h -a modulo,TIME,c,c,' ' salt_restore.nc

seawifs_1998-2006_smoothed_2X.nc: ocean_hgrid.nc ocean_topog.nc /archive/gold/datasets/global/siena_201204/INPUT/seawifs_1998-2006_GOLD_smoothed_2X.nc interpCHL.py local
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python interpCHL.py
module load nco; ncatted -h -a modulo,TIME,c,c,' ' seawifs_1998-2006_smoothed_2X.nc
module load $(NCO); ncatted -h -a modulo,TIME,c,c,' ' seawifs_1998-2006_smoothed_2X.nc

tidal_amplitude.nc: DATA interpTides.py local
unlimit stacksize; setenv PYTHONPATH ./local/lib/python; python interpTides.py
Expand All @@ -89,14 +100,14 @@ MIDAS:

local: MIDAS
-rm -rf MIDAS/build/*
module load python netcdf/4.2 intel_compilers; setenv INSTALL_DIR `pwd`/local ; cd MIDAS;make -f Makefile_GFDL;cd ..;touch local
module load python netcdf/4.2 intel_compilers; if (! -f local) mkdir local;cd MIDAS;make -f Makefile_GFDL INSTALL_PATH=../local;cd ..;touch local



bedmap2.nc GEBCO_08_v1.nc IBCAO_V3_500m_RR.grd:
cp /archive/gold/datasets/topography/$@ .

md5sums.txt: ocean_hgrid.nc antarctic_spherical_supergrid.nc mercator_supergrid.nc ncap_supergrid.nc scap_supergrid.nc supergrid.nc interpolated_topog.nc mercator_topog_gebco.nc ncap_topog_gebco.nc ncap_topog.nc scap_topog_bedmap2.nc scap_topog_gebco.nc so_topog_bedmap2.nc so_topog_gebco.nc ocean_topog.nc basin_codes.nc salt_restore.nc seawifs_1998-2006_smoothed_2X.nc tidal_amplitude.nc
md5sums.txt: ocean_hgrid.nc antarctic_spherical_supergrid.nc mercator_supergrid.nc ncap_supergrid.nc scap_supergrid.nc supergrid.nc interpolated_topog.nc mercator_topog_gebco.nc ncap_topog_gebco.nc ncap_topog.nc scap_topog_bedmap2.nc scap_topog_gebco.nc so_topog_bedmap2.nc so_topog_gebco.nc ocean_topog.nc basin_codes.nc salt_restore.nc seawifs_1998-2006_smoothed_2X.nc tidal_amplitude.nc WOA05_ptemp_salt_monthly.nc WOA05_ptemp_salt_annual.nc
echo Grids > $@
md5sum *supergrid.nc ocean_hgrid.nc >> $@
echo >> $@
Expand All @@ -106,3 +117,6 @@ md5sums.txt: ocean_hgrid.nc antarctic_spherical_supergrid.nc mercator_supergrid.
echo >> $@
echo Data >> $@
md5sum salt_restore.nc seawifs_1998-2006_smoothed_2X.nc tidal_amplitude.nc >> $@
echo >> $@
echo Obs >> $@
md5sum WOA05_ptemp_salt_{monthly,annual}.nc >> $@
13 changes: 8 additions & 5 deletions tools/python/025gridGeneration/interpTides.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/usr/bin/env python

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

f=nc.Dataset('DATA/grid_tpxo7_atlas.nc')

lon_u=f.variables['lon_u'][:].T
lat_u=f.variables['lat_u'][:].T
lon_v=f.variables['lon_v'][:].T
lat_v=f.variables['lat_v'][:].T

grid_u=rectgrid(lon=lon_u,lat=lat_u,cyclic=True)
grid_v=rectgrid(lon=lon_v,lat=lat_v,cyclic=True)
grid_u=quadmesh(lon=lon_u,lat=lat_u,cyclic=True)
grid_v=quadmesh(lon=lon_v,lat=lat_v,cyclic=True)

Su=state(grid=grid_u)
Sv=state(grid=grid_v)
Expand Down Expand Up @@ -82,7 +85,7 @@
Su.add_field_from_array(ua,'ua',var_dict=vdict_u)
Sv.add_field_from_array(va,'va',var_dict=vdict_v)

grid=rectgrid(lon=lon_v,lat=lat_u,cyclic=True)
grid=quadmesh(lon=lon_v,lat=lat_u,cyclic=True)
grid.wet=np.ones((grid.jm,grid.im))

S=Su.horiz_interp('ua',target=grid,src_modulo=True,method='bilinear')
Expand All @@ -100,7 +103,7 @@
S.add_field_from_array(umod,'umod',var_dict=vdict)

sgrid=supergrid(file='ocean_hgrid.nc',cyclic_x=True,tripolar_n=True)
output_grid = rectgrid(supergrid=sgrid,cyclic=True)
output_grid = quadmesh(supergrid=sgrid,cyclic=True)
output_grid.D=nc.Dataset('ocean_topog.nc').variables['depth'][:]
output_grid.wet = np.zeros(output_grid.D.shape)
output_grid.wet[output_grid.D>0.]=1.
Expand Down
12 changes: 5 additions & 7 deletions tools/python/025gridGeneration/interpWOA05.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import netCDF4 as nc
import numpy as np

sgrid=supergrid(file='/archive/gold/datasets/OM4_025/mosaic.v20140610.unpacked/ocean_hgrid.nc',cyclic_x=True,tripolar_n=True)
sgrid=supergrid(file='ocean_hgrid.nc',cyclic_x=True,tripolar_n=True)
grid=quadmesh(supergrid=sgrid)
grid.lath=grid.y_T[:,grid.im/4]
grid.latq=grid.y_T_bounds[:,grid.im/4]
grid.D=nc.Dataset('/archive/gold/datasets/OM4_025/mosaic.v20140610.unpacked/ocean_topog.nc').variables['depth'][:]
grid.D=nc.Dataset('ocean_topog.nc').variables['depth'][:]
grid.wet=np.zeros(grid.D.shape)
grid.wet[grid.D>0.]=1
S=state(grid=grid)
S=state(grid=grid)

dz=nc.Dataset('../../../examples/ocean_SIS/OM4_025/INPUT/vgrid_75_2m.nc').variables['dz'][:]
nk = dz.shape[0]
Expand All @@ -30,12 +30,11 @@
O.rename_field('SALT','salt')
OM=O.horiz_interp('salt',target=S.grid,method='bilinear')
OM=O.horiz_interp('ptemp',target=S.grid,method='bilinear',PrevState=OM)
OM.adjust_thickness('ptemp')
OM.adjust_thickness('salt')
OM.adjust_thickness('ptemp')
OM.adjust_thickness('salt')
OM.fill_interior('salt',smooth=True,num_pass=10000)
OM.fill_interior('ptemp',smooth=True,num_pass=10000)


OM.remap_ALE(fields=['ptemp','salt'],z_bounds=zb,zbax_data=-zi,method='ppm_h4',bndy_extrapolation=False)
OM.rename_field('ptemp_remap','ptemp')
OM.rename_field('salt_remap','salt')
Expand All @@ -46,4 +45,3 @@
OM.write_nc('WOA05_ptemp_salt_monthly.nc',['ptemp','salt'],append=False,write_interface_positions=True)
else:
OM.write_nc('WOA05_ptemp_salt_monthly.nc',['ptemp','salt'],append=True,write_interface_positions=True)

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

from midas import *
from midas.rectgrid import *
from midas.rectgrid_gen import *
import netCDF4
import numpy

Expand Down Expand Up @@ -168,9 +169,9 @@ def southOf(x, y, xy0, xy1):
else: print 'All points assigned a basin code'

sgrid=supergrid(file='ocean_hgrid.nc',cyclic_x=True,tripolar_n=True)
grid=rectgrid(supergrid=sgrid)
grid.D=nc.Dataset('ocean_topog.nc').variables['depth'][:]
grid.wet=np.zeros(grid.D.shape)
grid=quadmesh(supergrid=sgrid)
grid.D=netCDF4.Dataset('ocean_topog.nc').variables['depth'][:]
grid.wet=numpy.zeros(grid.D.shape)
grid.wet[grid.D>0.]=1.0
grid.lath=grid.y_T[:,grid.im/4] # should not be needed
grid.latq=grid.y_T_bounds[:,grid.im/4+1] # ditto
Expand Down
4 changes: 4 additions & 0 deletions tools/python/025gridGeneration/md5sums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Data
7d2993615f5225ae43659a1b39b12423 salt_restore.nc
f07acf60f16f3addf77b906c45349626 seawifs_1998-2006_smoothed_2X.nc
27b75fed981c011654a3512bcc094100 tidal_amplitude.nc

Obs
8a5b6c0ed1207725060ea71c0053f95f WOA05_ptemp_salt_monthly.nc
c18f42259b7e2454723692ce66c9271a WOA05_ptemp_salt_annual.nc