source: trunk/MESOSCALE/PLOT/PYTHON/scripts/domain.py @ 188

Last change on this file since 188 was 184, checked in by aslmd, 14 years ago

MESOSCALE: much improved python scripts for winds. lots of automatic settings.

  • Property svn:executable set to *
File size: 1.7 KB
RevLine 
[178]1#!/usr/bin/env python
2
[184]3### A. Spiga -- LMD -- 30/05/2011
[178]4
[184]5def domain (namefile,proj="ortho",back="molabw",target=None,var='HGT'): 
[178]6    from netCDF4 import Dataset
7    from myplot import getcoord2d,define_proj,makeplotpng,simplinterv
8    from matplotlib.pyplot import contourf
9    nc  = Dataset(namefile)
10    [lon2d,lat2d] = getcoord2d(nc)
11    [wlon,wlat] = simplinterv(lon2d,lat2d)
[180]12    m = define_proj(proj,wlon,wlat,back=back)
[178]13    x, y = m(lon2d, lat2d)
[184]14    contourf(x, y, nc.variables[var][0,:,:], 40)
[181]15    if not target:   zeplot = namefile+".domain"
[184]16    else:            zeplot = target+"/domain"
[181]17    makeplotpng(zeplot,pad_inches_value=0.35)
[178]18
19if __name__ == "__main__":
20    import sys
[184]21    ### to be replaced by argparse
22    from optparse import OptionParser
23    parser = OptionParser()
24    parser.add_option('-f', action='store', dest='namefile',    type="string",  default=None,     help='name of WRF file [NEEDED]')
25    parser.add_option('-p', action='store', dest='proj',        type="string",  default="ortho",  help='projection')
26    parser.add_option('-b', action='store', dest='back',        type="string",  default="molabw", help='background')
27    parser.add_option('-t', action='store', dest='target',      type="string",  default=None,     help='destination folder')
28    parser.add_option('-v', action='store', dest='var',         type="string",  default='HGT',    help='variable contoured')
29    (opt,args) = parser.parse_args()
30    if opt.namefile is None:
31        print "I want to eat one file at least ! Use domain.py -f name_of_my_file. Or type domain.py -h"
32        exit()
33    print "Options:", opt
34    domain (opt.namefile,proj=opt.proj,back=opt.back,target=opt.target,var=opt.var)
Note: See TracBrowser for help on using the repository browser.