source: trunk/MESOSCALE/LMD_MM_MARS/SRC/PYTHON/2dplot.py @ 296

Last change on this file since 296 was 296, checked in by aslmd, 13 years ago

MESOSCALE: graphics, added map/section examples in python. Registry, added thermals-related variables.

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#! /usr/bin/env python
2
3from netCDF4 import Dataset
4import matplotlib.pyplot as mpl
5import numpy as np
6from myplot import reducefield,getfield,getcoorddef,calculate_bounds,bounds,fmtvar,ptitle,makeplotres
7from matplotlib.pyplot import contourf,colorbar,show,xlabel,ylabel
8from matplotlib.cm import get_cmap
9
10name = "wrfout_d01_9999-09-09_09:00:00_z"
11itime = 12
12#itime = 1
13ndiv = 10
14zey = 0
15var = "W"
16vmin = -1.
17vmax = 1.
18title = "Vertical velocity"
19var = "Um"
20vmin = -2.
21vmax = 18.
22title = "Horizontal velocity"
23#var = "tk"
24#vmin = 150.
25#vmax = 170.
26#title = "Atmospheric temperature"
27
28nc = Dataset(name)
29
30what_I_plot, error = reducefield( getfield(nc,var), d4=itime, d2=zey )
31
32y = nc.variables["vert"][:]
33
34horinp = len(what_I_plot[0,:])
35x = np.linspace(0.,horinp*500.,horinp) / 1000.
36
37zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax)
38#if colorb in ["def","nobar"]:   palette = get_cmap(name=defcolorb(fvar))
39#else:                           palette = get_cmap(name=colorb)
40palette = get_cmap(name="jet")
41what_I_plot = bounds(what_I_plot,zevmin,zevmax)
42zelevels = np.linspace(zevmin,zevmax)
43contourf( x, y, what_I_plot, zelevels, cmap = palette )
44colorbar(fraction=0.05,pad=0.03,format=fmtvar(var),\
45                       ticks=np.linspace(zevmin,zevmax,ndiv+1),\
46                       extend='neither',spacing='proportional')
47ptitle(title)
48xlabel("Horizontal coordinate (km)")
49ylabel("Altitude (m)")
50makeplotres(var+str(itime),res=200.,disp=False)
51#show()
Note: See TracBrowser for help on using the repository browser.