if o in ('-o', '--origin'): a = a.split('/') try: origin = [float(a[0]),float(a[1])] except: print 'Error, cannot parse origin string' usage() sys.exit(1) if o in ('-f', '--force'): overwrite=1 if proj is None or origin is None: usage() sys.exit(1) proj4 = PyCF.getCFProj(proj) proj4.setOrigin(origin[0],origin[1]) proj.false_easting = proj4.params['x_0'] proj.false_northing = proj4.params['y_0'] cffile = Scientific.IO.NetCDF.NetCDFFile(inname,'r+') if 'mapping' in cffile.variables.keys(): if overwrite==1: varmap=cffile.variables['mapping'] else: print 'netCDF file already got map projection info.' sys.exit(0) else: varmap=cffile.createVariable('mapping','c',())
title = a if o == '--institution': institution = a if o == '--source': source = a if o == '--references': references = a if o == '--comment': comment = a if proj is None or origin is None or delta is None or (num is None and upper is None): usage() sys.exit(1) proj4 = PyCF.getCFProj(proj) proj4.setOrigin(origin[0],origin[1]) proj.false_easting = proj4.params['x_0'] proj.false_northing = proj4.params['y_0'] if upper != None: u = proj4.proj4(upper) num = [int(u[0]/delta[0])+1,int(u[1]/delta[1])+1] # projecting topography proj_gmt='-J%s/1:1 -R%s -A -D%f/%f'%( proj4.getGMTprojection(), proj4.getGMTregion([0.,0.],[delta[0]*num[0],delta[1]*num[1]]), delta[0],delta[1]) projfile = tempfile.NamedTemporaryFile(suffix='.bin') PyGMT.command('grdproject','%s -G%s=1 %s'%(inname,projfile.name,proj_gmt))
default=25., type="float", help="set grid spacing [km] (default = 25)") (options, args) = parser.parse_args() if len(args) != 1: parser.error("no output file name given") # ice sheet print options.massbalance, options.flow_law_exponent, options.margin_radius ism = exact_is.ModelAE(options.massbalance, options.flow_law_exponent, options.margin_radius) # creating output netCDF file cffile = PyCF.CFcreatefile(args[0]) # global attributes # history cffile.history = '%s: %s' % (datetime.datetime.today(), string.join(sys.argv)) num = int(1.1 * options.margin_radius / options.delta + 0.5) num = 2 * (num - 1) + 1 # creating dimensions cffile.createDimension('x0', num - 1) cffile.createDimension('x1', num) cffile.createDimension('y0', num - 1) cffile.createDimension('y1', num) cffile.createDimension('level', 1) cffile.createDimension('time', None)