1 | ;------------------------------------------------------------ |
---|
2 | ;+ |
---|
3 | ; |
---|
4 | ; @file_comments |
---|
5 | ; Trace 1d graphs: x,y,z (or t but in this case, we recall directly pltt) |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; Graphics |
---|
9 | ; |
---|
10 | ; @param TAB {in}{required} |
---|
11 | ; The field whose we want to make the hovmoller map can be 2 kind of thing: |
---|
12 | ; 1) An array which can be: |
---|
13 | ; * 2d, 3d or 4d: array xy, xyz. xyt or xyzt. In this case, the array will pass |
---|
14 | ; in moyenne or grossemoyenne to be averaged and become an array 1d. |
---|
15 | ; * 1d:Nevertheless, the type must be specified in order to we know which trace |
---|
16 | ; it is about. To have a correct caption, respecify the extraction zone via BOXZOOM. |
---|
17 | ; 2) a structure respecting all criterions specified by litchamp.pro. |
---|
18 | ; See IDL> xhelp,'litchamp'. The array contained in the structure |
---|
19 | ; respecting criterions of case 1) |
---|
20 | ; |
---|
21 | ; @param PARAM2 {in}{required} |
---|
22 | ; Min value we want to consider in the contour's drawing. |
---|
23 | ; Note: could also be the type of plot:'x','y','z' |
---|
24 | ; |
---|
25 | ; @param PARAM3 {in}{optional}{default=min/max of tab (on ocean points)} |
---|
26 | ; Max value we want to consider in the contour's drawing. |
---|
27 | ; Note: if param2 is defined as 'x','y','z' then param3 is used to define the min (see param2) |
---|
28 | ; |
---|
29 | ; @param PARAM4 {in}{optional}{default=max of tab (on ocean points)} |
---|
30 | ; Type of plot (can be only 'x','y','z' for plt1d). |
---|
31 | ; Note: if param2 is defined as 'xy' then param4 is used to define the max (see param3) |
---|
32 | ; |
---|
33 | ; @keyword BOXZOOM |
---|
34 | ; Vector indicating the geographic zone (3d) on which the extraction of the field must |
---|
35 | ; be done to do the hovmoeller. |
---|
36 | ; If BOXZOOM has : |
---|
37 | ; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] |
---|
38 | ; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] |
---|
39 | ; 4 elements: The extraction is made on [Boxzoom, vert1, vert2] |
---|
40 | ; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
41 | ; 6 elements: The extraction is made on Boxzoom |
---|
42 | ; |
---|
43 | ; Where lon1, lon2,lat1,lat2,vert1,vert2 are global variables defined at the last domdef! |
---|
44 | ; |
---|
45 | ; @keyword COL1d |
---|
46 | ; --OBSOLETE--Color number when we make a trace 1d by default, 0.It is better to use the |
---|
47 | ; keyword COLOR used by plot. |
---|
48 | ; |
---|
49 | ; @keyword ENDPOINTS |
---|
50 | ; keyword specifying that we want to make a vertical cut in diagonal. Then coordinated of extremities |
---|
51 | ; of these one are defined by the 4 elements of the vector ENDPOINTS: [x1,y1,x2,y2] which are |
---|
52 | ; coordinates. |
---|
53 | ; |
---|
54 | ; @keyword MAXIN |
---|
55 | ; Allows to specify the max value we want to consider in the drawing of contour |
---|
56 | ; helping by the keyword instead of the argument max. If the argument and the keyword are |
---|
57 | ; specified in the same time, it is the value specified by the keyword which is retained. |
---|
58 | ; |
---|
59 | ; @keyword MININ |
---|
60 | ; Allows to specify the min value we want to consider in the drawing of contour |
---|
61 | ; helping by the keyword instead of the argument min. If the argument and the keyword are |
---|
62 | ; specified in the same time, it is the value specified by the keyword which is retained. |
---|
63 | ; |
---|
64 | ; @keyword OV1D |
---|
65 | ; Allow the double exposure of an 1d curve to a precedent 1d trace. |
---|
66 | ; |
---|
67 | ; @keyword REVERSE_X |
---|
68 | ; To invert the x axis (so as the drawing) |
---|
69 | ; |
---|
70 | ; @keyword REVERSE_Y |
---|
71 | ; To invert the y axis (so as the drawing) |
---|
72 | ; |
---|
73 | ; @keyword SIN |
---|
74 | ; Activate this keyword if we want the x axis to be traced in sinus of the |
---|
75 | ; latitude when we make a drawing f(y) |
---|
76 | ; |
---|
77 | ; @keyword STY1D |
---|
78 | ; --OBSOLETE-- |
---|
79 | ; Number of the style used when we make a 1d drawing. We should better use the |
---|
80 | ; keyword LINESTYLE which is tho one of the plot. Beware, this keyword is still |
---|
81 | ; useful if we want to d bars instead of curves, put sty1d='bar' |
---|
82 | ; |
---|
83 | ; @keyword TYPEIN |
---|
84 | ; allows to specify the type of hovmoller we want to do |
---|
85 | ; 'xt','yt','zt','t' |
---|
86 | ; with help of a keyword rather than the argument type. If the argument and the |
---|
87 | ; keyword are specified in the same time, it is the value specified by the |
---|
88 | ; keyword which is retained. |
---|
89 | ; |
---|
90 | ; @keyword _EXTRA |
---|
91 | ; used to pass your keywords |
---|
92 | ; |
---|
93 | ; @history |
---|
94 | ; creation 24/6/99 Eric Guilyardi |
---|
95 | ; (a partir routine pltt de Sebastien Masson) |
---|
96 | ; 8/7/1999 Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
97 | ; inspection des travaux finis |
---|
98 | ; 8/2/2000 Sebastien Masson: checkfield |
---|
99 | ; |
---|
100 | ; @version |
---|
101 | ; $Id$ |
---|
102 | ; |
---|
103 | ;- |
---|
104 | ;------------------------------------------------------------ |
---|
105 | ;------------------------------------------------------------ |
---|
106 | ;------------------------------------------------------------ |
---|
107 | pro plt1d, tab, param2, param3, param4, BOXZOOM = boxzoom, SIN = sin $ |
---|
108 | , MININ = minin, MAXIN = maxin, TYPEIN = typein, ENDPOINTS = endpoints $ |
---|
109 | , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, X = x, Y = y, Z = z, TT = tt $ |
---|
110 | , REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SWITCHXY = switchxy $ |
---|
111 | , _extra = ex |
---|
112 | ;--------------------------------------------------------- |
---|
113 | ; include common |
---|
114 | ; |
---|
115 | compile_opt idl2, strictarrsubs |
---|
116 | ; |
---|
117 | @cm_4mesh |
---|
118 | @cm_4data |
---|
119 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
120 | @updatenew |
---|
121 | @updatekwd |
---|
122 | ENDIF |
---|
123 | ;------------------------------------------------------------ |
---|
124 | tempsun = systime(1) ; pour key_performance |
---|
125 | ;-------------------------------------------------------------- |
---|
126 | ; 1st part: initialization small calculations... |
---|
127 | ;-------------------------------------------------------------- |
---|
128 | ;-------------------------------------------------------------- |
---|
129 | ;-------------------------------------------------------------- |
---|
130 | ; verification of the type's value |
---|
131 | ;-------------------------------------------------------------- |
---|
132 | ; |
---|
133 | if n_elements(param2) NE 0 then type = param2 |
---|
134 | if n_elements(param3) NE 0 then min = param3 |
---|
135 | if n_elements(param4) NE 0 then max = param4 |
---|
136 | if n_elements(minin) NE 0 then min = minin |
---|
137 | if n_elements(maxin) NE 0 then max = maxin |
---|
138 | if keyword_set(tt) then typein = 't' |
---|
139 | if keyword_set(typein) then BEGIN |
---|
140 | if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin |
---|
141 | if n_elements(min) NE 0 then max = min |
---|
142 | min = type |
---|
143 | endif |
---|
144 | type = typein |
---|
145 | endif |
---|
146 | ; |
---|
147 | checktypeminmax, 'plt1d', TYPE = type, MIN = min, MAX = max, ENDPOINTS = endpoints $ |
---|
148 | , XX = keyword_set(x), YY = keyword_set(y), ZZ = keyword_set(z) |
---|
149 | if type EQ 't' then BEGIN |
---|
150 | pltt, tab, type, min, max, BOXZOOM = boxzoom, SIN = sin, TYPEIN = typein $ |
---|
151 | , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, ENDPOINTS = endpoints, _extra = ex |
---|
152 | return |
---|
153 | endif |
---|
154 | ;-------------------------------------------------------------- |
---|
155 | ; I2) reinitialization. !p.,!x.,!y. |
---|
156 | ; Comment: We do not reinitializate when we call back plt1d |
---|
157 | ;-------------------------------------------------------------- |
---|
158 | if NOT keyword_set(ov1d) then reinitplt |
---|
159 | ;-------------------------------------------------------------- |
---|
160 | ; I1) Reading of the field |
---|
161 | ;-------------------------------------------------------------- |
---|
162 | if (keyword_set(boxzoom) OR keyword_set(endpoints)) THEN BEGIN |
---|
163 | savedbox = 1b |
---|
164 | saveboxparam, 'boxparam4plt1d.dat' |
---|
165 | ENDIF |
---|
166 | ; |
---|
167 | if keyword_set(endpoints) then begin |
---|
168 | section, tab, z1d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $ |
---|
169 | , BOXZOOM = boxzoom, DIREC = direc |
---|
170 | nx = n_elements(glam) |
---|
171 | ny = nx |
---|
172 | if strupcase(vargrid) EQ 'W' then begin |
---|
173 | z = gdepw[firstzw:lastzw] |
---|
174 | nz = nzw |
---|
175 | ENDIF ELSE BEGIN |
---|
176 | z = gdept[firstzt:lastzt] |
---|
177 | nz = nzt |
---|
178 | ENDELSE |
---|
179 | ENDIF ELSE BEGIN |
---|
180 | z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $ |
---|
181 | , direc = direc, _extra = ex) |
---|
182 | grille, mask, glam, gphi, gdep, nx, ny, nz, type = type |
---|
183 | ENDELSE |
---|
184 | if z1d[0] EQ -1 then BEGIN |
---|
185 | IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat' |
---|
186 | return |
---|
187 | endif |
---|
188 | ; We build the mask. For this, the array must be hidden (Automaticaly done at valmask |
---|
189 | ; value if we pass in moyenne or grossemoyenne) |
---|
190 | mask = fltarr(n_elements(z1d)) |
---|
191 | if n_elements(valmask) EQ 0 then valmask = 1e20 |
---|
192 | nan = total(finite(z1d, /nan)) < 1 |
---|
193 | if keyword_set(nan) then begin |
---|
194 | notanum = where(finite(z1d) EQ 0) |
---|
195 | z1d[notanum] = 0 |
---|
196 | mask[where(z1d LT valmask/10)] = 1 |
---|
197 | z1d[notanum] = !values.f_nan |
---|
198 | ENDIF ELSE mask[where(z1d LT valmask/10)] = 1 |
---|
199 | ;----------------------------------------------------------------------------- |
---|
200 | ; determination of the min and of the max after the average |
---|
201 | ;----------------------------------------------------------------------------- |
---|
202 | nan = total(finite(z1d, /nan)) < 1 |
---|
203 | determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex |
---|
204 | if z1d[0] EQ -1 THEN return |
---|
205 | ;----------------------------------------------------------------------------- |
---|
206 | ;----------------------------------------------------------------------------- |
---|
207 | if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex |
---|
208 | ;-------------------------------------------------------------- |
---|
209 | ;-------------------------------------------------------------- |
---|
210 | ; 2nd part: Drawing |
---|
211 | ;-------------------------------------------------------------- |
---|
212 | ;----------------------------------------------------------------------------- |
---|
213 | ; definition of the abscisse and ordinate vectors. |
---|
214 | ; The triangulation is defined in order to the drawing be done from the |
---|
215 | ; left bottom to the right up. So the matrix have to be shown like this, |
---|
216 | ; from which some transpose and reverse |
---|
217 | ;----------------------------------------------------------------------------- |
---|
218 | ;----------------------------------------------------------------------------- |
---|
219 | case type of |
---|
220 | 'y': begin |
---|
221 | yy = z1d |
---|
222 | IF (size(gphi))[0] EQ 1 then xx = gphi ELSE BEGIN |
---|
223 | IF keyword_set(key_irregular) THEN BEGIN |
---|
224 | cln = (where(gphi EQ max(gphi)))[0] |
---|
225 | xx = reform(gphi[cln MOD nx, *]) |
---|
226 | ENDIF ELSE xx = reform(gphi[0, *]) |
---|
227 | ENDELSE |
---|
228 | if keyword_set(sin) then xx = sin(!pi/180.*xx) |
---|
229 | min0 = lat1 & max0 = lat2 |
---|
230 | END |
---|
231 | 'x':begin |
---|
232 | yy = z1d |
---|
233 | xx = glam[*, 0] |
---|
234 | min0 = lon1 & max0 = lon2 |
---|
235 | END |
---|
236 | 'z':begin |
---|
237 | yy = reverse(gdep, 1) |
---|
238 | xx = reverse(z1d, 1) |
---|
239 | min0 = 0 & max0 = 0 |
---|
240 | case n_elements(boxzoom) of |
---|
241 | 0:!y.range = [vert1, vert2] |
---|
242 | 1:!y.range = [0, boxzoom] |
---|
243 | 2:!y.range = boxzoom |
---|
244 | 4:!y.range = [vert1, vert2] |
---|
245 | 5:!y.range = [0, boxzoom[4]] |
---|
246 | 6:!y.range = boxzoom[4:5] |
---|
247 | endcase |
---|
248 | if NOT keyword_set(ov1d) then !y.range = reverse(!y.range) |
---|
249 | END |
---|
250 | ENDCASE |
---|
251 | ;----------------------------------------------------------- |
---|
252 | ;----------------------------------------------------------- |
---|
253 | ; definition of axes |
---|
254 | ;---------------------------------------------------------- |
---|
255 | ; if keyword_set(integrationtps) then axe, type, time[0], time[jpt-1], SIN = sin, _extra = ex $ |
---|
256 | ; ELSE axe, type, SIN = sin |
---|
257 | if NOT keyword_set(ov1d) then axe, type, SIN = sin |
---|
258 | ;------------------------------------------------------------ |
---|
259 | ;------------------------------------------------------------ |
---|
260 | ; drawing |
---|
261 | ;------------------------------------------------------------ |
---|
262 | ;------------------------------------------------------------ |
---|
263 | if type EQ 'z' then begin |
---|
264 | idx = where(xx NE valmask) |
---|
265 | if NOT keyword_set(ov1d) then BEGIN |
---|
266 | if min EQ mi then !x.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $ |
---|
267 | ELSE !x.range = [min, max] |
---|
268 | ENDIF |
---|
269 | ENDIF ELSE BEGIN |
---|
270 | idx = where(yy NE valmask) |
---|
271 | if NOT keyword_set(ov1d) then BEGIN |
---|
272 | if min EQ mi then !y.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $ |
---|
273 | ELSE !y.range = [min, max] |
---|
274 | ENDIF |
---|
275 | ENDELSE |
---|
276 | ; |
---|
277 | if NOT keyword_set(ov1d) then BEGIN |
---|
278 | legende, mi, ma, type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex |
---|
279 | ; |
---|
280 | ENDIF |
---|
281 | IF keyword_set(switchxy) THEN BEGIN |
---|
282 | tmp = xx |
---|
283 | xx = yy |
---|
284 | yy = temporary(tmp) |
---|
285 | if NOT keyword_set(ov1d) then BEGIN |
---|
286 | tmp = !x |
---|
287 | !x = !y |
---|
288 | !y = temporary(tmp) |
---|
289 | ENDIF |
---|
290 | ENDIF |
---|
291 | if NOT keyword_set(ov1d) then BEGIN |
---|
292 | if keyword_set(reverse_x) then !x.range = reverse(!x.range) |
---|
293 | if keyword_set(reverse_y) then !y.range = reverse(!y.range) |
---|
294 | ENDIF |
---|
295 | ; |
---|
296 | xx = xx[idx] |
---|
297 | yy = yy[idx] |
---|
298 | if (not keyword_set(col1d)) then col1d = 0 |
---|
299 | if keyword_set(sty1d) then BEGIN ;If we want to make bars |
---|
300 | IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin |
---|
301 | !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05, !y.range[1]] |
---|
302 | bar_plot, yy, background = (!d.n_colors-1) < 255, $ |
---|
303 | baselines = replicate(!y.range[0], n_elements(yy)), barnames = ['', ''], $ |
---|
304 | colors = replicate(col1d, n_elements(yy)), /outline |
---|
305 | if n_elements(ex) NE 0 then BEGIN |
---|
306 | ; To have a black frame |
---|
307 | if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0 |
---|
308 | ENDIF |
---|
309 | plot, [0], [0], /noerase, /nodata, _extra = ex |
---|
310 | GOTO, fini |
---|
311 | ENDIF |
---|
312 | ENDIF |
---|
313 | ; |
---|
314 | if NOT keyword_set(ov1d) then BEGIN |
---|
315 | ; |
---|
316 | plot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, title = '', subtitle = '', _extra = ex |
---|
317 | if n_elements(ex) NE 0 then BEGIN |
---|
318 | ; To have a 0 colored frame and trace a line at y=0 |
---|
319 | if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0 |
---|
320 | if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE = 0 |
---|
321 | if (where(tag_names(ex) EQ 'THICK'))[0] NE -1 then ex.THICK = 0 |
---|
322 | ENDIF |
---|
323 | plot, !x.range, [0, 0], /noerase, /nodata $ |
---|
324 | , xstyle = 1+4*(keyword_set(endpoints) AND $ |
---|
325 | ((type EQ 'x' AND lat1 NE lat2) OR (type EQ 'y' AND lon1 NE lon2))) $ |
---|
326 | , ystyle = 1, _extra = ex |
---|
327 | ; Add of an axis in the case where we use endpoints |
---|
328 | if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex |
---|
329 | ; Trace a line at x=0 |
---|
330 | plot, [0, 0], !y.range, /noerase, /nodata, title = '', subtitle = '', _extra = ex |
---|
331 | ENDIF ELSE oplot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, _extra = ex |
---|
332 | ;------------------------------------------------------------ |
---|
333 | ;------------------------------------------------------------ |
---|
334 | ; 3rd part: Possible print. |
---|
335 | ;------------------------------------------------------------ |
---|
336 | ;------------------------------------------------------------ |
---|
337 | fini: |
---|
338 | terminedessin, _extra = ex |
---|
339 | if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat' |
---|
340 | ;------------------------------------------------------------ |
---|
341 | if n_elements(key_performance) NE 0 then $ |
---|
342 | IF key_performance EQ 1 THEN print, 'temps plt1d', systime(1)-tempsun |
---|
343 | ;------------------------------------------------------------ |
---|
344 | ;------------------------------------------------------------ |
---|
345 | ;------------------------------------------------------------ |
---|
346 | return |
---|
347 | end |
---|
348 | |
---|
349 | |
---|