source: trunk/LMDZ.PLUTO/util/script_figures/proftempNH_obs.py @ 3823

Last change on this file since 3823 was 3823, checked in by afalco, 2 days ago

Pluto: added some python scripts for visualization.
AF

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#! /usr/bin/env python
2from ppclass import pp
3from    netCDF4               import    Dataset
4from    numpy                 import    *
5import  numpy                 as        np
6import  matplotlib.pyplot     as        mpl
7from matplotlib.cm import get_cmap
8import pylab
9from matplotlib import ticker
10import matplotlib.colors as colors
11import datetime
12from mpl_toolkits.basemap import Basemap, shiftgrid
13
14############################
15zefile="diagfi2015_A.nc"
16d1="restart_ref/"
17
18f1=d1+zefile
19
20
21var="temperature" #variable
22
23nc1=Dataset(f1)
24lat=nc1.variables["lat"][:]
25lon=nc1.variables["lon"][:]
26alt=nc1.variables["altitude"][:]
27tim=nc1.variables["time_counter"][:]
28
29print(('Time = ',tim))
30print(('Long = ',lon))
31print(('Lat = ',lat))
32
33############################
34
35def 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 
46def getvar(filename,var):
47    myvar = pp(file=filename,var=var,compute="nothing").getf()
48    return myvar
49
50def 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
56def 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
64p1=[-168.75, -18.75] # Entry
65p2=[-168.75, -30]    # sud est SP
66p2=[-164., -18.75]    # Entry un peu plus sur bord du bassin
67p3=[135, 45]    # Burney crater
68p4=[180, 45]    # SP
69p5=[-124, 2]    # BTD au fond
70p6=[-148,16]    # TR
71p7=[-5.625,86.25]    # Lowell
72p8=[-5.625,-86.25]    # south pole
73p7=[129.3,45]    # pente Burney
74p8=[166,-18]    # low SP west
75p9=[15,0]    # Exit
76
77tini=32  # choix du jour dans le diagfi
78lt0=0   # local time a t=0 et longitude=0
79ltchoice=16.5 # local time choisi
80ltchoice2=4 # local time choisi
81
82myvar1=main(tini,lt0,ltchoice,p1)
83#myvar2=main(tini,lt0,ltchoice,p2)
84#myvar3=main(tini,lt0,ltchoice,p3)
85myvar4=main(tini,lt0,ltchoice,p4)
86#myvar5=main(tini,lt0,ltchoice,p5)
87#myvar6=main(tini,lt0,ltchoice,p6)
88#myvar7=main(tini,lt0,ltchoice,p7)
89#myvar8=main(tini,lt0,ltchoice,p8)
90#myvar9=main(tini,lt0,ltchoice2,p9)
91
92
93mpl.figure(figsize=(10, 10))
94
95font=23
96
97alt=alt/1000.
98
99mpl.plot(myvar1,alt,'r',label='Entry')
100#mpl.plot(myvar2,alt,'g',label='Entry-like on edge')
101#mpl.plot(myvar3,alt,'k',label='Burney crater')
102mpl.plot(myvar4,alt,'k',label='Sputnik Planitia')
103#mpl.plot(myvar5,alt,'c',label='BTD')
104#mpl.plot(myvar6,alt,'b',label='TR')
105#mpl.plot(myvar7,alt,'y',label='Lowell')
106#mpl.plot(myvar8,alt,'orange',label='southpole')
107#mpl.plot(myvar7,alt,'y',label='Slope Burney')
108#mpl.plot(myvar8,alt,'orange',label='South-West SP')
109#mpl.plot(myvar9,alt,'b',label='Exit')
110
111mpl.legend(prop={'size':20},loc='upper left')
112#mpl.title('Latitude ='+str(tintstr[i]),fontsize=font)
113mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font)
114mpl.xlabel('Temperature (K)',labelpad=10, fontsize=font)
115#mpl.xticks(xticks,fontsize=font)
116mpl.xticks(fontsize=font)
117#mpl.yticks(yticks,fontsize=font)
118mpl.yticks(fontsize=font)
119mpl.grid()
120#mpl.legend(["Ref","Alt"])
121
122pylab.ylim([-3,2])
123pylab.xlim([35,50])
124
125#mpl.savefig('proftempNH_'+str(ltchoice)+'h.eps',dpi=200)
126#mpl.savefig('proftempNH_'+str(ltchoice)+'h.png',dpi=200)
127mpl.show()
128
129
Note: See TracBrowser for help on using the repository browser.