[3823] | 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 | from matplotlib import ticker |
---|
| 9 | import matplotlib.colors as colors |
---|
| 10 | import datetime |
---|
| 11 | from mpl_toolkits.basemap import Basemap, shiftgrid |
---|
[3833] | 12 | from FV3_utils import * |
---|
[3823] | 13 | |
---|
| 14 | ############################ |
---|
[3833] | 15 | filename1=name+"_S.nc" |
---|
[3823] | 16 | var="temperature" #variable |
---|
[3833] | 17 | longitude=[-169,-165] |
---|
| 18 | # longitude=-165 |
---|
| 19 | latitude=[-19,-15] |
---|
| 20 | # latitude=-19 |
---|
[3823] | 21 | |
---|
| 22 | # local time de la longitude consideree a t=0 |
---|
| 23 | loct=12 |
---|
[3833] | 24 | sol0=12 |
---|
[3823] | 25 | t0=1./24*loct |
---|
[3833] | 26 | t1=t0+12 |
---|
| 27 | tint=[sol0+t0,sol0+t1] #Time must be as written in the input file |
---|
[3823] | 28 | print(tint) |
---|
| 29 | nc1=Dataset(filename1) |
---|
| 30 | |
---|
[3833] | 31 | lat=getvar(nc1,"latitude") |
---|
| 32 | lon=getvar(nc1,"longitude") |
---|
| 33 | alt=getvar(nc1,"altitude") |
---|
| 34 | tim=getvar(nc1,"Time",times=tint) |
---|
[3823] | 35 | ############################ |
---|
| 36 | |
---|
| 37 | mpl.figure(figsize=(18, 10)) |
---|
| 38 | |
---|
[3833] | 39 | myvar=getvar(nc1,var,times=tint,longitudes=longitude,latitudes=latitude)[:,:,0,0] |
---|
[3823] | 40 | font=23 |
---|
[3833] | 41 | # tim=np.linspace(0,24,9) |
---|
[3823] | 42 | print(("tim=",tim)) |
---|
| 43 | print(('on prend les premiers indice, shape (tmps, alt, var) =',shape(tim), shape(alt), shape(myvar))) |
---|
| 44 | #pal=get_cmap(name="RdYlBu_r") |
---|
| 45 | pal=get_cmap(name="Spectral_r") |
---|
| 46 | lev=np.linspace(40,50,10) |
---|
[3833] | 47 | # xticks=[0,2,4,6,8,10,12,14,16,18,20,22,24] |
---|
[3823] | 48 | print(('hello:',np.linspace(0,24,13))) |
---|
| 49 | #yticks=np.linspace(0,240,9) |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | CF=mpl.contourf(tim,alt,np.transpose(myvar),lev,cmap=pal,extend='both') |
---|
| 53 | cbar=mpl.colorbar(CF,shrink=1, format="%1.0f") |
---|
| 54 | cbar.ax.set_title("Temp [K]",y=1.04,fontsize=font) |
---|
| 55 | for t in cbar.ax.get_yticklabels(): |
---|
| 56 | t.set_fontsize(font) |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | vect=lev |
---|
| 60 | CS=mpl.contour(tim,alt,np.transpose(myvar),vect,colors='k',linewidths=0.5) |
---|
| 61 | #inline=1 : values over the line |
---|
| 62 | #mpl.clabel(CS, inline=2, fontsize=10, fmt='%1.1e') |
---|
| 63 | mpl.clabel(CS, inline=1, fontsize=15, fmt='%1.0f',inline_spacing=1) |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font) |
---|
| 67 | mpl.xlabel('Local Time (h)',labelpad=10,fontsize=font) |
---|
| 68 | mpl.ylabel('Altitude (km)',labelpad=10, fontsize=font) |
---|
[3833] | 69 | # mpl.xticks(xticks,fontsize=font) |
---|
| 70 | mpl.xticks(fontsize=font) |
---|
[3823] | 71 | #mpl.yticks(yticks,fontsize=font) |
---|
| 72 | mpl.yticks(fontsize=font) |
---|
| 73 | pylab.ylim([0,4]) |
---|
| 74 | |
---|
| 75 | mpl.savefig('temploctime.eps',dpi=200) |
---|
| 76 | mpl.savefig('temploctime.png',dpi=200) |
---|
| 77 | mpl.show() |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|