1 | #! /usr/bin/env python |
---|
2 | from netCDF4 import Dataset |
---|
3 | from numpy import * |
---|
4 | import numpy as np |
---|
5 | import matplotlib.pyplot as mpl |
---|
6 | from matplotlib.cm import get_cmap |
---|
7 | import pylab |
---|
8 | import matplotlib.colors as mcolors |
---|
9 | from FV3_utils import * |
---|
10 | |
---|
11 | ############################ |
---|
12 | folder="../" |
---|
13 | filename1=folder+"diagfi_mean_A.nc" |
---|
14 | var="ch4_gas" #variable |
---|
15 | tint=[30,32] #Time must be as written in the input file |
---|
16 | xarea="-180,179" |
---|
17 | |
---|
18 | nc1=Dataset(filename1) |
---|
19 | |
---|
20 | lat=nc1.variables["lat"][:] |
---|
21 | lon=nc1.variables["lon"][:] |
---|
22 | alt=nc1.variables["altitude"][:] |
---|
23 | tim=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 | |
---|
31 | myvar=getvar(nc1,var,tint,tim) |
---|
32 | myvar=myvar*28/16.*100. |
---|
33 | |
---|
34 | mpl.figure(figsize=(20, 10)) |
---|
35 | |
---|
36 | font=26 |
---|
37 | |
---|
38 | #pal=rvb1 #get_cmap(name="RdYlBu_r") |
---|
39 | #pal=get_cmap(name="Spectral_r") |
---|
40 | pal=get_cmap(name="rainbow") |
---|
41 | |
---|
42 | xticks=[-90,-60,-30,0,30,60,90] |
---|
43 | #yticks=np.linspace(0,240,9) |
---|
44 | alt=alt/1000. |
---|
45 | |
---|
46 | mymin=0.1 |
---|
47 | mymax=4 |
---|
48 | |
---|
49 | # log |
---|
50 | norm=mcolors.LogNorm() |
---|
51 | lvls=np.logspace(np.log10(mymin),np.log10(mymax),16) |
---|
52 | #titi=[1.e-14,1.e-13,1.e-12,1.e-11] |
---|
53 | CF=mpl.contourf(lat, alt, myvar,levels=lvls,norm=norm,cmap=pal) |
---|
54 | cbar=mpl.colorbar(CF, shrink=1, format="%.1f",extend='both') |
---|
55 | |
---|
56 | for t in cbar.ax.get_yticklabels(): |
---|
57 | t.set_fontsize(font) |
---|
58 | |
---|
59 | |
---|
60 | vect=lvls |
---|
61 | CS=mpl.contour(lat,alt,myvar,vect,colors='k',linewidths=0.5) |
---|
62 | #### inline=1 : values over the line |
---|
63 | mpl.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) |
---|
69 | mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) |
---|
70 | mpl.xlabel('Latitude (deg)',labelpad=10, fontsize=font) |
---|
71 | mpl.xticks(xticks,fontsize=font) |
---|
72 | #mpl.xticks(fontsize=font) |
---|
73 | #mpl.yticks(yticks,fontsize=font) |
---|
74 | mpl.yticks(fontsize=font) |
---|
75 | pylab.ylim([-4,200]) |
---|
76 | |
---|
77 | mpl.savefig('meanvmrch4.eps',dpi=200) |
---|
78 | mpl.savefig('meanvmrch4.png',dpi=200) |
---|
79 | mpl.show() |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|