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