1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:litchamp |
---|
6 | ; |
---|
7 | ; PURPOSE:permet de lire un simple tableau ou une structure |
---|
8 | ; correspondant a un champ. |
---|
9 | ; Si en entree on a : |
---|
10 | ; -un simple tableau, litchamp renvoie le tableau |
---|
11 | ; -une stucture, litchamp renvoie le premier element de la structure |
---|
12 | ; qui doit obligatoirement etre le champ sous forme d''un tableau. |
---|
13 | ; Au passage litchamp regarde les autres elements de la structure et |
---|
14 | ; met a jour si besoin les variables globales qui se rapportent au |
---|
15 | ; champ: vargrid, varname, varunit, vardate, varexp , valmask, |
---|
16 | ; niveau et time |
---|
17 | ; |
---|
18 | ; CATEGORY:permet d''appeler plt, pltz, pltt ... avec un tableau ou une |
---|
19 | ; structure et de mettre a jour les variables globales liees au champ. |
---|
20 | ; |
---|
21 | ; CALLING SEQUENCE:res=litchamp(struct) |
---|
22 | ; |
---|
23 | ; INPUTS: |
---|
24 | ; struct: c''est soit un tableau soit une structure. |
---|
25 | ; Si struct est une structure, elle doit suivre les regles |
---|
26 | ; suivantes: |
---|
27 | ; -le premier element est le tableau contenant le champ. |
---|
28 | ; -les autres elements sont des strings qui contiennent des |
---|
29 | ; informations sur le champ SAUF pour l''element relatif a |
---|
30 | ; date. Ce dernier peut etre soit un string pour designer une date |
---|
31 | ; particuliere (ex: 'August 1999') ou bien un vecteur de jours |
---|
32 | ; juliens (d''IDL) correspondant au calendrier a associer au |
---|
33 | ; champ si c'est une serie temporelle. |
---|
34 | ; -l''ordre des elements (autre que le premier) n''a pas |
---|
35 | ; d''importance. |
---|
36 | ; -les autres elements (autre que le premier) sont tous |
---|
37 | ; optionnels. |
---|
38 | ; -ils sont reconnus par la premiere lettre de leur nom: |
---|
39 | ; g pour actualiser vargrid |
---|
40 | ; u pour actualiser varunit |
---|
41 | ; e pour actualiser varexp |
---|
42 | ; d pour actualiser vardate |
---|
43 | ; n pour actualiser varname |
---|
44 | ; m pour actualiser valmask |
---|
45 | ; l pour actualiser niveau (l pour level! et non pas n) |
---|
46 | ; |
---|
47 | ; KEYWORD PARAMETERS: |
---|
48 | ; |
---|
49 | ; /GRID: activer ce mot cle si on veut que litchamp renvoie la |
---|
50 | ; variable associee a l''element de la structure commencant |
---|
51 | ; par 'g' si il existe et '' dans le cas contraire. |
---|
52 | ; |
---|
53 | ; /UNIT: activer ce mot cle si on veut que litchamp renvoie la |
---|
54 | ; variable associee a l''element de la structure commencant |
---|
55 | ; par 'u' si il existe et '' dans le cas contraire. |
---|
56 | ; |
---|
57 | ; /EXP: activer ce mot cle si on veut que litchamp renvoie la |
---|
58 | ; variable associee a l''element de la structure commencant |
---|
59 | ; par 'e' si il existe et '' dans le cas contraire. |
---|
60 | ; |
---|
61 | ; /DATE: activer ce mot cle si on veut que litchamp renvoie la |
---|
62 | ; variable associee a l''element de la structure commencant |
---|
63 | ; par 'd' si il existe et '' dans le cas contraire. |
---|
64 | ; |
---|
65 | ; /NAME: activer ce mot cle si on veut que litchamp renvoie la |
---|
66 | ; variable associee a l''element de la structure commencant |
---|
67 | ; par 'n' si il existe et '' dans le cas contraire. |
---|
68 | ; |
---|
69 | ; /LEVEL: activer ce mot cle si on veut que litchamp renvoie la |
---|
70 | ; variable associee a l''element de la structure commencant |
---|
71 | ; par 'l' si il existe et -1 dans le cas contraire. |
---|
72 | ; |
---|
73 | ; /MASK: activer ce mot cle si on veut que litchamp renvoie la |
---|
74 | ; variable associee a l''element de la structure commencant |
---|
75 | ; par 'm' si il existe et -1 dans le cas contraire. |
---|
76 | ; |
---|
77 | ; OUTPUTS:c''est le tableau qui continent le champ. |
---|
78 | ; |
---|
79 | ; COMMON BLOCKS: |
---|
80 | ; common.pro |
---|
81 | ; |
---|
82 | ; SIDE EFFECTS: actualise au besion les variables globales vargrid, |
---|
83 | ; varname, varunit, vardate, varexp, valmask, niveau et time. |
---|
84 | ; |
---|
85 | ; RESTRICTIONS: |
---|
86 | ; |
---|
87 | ; EXAMPLE: |
---|
88 | ; |
---|
89 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
90 | ; T, , , 0, |
---|
91 | ; IDL> help, litchamp({a:indgen(5), u:'C', name:'toto'}) |
---|
92 | ; <Expression> INT = Array[5] |
---|
93 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
94 | ; T, toto, C, 0, |
---|
95 | ; IDL> help, litchamp({a:indgen(5), da:'1999'}) |
---|
96 | ; <Expression> INT = Array[5] |
---|
97 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
98 | ; T, toto, C, 1999, |
---|
99 | ; |
---|
100 | ; |
---|
101 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
102 | ; 28/5/1999 |
---|
103 | ;- |
---|
104 | ;------------------------------------------------------------ |
---|
105 | ;------------------------------------------------------------ |
---|
106 | ;------------------------------------------------------------ |
---|
107 | FUNCTION litchamp, struct, GRID = grid, NAME = name, UNIT = unit, EXP = exp, DATE = date $ |
---|
108 | , LEVEL = level, MASK = mask |
---|
109 | @common |
---|
110 | ;------------------------------------------------------------ |
---|
111 | if size(struct, /type) ne 8 then BEGIN ; alors contour n''est pas une structure |
---|
112 | if keyword_set(grid) then return, '' |
---|
113 | if keyword_set(name) then return, '' |
---|
114 | if keyword_set(unit) then return, '' |
---|
115 | if keyword_set(exp) then return, '' |
---|
116 | if keyword_set(date) then return, '' |
---|
117 | if keyword_set(level) then return, -1 |
---|
118 | if keyword_set(mask) then return, -1 |
---|
119 | return, struct |
---|
120 | ENDIF |
---|
121 | ;------------------------------------------------------------ |
---|
122 | IF n_tags(struct) EQ 1 then BEGIN ; la structure n'a qu''un element |
---|
123 | if keyword_set(grid) then return, '' |
---|
124 | if keyword_set(name) then return, '' |
---|
125 | if keyword_set(unit) then return, '' |
---|
126 | if keyword_set(exp) then return, '' |
---|
127 | if keyword_set(date) then return, '' |
---|
128 | if keyword_set(level) then return, -1 |
---|
129 | if keyword_set(mask) then return, -1 |
---|
130 | return, struct.(0) |
---|
131 | ENDIF |
---|
132 | ;------------------------------------------------------------ |
---|
133 | nomelements = tag_names(struct) |
---|
134 | for i = 1, n_tags(struct)-1 do begin |
---|
135 | case strlowcase(strmid(nomelements[i], 0, 1)) of |
---|
136 | 'g':BEGIN |
---|
137 | if keyword_set(grid) then return, strupcase(struct.(i)) |
---|
138 | vargrid = strupcase(struct.(i)) |
---|
139 | END |
---|
140 | 'n':BEGIN |
---|
141 | if keyword_set(name) then return, struct.(i) |
---|
142 | varname = struct.(i) |
---|
143 | END |
---|
144 | 'u':BEGIN |
---|
145 | if keyword_set(unit) then return, struct.(i) |
---|
146 | varunit = struct.(i) |
---|
147 | END |
---|
148 | 'e':BEGIN |
---|
149 | if keyword_set(exp) then return, struct.(i) |
---|
150 | varexp = struct.(i) |
---|
151 | END |
---|
152 | 'l':BEGIN |
---|
153 | if keyword_set(level) then return, struct.(i) |
---|
154 | niveau = struct.(i) |
---|
155 | END |
---|
156 | 'm':BEGIN |
---|
157 | if keyword_set(mask) then return, struct.(i) |
---|
158 | valmask = struct.(i) |
---|
159 | END |
---|
160 | 'd':BEGIN |
---|
161 | if size(struct.(i),/type) EQ 7 THEN BEGIN |
---|
162 | vardate = struct.(i) |
---|
163 | ENDIF ELSE BEGIN |
---|
164 | time = struct.(i) |
---|
165 | jpt = n_elements(time) |
---|
166 | if jpt EQ 1 then vardate = strtrim(vairdate((struct.(i))[0]), 2)$ |
---|
167 | ELSE vardate = strtrim(vairdate((struct.(i))[0]), 2)+' - ' $ |
---|
168 | +strtrim(vairdate((struct.(i))[jpt-1]), 2) |
---|
169 | ENDELSE |
---|
170 | if keyword_set(date) then return, vardate |
---|
171 | END |
---|
172 | 'h':BEGIN |
---|
173 | computehopegrid, (struct.(i)).xaxis, (struct.(i)).yaxis $ |
---|
174 | , (struct.(i)).zaxis, (struct.(i)).linetype $ |
---|
175 | , FIRSTS = (struct.(i)).firsts, LASTS = (struct.(i)).lasts $ |
---|
176 | , FORTHEMASK = struct.(0), pttype = (struct.(i)).pttype |
---|
177 | END |
---|
178 | ELSE:BEGIN |
---|
179 | ras = report('Le nom '+nomelements[i]+' ne correspont a aucun element reconnu de la structure. cf. IDL> xhelp, ''litchamp''') |
---|
180 | end |
---|
181 | endcase |
---|
182 | endfor |
---|
183 | ;------------------------------------------------------------ |
---|
184 | if keyword_set(grid) then return, '' |
---|
185 | if keyword_set(name) then return, '' |
---|
186 | if keyword_set(unit) then return, '' |
---|
187 | if keyword_set(exp) then return, '' |
---|
188 | if keyword_set(date) then return, '' |
---|
189 | if keyword_set(level) then return, -1 |
---|
190 | if keyword_set(mask) then return, -1 |
---|
191 | |
---|
192 | return, struct.(0) |
---|
193 | end |
---|