1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | ### A. Spiga LMD 29/05/2011 |
---|
4 | |
---|
5 | def usage(): |
---|
6 | print 'USAGE: winds.py ntime nvert file' |
---|
7 | print 'file : name of input netcdf file.' |
---|
8 | print 'nvert : vertical level.' |
---|
9 | print 'Example: winds.py 0 /d5/aslmd/LMD_MM_MARS_SIMUS/OM/OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' |
---|
10 | |
---|
11 | def winds (namefile,nvert,proj="cyl",back=None): |
---|
12 | from netCDF4 import Dataset |
---|
13 | from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle |
---|
14 | from matplotlib.pyplot import contourf, subplot, figure |
---|
15 | nc = Dataset(namefile) |
---|
16 | [lon2d,lat2d] = getcoord2d(nc) |
---|
17 | [wlon,wlat] = simplinterv(lon2d,lat2d) |
---|
18 | [u,v] = getwinds(nc) |
---|
19 | nt = len(u[:,0,0,0]) |
---|
20 | fig = figure() |
---|
21 | fig.subplots_adjust(wspace = 0.0, hspace = 0.3) |
---|
22 | sub = 221 |
---|
23 | for i in range(0,nt-1,int(nt/4.)): |
---|
24 | subplot(sub) |
---|
25 | ptitle("Winds time"+str(i)+" level"+str(nvert)) |
---|
26 | m = define_proj(proj,wlon,wlat,back=back) |
---|
27 | x, y = m(lon2d, lat2d) |
---|
28 | contourf(x, y, nc.variables['HGT'][0,:,:] / 1000., 30) |
---|
29 | vectorfield(u[i,nvert,:,:], v[i,nvert,:,:],\ |
---|
30 | x, y, stride=5, csmooth=3,\ |
---|
31 | scale=20., factor=300., color='k') |
---|
32 | sub += 1 |
---|
33 | makeplotpng(namefile+".winds"+str(nvert),pad_inches_value=0.35) |
---|
34 | |
---|
35 | def getwinds (nc,charu='Um',charv='Vm'): |
---|
36 | u = nc.variables[charu] |
---|
37 | v = nc.variables[charv] |
---|
38 | return u,v |
---|
39 | |
---|
40 | if __name__ == "__main__": |
---|
41 | import sys |
---|
42 | winds(str(sys.argv[2]),int(sys.argv[1])) |
---|