| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | ### A. Spiga LMD 29/05/2011 |
|---|
| 4 | |
|---|
| 5 | def usage(): |
|---|
| 6 | print 'USAGE: plot.py file (target)' |
|---|
| 7 | print 'file : name of input netcdf file.' |
|---|
| 8 | print '(target) : a directory with write rights.' |
|---|
| 9 | print 'Example: domain.py /d5/aslmd/LMD_MM_MARS_SIMUS/OM/OM6_TI85/wrfout_d01_2024-06-43_06:00:00 ~/' |
|---|
| 10 | |
|---|
| 11 | def domain (namefile,proj="ortho",back="molabw",target=None): #vishires |
|---|
| 12 | from netCDF4 import Dataset |
|---|
| 13 | from myplot import getcoord2d,define_proj,makeplotpng,simplinterv |
|---|
| 14 | from matplotlib.pyplot import contourf |
|---|
| 15 | nc = Dataset(namefile) |
|---|
| 16 | [lon2d,lat2d] = getcoord2d(nc) |
|---|
| 17 | [wlon,wlat] = simplinterv(lon2d,lat2d) |
|---|
| 18 | m = define_proj(proj,wlon,wlat,back=back) |
|---|
| 19 | x, y = m(lon2d, lat2d) |
|---|
| 20 | contourf(x, y, nc.variables['HGT'][0,:,:] / 1000., 50) |
|---|
| 21 | if not target: zeplot = namefile+".domain" |
|---|
| 22 | else: zeplot = target+"domain" |
|---|
| 23 | makeplotpng(zeplot,pad_inches_value=0.35) |
|---|
| 24 | |
|---|
| 25 | if __name__ == "__main__": |
|---|
| 26 | import sys |
|---|
| 27 | if (len(sys.argv)) == 2: domain( str(sys.argv[1]) ) |
|---|
| 28 | elif (len(sys.argv)) == 3: domain( str(sys.argv[1]) , target = str(sys.argv[2]) ) |
|---|