[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[142] | 3 | ; @file_comments |
---|
[163] | 4 | ; Allows to read an array or a structure corresponding to a field. |
---|
[231] | 5 | ; If we have in input: |
---|
[296] | 6 | ; - an array, litchamp send back the array. |
---|
| 7 | ; - a structure, litchamp send back the first element of the structure |
---|
[142] | 8 | ; which must be the field in an array. |
---|
[296] | 9 | ; litchamp profit of this to look other elements of the structure and |
---|
| 10 | ; update if needed global variables which refer to the field: |
---|
| 11 | ; vargrid, varname, varunit, vardate, varexp , valmask et time |
---|
[2] | 12 | ; |
---|
[142] | 13 | ; @categories |
---|
[157] | 14 | ; Graphics |
---|
[2] | 15 | ; |
---|
[163] | 16 | ; @param STRUCT {in}{required}{type=array or struct}{type=array or structure} |
---|
[142] | 17 | ; If STRUCT is a structure, it must follow following rules: |
---|
| 18 | ; -the first element is the array containing the field. |
---|
[163] | 19 | ; -other elements are strings containing informations on the field except |
---|
[142] | 20 | ; for the one about the date. This one can be either a string to designate |
---|
[493] | 21 | ; a particular date (ex: 'August 1999') or a vector of Julian days (of IDL) |
---|
[142] | 22 | ; corresponding to the calendar to be associated with the field if it is a |
---|
| 23 | ; temporal series. |
---|
[231] | 24 | ; -the order of elements (except the first) has not any importance. |
---|
[163] | 25 | ; -the other elements (except the first) are optional. |
---|
[295] | 26 | ; -they are recognized by the first letter of their names: |
---|
| 27 | ; g to update vargrid, |
---|
| 28 | ; u to update varunit, |
---|
| 29 | ; e to update varexp, |
---|
| 30 | ; d to update vardate, |
---|
| 31 | ; n to update varname, |
---|
[142] | 32 | ; m to update valmask |
---|
[2] | 33 | ; |
---|
[142] | 34 | ; @keyword GRID |
---|
[231] | 35 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 36 | ; associated with the element of the structure starting by 'g' if it exist |
---|
[142] | 37 | ; and '' if it does not. |
---|
[2] | 38 | ; |
---|
[142] | 39 | ; @keyword UNIT |
---|
[231] | 40 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 41 | ; associated with the element of the structure starting by 'u' if it exist |
---|
[142] | 42 | ; and '' if it does not. |
---|
[2] | 43 | ; |
---|
[142] | 44 | ; @keyword EXP |
---|
[231] | 45 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 46 | ; associated with the element of the structure starting by 'u' if it exist |
---|
[142] | 47 | ; and '' if it does not. |
---|
[2] | 48 | ; |
---|
[142] | 49 | ; @keyword DATE |
---|
[231] | 50 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 51 | ; associated with the element of the structure starting by 'd' if it exist |
---|
[142] | 52 | ; and '' if it does not. |
---|
[2] | 53 | ; |
---|
[142] | 54 | ; @keyword NAME |
---|
[231] | 55 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 56 | ; associated with the element of the structure starting by 'n' if it exist |
---|
[142] | 57 | ; and '' if it does not. |
---|
[2] | 58 | ; |
---|
[142] | 59 | ; @keyword LEVEL |
---|
[231] | 60 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 61 | ; associated with the element of the structure starting by 'l' if it exist |
---|
[142] | 62 | ; and -1 if it does not. |
---|
[231] | 63 | ; |
---|
[142] | 64 | ; @keyword MASK |
---|
[231] | 65 | ; We activate this keyword if we want litchamp to send back the variable |
---|
| 66 | ; associated with the element of the structure starting by 'm' if it exist |
---|
[142] | 67 | ; and -1 if it does not. |
---|
[2] | 68 | ; |
---|
[142] | 69 | ; @returns |
---|
| 70 | ; It is the array containing the field. |
---|
[2] | 71 | ; |
---|
[142] | 72 | ; @uses |
---|
[370] | 73 | ; <pro>common</pro> |
---|
[2] | 74 | ; |
---|
[142] | 75 | ; @restrictions |
---|
| 76 | ; Update if needed global variables vargrid, |
---|
| 77 | ; varname, varunit, vardate, varexp, valmask and time. |
---|
[2] | 78 | ; |
---|
[142] | 79 | ; @examples |
---|
[231] | 80 | ; |
---|
[371] | 81 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
[231] | 82 | ; T, , , 0, |
---|
[371] | 83 | ; IDL> help, litchamp({a:indgen(5), u:'C', name:'toto'}) |
---|
[2] | 84 | ; <Expression> INT = Array[5] |
---|
[371] | 85 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
[231] | 86 | ; T, toto, C, 0, |
---|
[371] | 87 | ; IDL> help, litchamp({a:indgen(5), da:'1999'}) |
---|
[2] | 88 | ; <Expression> INT = Array[5] |
---|
[371] | 89 | ; IDL> print, vargrid,', ', varname,', ', varunit,', ', vardate,', ', varexp |
---|
[231] | 90 | ; T, toto, C, 1999, |
---|
[2] | 91 | ; |
---|
[231] | 92 | ; |
---|
[142] | 93 | ; @history |
---|
[157] | 94 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 95 | ; 28/5/1999 |
---|
[142] | 96 | ; |
---|
| 97 | ; @version |
---|
| 98 | ; $Id$ |
---|
| 99 | ; |
---|
[2] | 100 | ;- |
---|
[327] | 101 | FUNCTION litchamp, struct, GRID=grid, NAME=name, UNIT=unit $ |
---|
| 102 | , EXP=exp, DATE=date $ |
---|
| 103 | , LEVEL=level, MASK=mask |
---|
[114] | 104 | ; |
---|
| 105 | compile_opt idl2, strictarrsubs |
---|
| 106 | ; |
---|
[2] | 107 | @common |
---|
[231] | 108 | ; |
---|
[142] | 109 | if size(struct, /type) ne 8 then BEGIN ; so contour is not a structure. |
---|
[2] | 110 | if keyword_set(grid) then return, '' |
---|
| 111 | if keyword_set(name) then return, '' |
---|
| 112 | if keyword_set(unit) then return, '' |
---|
| 113 | if keyword_set(exp) then return, '' |
---|
| 114 | if keyword_set(date) then return, '' |
---|
| 115 | if keyword_set(level) then return, -1 |
---|
| 116 | if keyword_set(mask) then return, -1 |
---|
[231] | 117 | return, struct |
---|
| 118 | ENDIF |
---|
[2] | 119 | ;------------------------------------------------------------ |
---|
[142] | 120 | IF n_tags(struct) EQ 1 then BEGIN ; The structure has only one element. |
---|
[2] | 121 | if keyword_set(grid) then return, '' |
---|
| 122 | if keyword_set(name) then return, '' |
---|
| 123 | if keyword_set(unit) then return, '' |
---|
| 124 | if keyword_set(exp) then return, '' |
---|
| 125 | if keyword_set(date) then return, '' |
---|
| 126 | if keyword_set(level) then return, -1 |
---|
| 127 | if keyword_set(mask) then return, -1 |
---|
| 128 | return, struct.(0) |
---|
[231] | 129 | ENDIF |
---|
[2] | 130 | ;------------------------------------------------------------ |
---|
| 131 | nomelements = tag_names(struct) |
---|
| 132 | for i = 1, n_tags(struct)-1 do begin |
---|
| 133 | case strlowcase(strmid(nomelements[i], 0, 1)) of |
---|
| 134 | 'g':BEGIN |
---|
| 135 | if keyword_set(grid) then return, strupcase(struct.(i)) |
---|
| 136 | vargrid = strupcase(struct.(i)) |
---|
| 137 | END |
---|
| 138 | 'n':BEGIN |
---|
| 139 | if keyword_set(name) then return, struct.(i) |
---|
| 140 | varname = struct.(i) |
---|
| 141 | END |
---|
| 142 | 'u':BEGIN |
---|
| 143 | if keyword_set(unit) then return, struct.(i) |
---|
| 144 | varunit = struct.(i) |
---|
| 145 | END |
---|
| 146 | 'e':BEGIN |
---|
| 147 | if keyword_set(exp) then return, struct.(i) |
---|
| 148 | varexp = struct.(i) |
---|
| 149 | END |
---|
| 150 | 'm':BEGIN |
---|
| 151 | if keyword_set(mask) then return, struct.(i) |
---|
| 152 | valmask = struct.(i) |
---|
| 153 | END |
---|
[231] | 154 | 'd':BEGIN |
---|
| 155 | if size(struct.(i),/type) EQ 7 THEN BEGIN |
---|
[2] | 156 | vardate = struct.(i) |
---|
| 157 | ENDIF ELSE BEGIN |
---|
| 158 | time = struct.(i) |
---|
| 159 | jpt = n_elements(time) |
---|
| 160 | if jpt EQ 1 then vardate = strtrim(vairdate((struct.(i))[0]), 2)$ |
---|
| 161 | ELSE vardate = strtrim(vairdate((struct.(i))[0]), 2)+' - ' $ |
---|
[231] | 162 | +strtrim(vairdate((struct.(i))[jpt-1]), 2) |
---|
[2] | 163 | ENDELSE |
---|
| 164 | if keyword_set(date) then return, vardate |
---|
| 165 | END |
---|
| 166 | 'h':BEGIN |
---|
| 167 | computehopegrid, (struct.(i)).xaxis, (struct.(i)).yaxis $ |
---|
| 168 | , (struct.(i)).zaxis, (struct.(i)).linetype $ |
---|
| 169 | , FIRSTS = (struct.(i)).firsts, LASTS = (struct.(i)).lasts $ |
---|
| 170 | , FORTHEMASK = struct.(0), pttype = (struct.(i)).pttype |
---|
| 171 | END |
---|
[231] | 172 | ELSE:BEGIN |
---|
[493] | 173 | ras = report('Le nom '+nomelements[i]+' ne correspond a aucun element reconnu de la structure. cf. IDL> xhelp, ''litchamp''') |
---|
[2] | 174 | end |
---|
| 175 | endcase |
---|
| 176 | endfor |
---|
| 177 | ;------------------------------------------------------------ |
---|
| 178 | if keyword_set(grid) then return, '' |
---|
| 179 | if keyword_set(name) then return, '' |
---|
| 180 | if keyword_set(unit) then return, '' |
---|
| 181 | if keyword_set(exp) then return, '' |
---|
| 182 | if keyword_set(date) then return, '' |
---|
| 183 | if keyword_set(level) then return, -1 |
---|
| 184 | if keyword_set(mask) then return, -1 |
---|
| 185 | |
---|
| 186 | return, struct.(0) |
---|
| 187 | end |
---|