source: trunk/MESOSCALE/PLOT/RESERVE/hovmuller.pro @ 205

Last change on this file since 205 was 85, checked in by aslmd, 14 years ago

LMD_MM_MARS et LMD_LES_MARS: ajout des routines IDL pour tracer les sorties --> voir mesoscale/PLOT

File size: 4.8 KB
Line 
1pro hovmuller, $
2        what_I_plot, $                          ; 2D field
3        space, $                                ; space coordinate
4        time, $                                 ; time coordinate
5        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
6        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
7        minspace=minspace, $                    ; minimum value of space window (=0: calculate)
8        maxspace=maxspace, $                    ; maximum value of space window (=0: calculate)
9        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
10        ct=pal, $                               ; color table (33-rainbow is default)
11        colors=colors, $                        ; number of colors/levels (32 is default)
12        title=title                             ; title of the plot ('' is default)
13
14;--------------------------------------------
15;
16; A general routine to plot hovmuller maps
17;
18; USE:  - hovmuller, what_I_plot       
19;       - hovmuller, what_I_plot, space, time
20;       - ... and see options above
21;
22;--------------------------------------------
23; A. Spiga, September 2007
24;--------------------------------------------
25
26
27
28
29;---------------------------
30; a few permanent settings
31;---------------------------
32;
33missing_value=1.e30
34@param_plot.idl
35;
36;------------------
37
38
39;------------------
40; user settings
41;------------------
42if (n_elements(space) eq 0) then begin
43        space=findgen(n_elements(what_I_plot(*,0)))
44endif
45if (n_elements(time) eq 0) then begin
46        time=findgen(n_elements(what_I_plot(0,*)))
47endif
48
49if (n_elements(minfield_init) eq 0) then minfield_init=0.
50if (n_elements(maxfield_init) eq 0) then maxfield_init=0.
51if (n_elements(minspace) eq 0) then minspace=0.
52if (n_elements(maxspace) eq 0) then maxspace=0.
53if (n_elements(colors) eq 0) then colors=32
54if (n_elements(title) eq 0) then title=''
55if (n_elements(pal) eq 0) then pal=33
56if (n_elements(overcontour) eq 0) then overcontour=0.
57if (n_elements(titlex) eq 0) then titlex='space'
58if (n_elements(titley) eq 0) then titley='time'
59
60;------------------
61; limits
62;------------------
63if (minfield_init*maxfield_init eq 0) then begin   
64        ;---different min/max for each layer
65        w=where(abs(what_I_plot) lt missing_value)
66        if (w(0) ne -1) then begin
67                minfield=min(what_I_plot[w])
68                maxfield=max(what_I_plot[w])
69        endif else begin
70                what_I_plot=0.
71                print, 'no valid values in this field'
72        endelse
73endif else begin
74        ;---user-defined limits
75        minfield=minfield_init
76        maxfield=maxfield_init
77        ;;w=where(what_I_plot lt minfield) & if (w(0) ne -1) then what_I_plot[w]=minfield
78        ;;w=where(what_I_plot gt maxfield) & if (w(0) ne -1) then what_I_plot[w]=maxfield
79endelse
80
81if ((minfield+maxfield eq 0) and (abs(minfield) ne abs(maxfield))) then begin
82        print, 'nothing to plot ... skipping this plot ...'
83endif else begin
84
85
86
87;-----------------------------------------
88; fix the possible longitude ugliness :)
89; ...get rid of the -180/180 limit
90;-----------------------------------------
91
92w=where(space eq min(space))
93if (w(0) ne 0) then begin
94        space[0:w(0)-1]=space[0:w(0)-1]-360
95endif
96
97
98;---------------
99; adapt ticks
100;---------------
101if ((minspace eq 0) and (maxspace eq 0)) then begin
102        minspace=min(space)
103        maxspace=max(space)
104endif
105intervalx=round((maxspace-minspace)/8.)
106intervaly=round((max(time)-min(time))/5.)
107intervalx=60.
108intervaly=4.
109
110
111;------------------
112; plot window
113;------------------
114
115        ; to ensure the right limits
116        dumb_what_I_plot=what_I_plot
117        dumb_what_I_plot(*,*)=minfield & print, minfield
118        dumb_what_I_plot(0,0)=maxfield & print, maxfield
119
120
121loadct,0,/silent 
122contour, $
123        /nodata, $
124        dumb_what_I_plot, $
125        space, $
126        time, $
127        title=title, $
128        xtitle=titlex, $
129        xrange=[minspace,maxspace], $
130        ytitle=titley, $
131        yrange=[min(time),max(time)], $
132        xtickinterval=intervalx, ytickinterval=intervaly, $
133;       position=[0.15, 0.15, 0.95, 0.75], $
134        color=0
135
136
137
138;------------------
139; plot field
140;------------------
141
142;lim=45.
143;ecart=5.
144;yeah=-lim + ecart*findgen(lim*2./5.)
145
146loadct,pal,/silent
147contour, what_I_plot, $
148        space, $
149        time, $
150        nlevels=colors, $
151;lev=yeah, $
152        /cell_fill, $
153        max_value=maxfield, $
154        min_value=minfield, $   
155        /overplot
156
157
158;------------------
159; colorbar
160;------------------
161
162;;format_colorbar='(F6.2)'
163;;format_colorbar='(F10.3)'
164;;format_colorbar='(F12.2)'
165;format_colorbar='(F4.0)'  ;temperature
166;colorbar, $
167;;      position=[0.15, 0.85, 0.95, 0.90], $
168;       /vertical, $
169;       divisions=8, $
170;       range=[minfield,maxfield], $
171;       format=format_colorbar
172
173;--------------------
174; overplot contour
175;--------------------
176if (n_elements(overcontour) ne 1) then begin
177
178        w=where(abs(overcontour) lt missing_value)
179        if (w(0) ne -1) then begin
180                min_contour=min(overcontour[w])
181                max_contour=max(overcontour[w])
182        endif
183
184loadct,0,/silent
185contour, overcontour, $
186        space,time, $
187        nlevels=colors/2, $
188        max_value=max_contour, $
189        min_value=min_contour, $       
190        c_labels=findgen(colors/2), $
191        color=0, $
192        /noerase, $
193        xtitle='space', $
194        xrange=[min(space),max(space)], $
195        ytitle='time', $
196        yrange=[min(time),max(time)], $
197        xtickinterval=intervalx, ytickinterval=intervaly, $
198        position=[0.15, 0.15, 0.95, 0.75]
199
200endif
201
202
203endelse
204
205end
Note: See TracBrowser for help on using the repository browser.