<p><b>mhoffman@lanl.gov</b> 2012-03-07 10:55:21 -0700 (Wed, 07 Mar 2012)</p><p>BRANCH COMMIT -- land_ice<br>
Modified the python scripts that setup a land ice grid and dome test case to use the variable 'temperature' instead of 'tracers'. Also removed the dimension nTracers when setting up the land ice grid.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/land_ice_projects/grid_tools/add_land_ice_variables_to_mpas_grid.py
===================================================================
--- branches/land_ice_projects/grid_tools/add_land_ice_variables_to_mpas_grid.py        2012-03-06 23:17:36 UTC (rev 1600)
+++ branches/land_ice_projects/grid_tools/add_land_ice_variables_to_mpas_grid.py        2012-03-07 17:55:21 UTC (rev 1601)
@@ -5,18 +5,22 @@
import sys, numpy
from Scientific.IO.NetCDF import *
-# from NetCDF import *
-from optparse import OptionParser
-parser = OptionParser()
-parser.add_option("-f", "--file", dest="filename", help="file to convert", metavar="FILE")
-options, args = parser.parse_args()
-if not options.filename:
- parser.error("Filename is a required input. Include by using: -f FILENAME")
+# Check to see if a grid file was specified on the command line.
+# If not, land_ice_grid.nc is used.
+if len(sys.argv) > 1:
+ if sys.argv[1][0] == '-': # The filename can't begin with a hyphen
+ print '</font>
<font color="black">Usage: python add_land_ice_variables_to_mpas_grid.py [GRID.NC]</font>
<font color="gray">If no filename is supplied, grid.nc will be used.'
+ sys.exit(0)
+ else:
+ fileinName = sys.argv[1]
+else:
+ fileinName = 'grid.nc'
+
# Get some information about the input file
-filein = NetCDFFile(options.filename,'r')
+filein = NetCDFFile(fileinName,'r')
# vert_levs = filein.dimensions['nVertLevels']
@@ -36,7 +40,9 @@
# This is a limitation of Scientific.IO.NetCDF and may not be an issue with other netcdf python modules.
# This workaround should be fine for the time being since there is no need to have the I.C. file have UNLIMITED time dimension.
fileout.createDimension('Time', 1)
- else:
+ elif dim == 'nTracers':
+ pass # Do nothing - we don't want this dimension
+ else: # Copy over all other dimensions
fileout.createDimension(dim, filein.dimensions[dim])
# Create nVertLevelsPlus2 dimension
fileout.createDimension('nVertLevelsPlus2', filein.dimensions['nVertLevels'] + 2)
@@ -63,7 +69,7 @@
newvar[:] = numpy.zeros(newvar.shape)
newvar = fileout.createVariable('normalVelocity', 'd', ('Time', 'nEdges', 'nVertLevels'))
newvar[:] = numpy.zeros(newvar.shape)
-newvar = fileout.createVariable('tracers', 'd', ('Time', 'nCells', 'nVertLevelsPlus2', 'nTracers'))
+newvar = fileout.createVariable('temperature', 'd', ('Time', 'nCells', 'nVertLevelsPlus2'))
newvar[:] = numpy.zeros(newvar.shape)
# Assign the global attributes
Modified: branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py
===================================================================
--- branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py        2012-03-06 23:17:36 UTC (rev 1600)
+++ branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py        2012-03-07 17:55:21 UTC (rev 1601)
@@ -18,11 +18,12 @@
+# Open the file, get needed dimensions
try:
- # Open the file, get needed dimensions
gridfile = NetCDFFile(gridfilename,'r+')
nVertLevels = gridfile.dimensions['nVertLevels']
-
+ if nVertLevels != 9:
+ print 'nVerLevels in the supplied file was ', nVertLevels, '. Were you expecting 9?'
# Get variables
xCell = gridfile.variables['xCell'][:]
yCell = gridfile.variables['yCell'][:]
@@ -30,14 +31,11 @@
bedTopography = gridfile.variables['bedTopography'][:]
normalVelocity = gridfile.variables['normalVelocity'][:]
layerThicknessFractions = gridfile.variables['layerThicknessFractions'][:]
- tracers = gridfile.variables['tracers'][:]
+ temperature = gridfile.variables['temperature'][:]
except:
sys.exit('Error: The grid file specified is either missing or lacking needed dimensions/variables.')
-indexTemperature = 0 # IS THIS RIGHT?
-
-
# Assign variable values for dome
# Define dome dimensions - all in meters
r0 = 60000.0 * sqrt(0.125)
@@ -55,7 +53,7 @@
# flat bed at sea level
bedTopography[:] = 0.0
# constant, arbitrary temperature, degrees C
-tracers[:,:,:,indexTemperature] = -20.0
+temperature[:] = -20.0
# Setup layerThicknessFractions
layerThicknessFractions[:] = 1.0 / nVertLevels
# (lowerSurface and upperSurface need to be calculated in MPAS)
@@ -64,7 +62,7 @@
gridfile.variables['thickness'][:] = thickness
gridfile.variables['normalVelocity'][:] = normalVelocity
gridfile.variables['bedTopography'][:] = bedTopography
-gridfile.variables['tracers'][:] = tracers
+gridfile.variables['temperature'][:] = temperature
gridfile.variables['layerThicknessFractions'][:] = layerThicknessFractions
</font>
</pre>