[3823] | 1 | #! /usr/bin/env python |
---|
| 2 | from netCDF4 import Dataset |
---|
| 3 | from numpy import * |
---|
| 4 | import numpy as np |
---|
| 5 | import matplotlib |
---|
| 6 | import matplotlib.pyplot as mpl |
---|
| 7 | from matplotlib.cm import get_cmap |
---|
| 8 | import pylab |
---|
| 9 | from matplotlib import ticker |
---|
| 10 | import matplotlib.colors as colors |
---|
| 11 | import datetime |
---|
| 12 | from mpl_toolkits.basemap import Basemap, shiftgrid |
---|
| 13 | from FV3_utils import * |
---|
| 14 | matplotlib.use('TKAgg') |
---|
| 15 | |
---|
| 16 | ############################ |
---|
| 17 | folder="../" |
---|
| 18 | name=name+'_A.nc' |
---|
| 19 | # filename1=folder+"diagfi_mean_A.nc" |
---|
| 20 | var="temperature" #variable |
---|
| 21 | tint=[30,35] #Time must be as written in the input file |
---|
| 22 | xarea="-180,179" |
---|
| 23 | print(name) |
---|
| 24 | nc1=Dataset(name) |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | lat=getvar(nc1,"latitude") |
---|
| 28 | lon=getvar(nc1,"longitude") |
---|
| 29 | alt=getvar(nc1,"altitude") |
---|
| 30 | tim=getvar(nc1,"Time") |
---|
| 31 | ############################ |
---|
| 32 | |
---|
| 33 | mpl.figure(figsize=(20, 10)) |
---|
| 34 | |
---|
| 35 | myvar=getvar(nc1,var,tint,tim,l_mean=True,t_mean=True) |
---|
| 36 | font=26 |
---|
| 37 | |
---|
| 38 | pal=get_cmap(name="RdYlBu_r") |
---|
| 39 | # pal=get_cmap(name="cividis") |
---|
| 40 | # pal=get_cmap(name="hot") |
---|
| 41 | # pal=get_cmap(name="gnuplot2") |
---|
| 42 | lev=np.linspace(40,110,11) |
---|
| 43 | newlon=lon+180 |
---|
| 44 | xticks=[-90,-60,-30,0,30,60,90] |
---|
| 45 | #yticks=np.linspace(0,240,9) |
---|
| 46 | # alt=alt/1000. |
---|
| 47 | |
---|
| 48 | CF=mpl.contourf(lat,alt,myvar,lev,cmap=pal,extend='both') |
---|
| 49 | cbar=mpl.colorbar(CF,shrink=1, format="%1.0f") |
---|
| 50 | cbar.ax.set_title("Tsurf [K]",y=1.04,fontsize=font) |
---|
| 51 | for t in cbar.ax.get_yticklabels(): |
---|
| 52 | t.set_fontsize(font) |
---|
| 53 | |
---|
| 54 | vect=lev |
---|
| 55 | CS=mpl.contour(lat,alt,myvar,vect,colors='k',linewidths=0.5) |
---|
| 56 | #inline=1 : values over the line |
---|
| 57 | #mpl.clabel(CS, inline=2, fontsize=10, fmt='%1.1e') |
---|
| 58 | mpl.clabel(CS, inline=1, fontsize=20, fmt='%1.0f',inline_spacing=1) |
---|
| 59 | |
---|
| 60 | #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font) |
---|
| 61 | mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) |
---|
| 62 | mpl.xlabel('Latitude (deg)',labelpad=10, fontsize=font) |
---|
| 63 | mpl.xticks(xticks,fontsize=font) |
---|
| 64 | #mpl.yticks(yticks,fontsize=font) |
---|
| 65 | mpl.yticks(fontsize=font) |
---|
| 66 | if type(ma.getmask(myvar)) in (bool,np.bool_): |
---|
| 67 | max_alt = max(alt) |
---|
| 68 | else: |
---|
| 69 | max_alt = max(alt[~ma.getmask(myvar)[:,0]][:-1]) |
---|
| 70 | # max_alt = 230 |
---|
| 71 | pylab.ylim([-4,max_alt]) |
---|
| 72 | |
---|
| 73 | mpl.savefig('tempsec.eps',dpi=200) |
---|
| 74 | mpl.savefig('tempsec.png',dpi=200) |
---|
| 75 | # mpl.show() |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|