source: trunk/procs/fld_pltint.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: 4.7 KB
Line 
1;+
2;
3; Define field plot attributes min/max/int/mult
4;
5; @param VAR_NAME {in}{required}{type=string}
6; variable name
7;
8; @param PLTTYP {in}{in}{required}{type=string}
9; plot type
10;
11; @param DIMPLOT {in}{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; define variable plot attributes (contour intervals)
19;
20; @examples
21;
22; IDL> var_name='temp_1'
23; IDL> hotyp='-'
24; IDL> plttyp='pltt'
25; IDL> dimplot=1
26; IDL> field={origin:'div'}
27; IDL> result=fld_pltint(var_name, plttyp, dimplot, hotyp)
28; IDL> help, result,/structure
29; ** Structure <8476b7c>, 6 tags, length=40, data length=40, refs=1:
30;    NAME            STRING    'temp_1'
31;    INT             FLOAT           1.00000
32;    MULT            FLOAT           1.00000
33;    ADD             FLOAT           0.00000
34;    UNIT            STRING    ''
35;    MID             FLOAT           26.0000
36;
37; IDL> print, result
38; { temp_1      1.00000      1.00000      0.00000       26.0000}
39;
40; @uses
41; <pro>common</pro>
42; <propost_it>com_eg</propost_it>
43;
44; @todo
45; get rid of spawn
46;
47; explication sur common field.origin
48;
49; @history
50; - fplod 20091210T080930Z aedon.locean-ipsl.upmc.fr (Darwin)
51;
52;   * check parameters
53;
54; - EG 25/2/99
55;
56; @version
57; $Id$
58;
59;-
60FUNCTION fld_pltint, var_name, plttyp, dimplot, hotyp
61;
62  compile_opt idl2, strictarrsubs
63;
64@common
65@com_eg
66;
67;
68; Return to caller if errors
69 ON_ERROR, 2
70;
71 usage='result=fld_pltint(var_name, plttyp, dimplot, hotyp)
72;
73 nparam = N_PARAMS()
74 IF (nparam LT 4) THEN BEGIN
75    ras = report(['Incorrect number of arguments.' $
76          + '!C' $
77          + 'Usage : ' + usage])
78    return, -1
79 ENDIF
80
81 arg_type = size(var_name,/type)
82 IF (arg_type NE 7) THEN BEGIN
83   ras = report(['Incorrect arg type var_name' $
84          + '!C' $
85          + 'Usage : ' + usage])
86    return, -1
87 ENDIF
88
89 arg_type = size(plttyp,/type)
90 IF (arg_type NE 7) THEN BEGIN
91   ras = report(['Incorrect arg type plttyp' $
92          + '!C' $
93          + 'Usage : ' + usage])
94   return, -1
95 ENDIF
96
97 arg_type = size(dimplot,/type)
98 IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN
99   ras = report(['Incorrect arg type dimplot' $
100          + '!C' $
101          + 'Usage : ' + usage])
102   return, -1
103 ENDIF
104
105 arg_type = size(hotyp,/type)
106 IF (arg_type NE 7) THEN BEGIN
107   ras = report(['Incorrect arg type hotyp' $
108          + '!C' $
109          + 'Usage : ' + usage])
110   return, -1
111 ENDIF
112
113   fldintr = {name:'', int: 0.0, mult: 0.0, add: 0.0, unit: '', mid: 0.0}
114
115; name of defaults files
116
117   CASE plttyp of
118      'plt': file_iso = 'fld_glo_iso.def'
119      'pltz': file_iso = 'fld_glo_iso.def'
120      'pltt': file_iso = 'fld_glo_iso.def'
121      ELSE: file_iso = 'fld_glo_iso.def'
122   ENDCASE
123   IF field.origin EQ 'diff' THEN BEGIN
124    file_iso = 'fld_zoo_iso.def'
125   ENDIF
126
127   IF debug_w THEN BEGIN
128    print, ' field.origin in fld_pltint: ', field.origin
129   ENDIF
130
131   print,' '
132   print,'    Reading iso/mult of ',var_name,' from : ', file_iso
133
134   spawn, 'grep -i "\ '+var_name+' " '+hom_def+file_iso, line
135   line = strcompress(strtrim(line[0], 2))
136   length = strlen(line)
137
138   IF length EQ 0 THEN BEGIN
139
140      print, '    *** field_pltint : no iso/mult for field ', var_name, $
141       ' in file ', file_iso
142      fldintr.int = !VALUES.F_NAN
143      fldintr.mult = 1.0
144      fldintr.add = 0.0
145      fldintr.unit = ''
146      fldintr.mid = 0.0
147
148   ENDIF ELSE BEGIN
149      argvar = strsplit(line, ' ', /EXTRACT)
150      IF strmid(argvar[1], 0, 1) EQ '@' THEN BEGIN
151                                ; get info from other variable
152         friend_name = strmid(argvar[1], 1, strlen(argvar[1])-1)
153         print, '      -> linked to ', friend_name
154         fldintr = fld_pltint(friend_name, plttyp, dimplot, hotyp)
155      ENDIF ELSE BEGIN
156         fldintr.int = float(argvar[3])
157                                ; separation for iso =0 if difference
158                                ; plot
159         CASE field.origin OF
160            'diff': BEGIN
161               fldintr.mid = 0.
162               fldatt.max = fldatt.dmax
163               fldatt.min = -fldatt.dmax
164               fldatt.homax = fldatt.max
165               fldatt.homin = fldatt.min
166               fldatt.max1d = fldatt.max
167               fldatt.min1d = fldatt.min
168            END
169            ELSE: fldintr.mid = float(argvar[5])
170         ENDCASE
171         IF size(argvar, /N_ELEMENTS) eq 8 OR field.origin EQ 'div' THEN BEGIN ; OR field.origin EQ 'diff'
172            fldintr.mult = 1.0
173            fldintr.add = 0.0
174            fldintr.unit = ''
175         ENDIF ELSE BEGIN
176            fldintr.mult = float(argvar[8])
177            fldintr.add = float(argvar[9])
178            fldintr.unit = argvar[10]
179         ENDELSE
180         tempvar = SIZE(TEMPORARY(argvar))
181      ENDELSE
182   ENDELSE
183
184   fldintr.name = var_name
185
186   return, fldintr
187END
Note: See TracBrowser for help on using the repository browser.