1 | #! /usr/bin/env python |
---|
2 | from ppclass import pp |
---|
3 | from netCDF4 import Dataset |
---|
4 | from numpy import * |
---|
5 | import numpy as np |
---|
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 | |
---|
14 | ############################ |
---|
15 | zefile="diagfi2015_A.nc" |
---|
16 | d1="restart_ref/" |
---|
17 | |
---|
18 | f1=d1+zefile |
---|
19 | |
---|
20 | |
---|
21 | var="temperature" #variable |
---|
22 | |
---|
23 | nc1=Dataset(f1) |
---|
24 | lat=nc1.variables["lat"][:] |
---|
25 | lon=nc1.variables["lon"][:] |
---|
26 | alt=nc1.variables["altitude"][:] |
---|
27 | tim=nc1.variables["time_counter"][:] |
---|
28 | |
---|
29 | print(('Time = ',tim)) |
---|
30 | print(('Long = ',lon)) |
---|
31 | print(('Lat = ',lat)) |
---|
32 | |
---|
33 | ############################ |
---|
34 | |
---|
35 | def findindextime(tini,lt0,lt1,p): |
---|
36 | lt180=(lt0+12)%24 # a t=0 et longitude=180 |
---|
37 | lt0p1=lt180*((p[0]+360)%360)/180 # local time a t=0 a la longitude p1 |
---|
38 | diff=lt1-lt0p1 # diff du local time a p1 a t=0 avec celui recherche |
---|
39 | indp1=tini+diff/24. # on adapte lindice pour tomber sur le bon moment |
---|
40 | |
---|
41 | # on cherche dans Time l'indice le plus proche : |
---|
42 | indt1=np.where(abs(tim[:]-indp1)==min(abs(tim[:]-indp1)))[0][0] |
---|
43 | print(('Point =',p,' Time=',tim[indt1])) |
---|
44 | return indt1 |
---|
45 | |
---|
46 | def getvar(filename,var): |
---|
47 | myvar = pp(file=filename,var=var,compute="nothing").getf() |
---|
48 | return myvar |
---|
49 | |
---|
50 | def getindex(lat,lon,mylat,mylon): |
---|
51 | indlat=np.where(abs(lat[:]-mylat)==min(abs(lat[:]-mylat)))[0][0] |
---|
52 | indlon=np.where(abs(lon[:]-mylon)==min(abs(lon[:]-mylon)))[0][0] |
---|
53 | print((lon[indlon],lat[indlat])) |
---|
54 | return indlat,indlon |
---|
55 | |
---|
56 | def main(tini,lt0,ltchoice,p): |
---|
57 | indt=findindextime(tini,lt0,ltchoice,p) |
---|
58 | indlat,indlon=getindex(lat,lon,p[1],p[0]) |
---|
59 | myvar=getvar(f1,var)[indt,:,indlat,indlon] |
---|
60 | return myvar |
---|
61 | ############################ |
---|
62 | |
---|
63 | #points: entre -180 et 180 |
---|
64 | p1=[-168.75, -18.75] # Entry |
---|
65 | p2=[-168.75, -30] # sud est SP |
---|
66 | p2=[-164., -18.75] # Entry un peu plus sur bord du bassin |
---|
67 | p3=[135, 45] # Burney crater |
---|
68 | p4=[180, 45] # SP |
---|
69 | p5=[-124, 2] # BTD au fond |
---|
70 | p6=[-148,16] # TR |
---|
71 | p7=[-5.625,86.25] # Lowell |
---|
72 | p8=[-5.625,-86.25] # south pole |
---|
73 | p7=[129.3,45] # pente Burney |
---|
74 | p8=[166,-18] # low SP west |
---|
75 | |
---|
76 | tini=32 # choix du jour dans le diagfi |
---|
77 | lt0=0 # local time a t=0 et longitude=0 |
---|
78 | ltchoice=16.5 # local time choisi |
---|
79 | |
---|
80 | myvar1=main(tini,lt0,ltchoice,p1) |
---|
81 | myvar2=main(tini,lt0,ltchoice,p2) |
---|
82 | myvar3=main(tini,lt0,ltchoice,p3) |
---|
83 | myvar4=main(tini,lt0,ltchoice,p4) |
---|
84 | myvar5=main(tini,lt0,ltchoice,p5) |
---|
85 | myvar6=main(tini,lt0,ltchoice,p6) |
---|
86 | myvar7=main(tini,lt0,ltchoice,p7) |
---|
87 | myvar8=main(tini,lt0,ltchoice,p8) |
---|
88 | |
---|
89 | |
---|
90 | mpl.figure(figsize=(10, 10)) |
---|
91 | |
---|
92 | font=23 |
---|
93 | |
---|
94 | alt=alt/1000. |
---|
95 | |
---|
96 | mpl.plot(myvar1,alt,'r',label='Entry') |
---|
97 | mpl.plot(myvar2,alt,'g',label='Entry-like on edge') |
---|
98 | mpl.plot(myvar3,alt,'k',label='Burney crater') |
---|
99 | mpl.plot(myvar4,alt,'m',label='SP') |
---|
100 | mpl.plot(myvar5,alt,'c',label='BTD') |
---|
101 | mpl.plot(myvar6,alt,'b',label='TR') |
---|
102 | #mpl.plot(myvar7,alt,'y',label='Lowell') |
---|
103 | #mpl.plot(myvar8,alt,'orange',label='southpole') |
---|
104 | mpl.plot(myvar7,alt,'y',label='Slope Burney') |
---|
105 | mpl.plot(myvar8,alt,'orange',label='South-West SP') |
---|
106 | |
---|
107 | mpl.legend(prop={'size':20},loc='upper left') |
---|
108 | #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font) |
---|
109 | mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) |
---|
110 | mpl.xlabel('Temperature (K)',labelpad=10, fontsize=font) |
---|
111 | #mpl.xticks(xticks,fontsize=font) |
---|
112 | mpl.xticks(fontsize=font) |
---|
113 | #mpl.yticks(yticks,fontsize=font) |
---|
114 | mpl.yticks(fontsize=font) |
---|
115 | mpl.grid() |
---|
116 | #mpl.legend(["Ref","Alt"]) |
---|
117 | |
---|
118 | pylab.ylim([-4,6]) |
---|
119 | pylab.xlim([30,60]) |
---|
120 | |
---|
121 | mpl.savefig('proftempNH_'+str(ltchoice)+'h.eps',dpi=200) |
---|
122 | mpl.savefig('proftempNH_'+str(ltchoice)+'h.png',dpi=200) |
---|
123 | mpl.show() |
---|
124 | |
---|
125 | |
---|