source: trunk/procs/fld_pltext.pro @ 205

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

homegenize THEN BEGIN ... ENDIF

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1;+
2;
3; Define field plot attributes min/max
4;
5; @param VAR_NAME {in}{required}{type=string}
6; variable name
7;
8; @param PLTTYP {in}{required}{type=string}
9; plot type
10;
11; @param DIMPLOT {in}{required}{type=integer}
12; dimension of plot (1,2)
13;
14; @param HOTYP {in}{required}{type=string}
15;
16; @returns
17; outputs structure
18;
19; -1 in case of error
20;
21; @examples
22;
23; IDL> var_name='temp_1'
24; IDL> hotyp='-'
25; IDL> plttyp='pltt'
26; IDL> dimplot=1
27; IDL> free_1d_minmax='yes'
28; IDL> result=fld_pltext(var_name, plttyp, dimplot, hotyp)
29; IDL> help, result,/structure
30; ** Structure <84797cc>, 10 tags, length=56, data length=56, refs=1:
31;    NAME            STRING    'temp_1'
32;    ASSOS           STRING    'temp'
33;    MIN             FLOAT          -2.00000
34;    MAX             FLOAT           30.0000
35;    HOMIN           FLOAT           3.68000
36;    HOMAX           FLOAT           3.71000
37;    MIN1D           FLOAT               NaN
38;    MAX1D           FLOAT               NaN
39;    DMAX            FLOAT           3.00000
40;    SPEC            FLOAT               NaN
41;
42; IDL> print, result
43; { temp_1 temp     -2.00000      30.0000      3.68000      3.71000          NaN          NaN      3.00000
44;           NaN}
45;
46; @uses
47; <pro>common</pro>
48; <propost_it>com_eg</propost_it>
49;
50; @todo
51; get rid of spawn
52;
53; explication sur common free_1d_minmax
54;
55; @history
56;
57; - fplod 20091210T080930Z aedon.locean-ipsl.upmc.fr (Darwin)
58;
59;   * check parameters
60;
61; - EG 4/10/99
62;
63; @version
64; $Id$
65;
66;-
67FUNCTION fld_pltext, var_name, plttyp, dimplot, hotyp
68;
69  compile_opt idl2, strictarrsubs
70;
71@common
72@com_eg
73;
74; Return to caller if errors
75 ON_ERROR, 2
76;
77 usage='result=fld_pltext(var_name, plttyp, dimplot, hotyp)
78;
79 nparam = N_PARAMS()
80 IF (nparam LT 4) THEN BEGIN
81    ras = report(['Incorrect number of arguments.' $
82          + '!C' $
83          + 'Usage : ' + usage])
84    return, -1
85 ENDIF
86
87 arg_type = size(var_name,/type)
88 IF (arg_type NE 7) THEN BEGIN
89   ras = report(['Incorrect arg type var_name' $
90          + '!C' $
91          + 'Usage : ' + usage])
92    return, -1
93 ENDIF
94
95 arg_type = size(plttyp,/type)
96 IF (arg_type NE 7) THEN BEGIN
97   ras = report(['Incorrect arg type plttyp' $
98          + '!C' $
99          + 'Usage : ' + usage])
100   return, -1
101 ENDIF
102
103 arg_type = size(dimplot,/type)
104 IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN
105   ras = report(['Incorrect arg type dimplot' $
106          + '!C' $
107          + 'Usage : ' + usage])
108   return, -1
109 ENDIF
110
111 arg_type = size(hotyp,/type)
112 IF (arg_type NE 7) THEN BEGIN
113   ras = report(['Incorrect arg type hotyp' $
114          + '!C' $
115          + 'Usage : ' + usage])
116   return, -1
117 ENDIF
118
119 common_type=size(free_1d_minmax,/type)
120 IF (common_type NE 7) THEN BEGIN
121   ras = report(['Incorrect common type free_1d_minmax' $
122          + '!C' $
123          + 'Usage : ' + usage])
124   return, -1
125 ENDIF
126
127; define variable plot attributes (min/max)
128
129   fldextr = {name:'', assos:'', min: 0.0, max: 0.0, homin:0.0, homax:0.0, min1d:0.0, max1d:0.0, dmax:0.0, spec:0.0}
130
131; name of defaults files
132
133   file_mmx = 'fld_glo_mmx.def'
134
135; min/max
136   print,' '
137   print,'    Reading minmax of ',var_name,' from : ', file_mmx
138
139   spawn, 'grep -i "\ '+var_name+' " '+hom_def+file_mmx, line
140   line = strcompress(strtrim(line[0], 2))
141   length = strlen(line)
142
143   IF length EQ 0 THEN BEGIN
144      print, '     *** no min & max found for field ', var_name, $
145       ' in file fld_glo_mmx.def'
146         fldextr.min = min(field.data[where(field.data NE valmask)])
147         fldextr.max = max(field.data[where(field.data NE valmask)])
148         fldextr.homin = fldextr.min
149         fldextr.homax = fldextr.max
150         fldextr.min1d = fldextr.min
151         fldextr.max1d = fldextr.max
152         fldextr.dmax = max([abs(fldextr.min), abs(fldextr.max)])
153         fldextr.assos = var_name
154         fldextr.spec = 1.
155   ENDIF ELSE BEGIN
156      argvar = strsplit(line, ' ', /EXTRACT)
157      IF strmid(argvar[1], 0, 1) EQ '@' THEN BEGIN
158         ; get info from other variable
159         friend_name = strmid(argvar[1], 1, strlen(argvar[1])-1)
160         print, '      -> linked to ', friend_name
161         fldextr = fld_pltext(friend_name, plttyp, dimplot, hotyp)
162         fldextr.assos = friend_name
163      ENDIF ELSE  BEGIN
164         fldextr.min = float(argvar[1])
165         fldextr.max = float(argvar[2])
166         fldextr.homin = !VALUES.F_NAN
167         fldextr.homax = !VALUES.F_NAN
168         fldextr.min1d = !VALUES.F_NAN
169         fldextr.max1d = !VALUES.F_NAN
170         fldextr.dmax = !VALUES.F_NAN
171         fldextr.spec = !VALUES.F_NAN
172         IF debug_w THEN BEGIN
173          print, '   Number of args for fldext:', n_elements(argvar)
174         ENDIF
175         IF n_elements(argvar) GE 5 THEN BEGIN
176            fldextr.homin = float(argvar[3])
177            fldextr.homax = float(argvar[4])
178         ENDIF
179         IF n_elements(argvar) GE 7 THEN BEGIN
180            fldextr.min1d = float(argvar[5])
181            fldextr.max1d = float(argvar[6])
182         ENDIF
183         IF n_elements(argvar) GE 9 THEN BEGIN
184            fldextr.spec = float(argvar[8])
185         ENDIF
186
187         IF free_1d_minmax EQ 'yes' THEN BEGIN
188            IF hotyp EQ 't' THEN BEGIN
189               fldextr.homin = !VALUES.F_NAN
190               fldextr.homax = !VALUES.F_NAN
191            ENDIF
192            fldextr.min1d = !VALUES.F_NAN
193            fldextr.max1d = !VALUES.F_NAN
194         ENDIF
195         IF n_elements(argvar) GE 8 THEN BEGIN
196            fldextr.dmax = float(argvar[7])
197         ENDIF
198         tempvar = SIZE(TEMPORARY(argvar))
199         fldextr.assos = var_name
200      ENDELSE
201   ENDELSE
202
203   fldextr.name = var_name
204
205   return, fldextr
206END
Note: See TracBrowser for help on using the repository browser.