From d2ce72196ad31ec8e7fd17729eddb76120eea6ce Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Thu, 2 Oct 2014 09:25:41 -0400 Subject: [PATCH] Updates to tools/python/025gridGeneration using latest version of MIDAS. Does not change answers. --- tools/python/025gridGeneration/MIDAS | 2 +- tools/python/025gridGeneration/Makefile | 23 ++++------ .../python/025gridGeneration/create_grids.py | 5 ++- tools/python/025gridGeneration/create_topo.py | 42 ++++++++++--------- tools/python/025gridGeneration/interpCHL.py | 6 ++- .../025gridGeneration/interpSaltRestore.py | 7 +++- tools/python/025gridGeneration/merge_grids.py | 2 + 7 files changed, 44 insertions(+), 43 deletions(-) diff --git a/tools/python/025gridGeneration/MIDAS b/tools/python/025gridGeneration/MIDAS index 1ca9a60b0d..23054755d4 160000 --- a/tools/python/025gridGeneration/MIDAS +++ b/tools/python/025gridGeneration/MIDAS @@ -1 +1 @@ -Subproject commit 1ca9a60b0df121c839a9f85cfba60dcaf944b19c +Subproject commit 23054755d474175c02837da173efdd5fa5886fcc diff --git a/tools/python/025gridGeneration/Makefile b/tools/python/025gridGeneration/Makefile index ff43bd66f7..e185e3f31d 100644 --- a/tools/python/025gridGeneration/Makefile +++ b/tools/python/025gridGeneration/Makefile @@ -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 @@ -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/$@ . diff --git a/tools/python/025gridGeneration/create_grids.py b/tools/python/025gridGeneration/create_grids.py index 723c57349c..54bbcc5d73 100755 --- a/tools/python/025gridGeneration/create_grids.py +++ b/tools/python/025gridGeneration/create_grids.py @@ -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 diff --git a/tools/python/025gridGeneration/create_topo.py b/tools/python/025gridGeneration/create_topo.py index 9251e56faf..be937b9363 100755 --- a/tools/python/025gridGeneration/create_topo.py +++ b/tools/python/025gridGeneration/create_topo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!python #============================================================ # Generate tiles for the northern/southern caps @@ -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 @@ -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: @@ -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] @@ -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') @@ -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']) @@ -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']) @@ -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']) @@ -184,7 +186,7 @@ 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) @@ -192,7 +194,7 @@ def csv(value): 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']) @@ -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']) @@ -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']) diff --git a/tools/python/025gridGeneration/interpCHL.py b/tools/python/025gridGeneration/interpCHL.py index 653f8e2fa8..02f3e4ec40 100755 --- a/tools/python/025gridGeneration/interpCHL.py +++ b/tools/python/025gridGeneration/interpCHL.py @@ -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) diff --git a/tools/python/025gridGeneration/interpSaltRestore.py b/tools/python/025gridGeneration/interpSaltRestore.py index f2695d659f..4f9bdc5c0d 100755 --- a/tools/python/025gridGeneration/interpSaltRestore.py +++ b/tools/python/025gridGeneration/interpSaltRestore.py @@ -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 diff --git a/tools/python/025gridGeneration/merge_grids.py b/tools/python/025gridGeneration/merge_grids.py index 289e5f6c7c..f15cc208cd 100755 --- a/tools/python/025gridGeneration/merge_grids.py +++ b/tools/python/025gridGeneration/merge_grids.py @@ -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')