source: trunk/LMDZ.PLUTO/util/script_figures/ch4vmrsection.py @ 3831

Last change on this file since 3831 was 3823, checked in by afalco, 6 days ago

Pluto: added some python scripts for visualization.
AF

  • Property svn:executable set to *
File size: 2.0 KB
RevLine 
[3823]1#! /usr/bin/env python
2from    netCDF4               import    Dataset
3from    numpy                 import    *
4import  numpy                 as        np
5import  matplotlib.pyplot     as        mpl
6from matplotlib.cm import get_cmap
7import pylab
8import matplotlib.colors as mcolors
9from FV3_utils import *
10
11############################
12folder="../"
13filename1=folder+"diagfi_mean_A.nc"
14var="ch4_gas" #variable
15tint=[30,32] #Time must be as written in the input file
16xarea="-180,179"
17
18nc1=Dataset(filename1)
19
20lat=nc1.variables["lat"][:]
21lon=nc1.variables["lon"][:]
22alt=nc1.variables["altitude"][:]
23tim=nc1.variables["time_counter"][:]
24############################
25
26# def getvar(filename,var,tint,xarea):
27#     myvar = pp(file=filename,var=var,t=tint,x=xarea,compute="mean").getf()
28#     print((shape(myvar)))
29    # return myvar
30
31myvar=getvar(nc1,var,tint,tim)
32myvar=myvar*28/16.*100.
33
34mpl.figure(figsize=(20, 10))
35
36font=26
37
38#pal=rvb1 #get_cmap(name="RdYlBu_r")
39#pal=get_cmap(name="Spectral_r")
40pal=get_cmap(name="rainbow")
41
42xticks=[-90,-60,-30,0,30,60,90]
43#yticks=np.linspace(0,240,9)
44alt=alt/1000.
45
46mymin=0.1
47mymax=4
48
49# log
50norm=mcolors.LogNorm()
51lvls=np.logspace(np.log10(mymin),np.log10(mymax),16)
52#titi=[1.e-14,1.e-13,1.e-12,1.e-11]
53CF=mpl.contourf(lat, alt, myvar,levels=lvls,norm=norm,cmap=pal)
54cbar=mpl.colorbar(CF, shrink=1, format="%.1f",extend='both')
55
56for t in cbar.ax.get_yticklabels():
57      t.set_fontsize(font)
58
59
60vect=lvls
61CS=mpl.contour(lat,alt,myvar,vect,colors='k',linewidths=0.5)
62#### inline=1 : values over the line
63mpl.clabel(CS, inline=1, fontsize=20, fmt='%1.1f',inline_spacing=1)
64
65
66#lev=np.logspace(np.log10(0.1),np.log10(4),9)
67
68#mpl.title('Latitude ='+str(tintstr[i]),fontsize=font)
69mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font)
70mpl.xlabel('Latitude (deg)',labelpad=10, fontsize=font)
71mpl.xticks(xticks,fontsize=font)
72#mpl.xticks(fontsize=font)
73#mpl.yticks(yticks,fontsize=font)
74mpl.yticks(fontsize=font)
75pylab.ylim([-4,200])
76
77mpl.savefig('meanvmrch4.eps',dpi=200)
78mpl.savefig('meanvmrch4.png',dpi=200)
79mpl.show()
80
81
82
83
Note: See TracBrowser for help on using the repository browser.