tgenerate_input.py - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tgenerate_input.py (1577B)
       ---
            1 #!/usr/bin/env python3
            2 
            3 from PISMNC import PISMDataset as NC
            4 from optparse import OptionParser
            5 import numpy as np
            6 
            7 parser = OptionParser()
            8 
            9 parser.usage = "%prog [options]"
           10 parser.description = "Fills missing values in variables selected using -v in the file given by -f."
           11 parser.add_option("-o", dest="output_file_name", default="advance_test.nc",
           12                   help="output file name")
           13 parser.add_option("-L", dest="length", default=100e3, type=float,
           14                   help="domain length, meters")
           15 parser.add_option("-M", dest="Mx", default=101, type=int,
           16                   help="number of grid points in the flow direction")
           17 
           18 (options, args) = parser.parse_args()
           19 
           20 My = 3
           21 bed_slope = 0.02
           22 ice_thickness = 1000.0
           23 U = 100.0
           24 
           25 nc = NC(options.output_file_name, 'w')
           26 
           27 x = np.linspace(0, options.length, options.Mx)
           28 y = x[0:3] - x[1]
           29 
           30 xx, yy = np.meshgrid(x, y)
           31 
           32 zeros = np.zeros((My, options.Mx))
           33 topg = (0.5 * options.length - xx) * bed_slope
           34 
           35 thk = zeros.copy()
           36 thk[topg > 200] = ice_thickness
           37 
           38 v = zeros.copy()
           39 u = zeros.copy() + U
           40 
           41 nc.create_dimensions(x, y)
           42 nc.write("topg", topg, attrs={"units": "m", "long_name": "bed_topography"})
           43 nc.write("climatic_mass_balance", zeros, attrs={"units": "kg m-2 year-1"})
           44 nc.write("ice_surface_temp", zeros, attrs={"units": "Celsius"})
           45 nc.write("thk", thk,
           46          attrs={"units": "m", "standard_name": "land_ice_thickness"})
           47 nc.write("ubar", u,
           48          attrs={"units": "m/year", "long_name": "x-component of velocity"})
           49 nc.write("vbar", v,
           50          attrs={"units": "m/year", "long_name": "y-component of velocity"})
           51 
           52 nc.close()