1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME: read_hope |
---|
6 | ; |
---|
7 | ; PURPOSE: read the Hope grid file converted in NetCdf by xconv |
---|
8 | ; |
---|
9 | ; CATEGORY: reading |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE: a=read_hope([typein, varnamein]) |
---|
12 | ; |
---|
13 | ; INPUTS: |
---|
14 | ; typein: a string specifing from which type of section the 4D |
---|
15 | ; array based: 'xy, 'xz', 'yz' |
---|
16 | ; |
---|
17 | ; varnamein: a string the name of the cariable to be read (in |
---|
18 | ; lower or upper case) |
---|
19 | ; |
---|
20 | ; KEYWORD PARAMETERS: |
---|
21 | ; |
---|
22 | ; FILENAME = the name of the file to be read |
---|
23 | ; |
---|
24 | ; XLIMITS = a two elements vertor [lonmin, lonmax]] |
---|
25 | ; the bondary of the longitudes (from 0 to 360) |
---|
26 | ; |
---|
27 | ; YLIMITS = a two elements vertor [latmin, latmax]] |
---|
28 | ; the bondary of the latitudes (from -90 to 90) |
---|
29 | ; |
---|
30 | ; ZLIMITS = a two elements vertor [depthmin, depthmax]] |
---|
31 | ; the bondary of the depth |
---|
32 | ; |
---|
33 | ; TLIMITS = a two elements vertor [date1, date2]] |
---|
34 | ; the bondary of the calendar with date1 and date2 |
---|
35 | ; folowing the syntaxe yyyymmdd |
---|
36 | ; |
---|
37 | ; /ODDPT: activate to read only the sections located on ODD |
---|
38 | ; points |
---|
39 | ; |
---|
40 | ; /EVENPT: activate to read only the sections located on even |
---|
41 | ; points |
---|
42 | ; |
---|
43 | ; /ODDEVENPT: activate to read only the sections located on |
---|
44 | ; both even and odd points (horizontal sections) |
---|
45 | ; |
---|
46 | ; OUTPUTS: |
---|
47 | ; |
---|
48 | ; -1 if typein and varnamein are undefine (this is the widget |
---|
49 | ; version) |
---|
50 | ; |
---|
51 | ; a structure which but be read by litchamp.pro and is |
---|
52 | ; necessary to complute the grid associated to the data (see |
---|
53 | ; the example). |
---|
54 | ; |
---|
55 | ; COMMON BLOCKS: common.pro (usefull only for the definition of iodir) |
---|
56 | ; |
---|
57 | ; SIDE EFFECTS: |
---|
58 | ; 'x', 'y', 'z', 't', 'xt', 'yt' and 'zt' section not coded, xconv |
---|
59 | ; must be able to works with this kind of fonction. |
---|
60 | ; The grib file has no zoom possibilities on horizontal |
---|
61 | ; dimensions. |
---|
62 | ; |
---|
63 | ; RESTRICTIONS: |
---|
64 | ; |
---|
65 | ; When typein and varnamein are defined, the methode to find the |
---|
66 | ; godd variable is: |
---|
67 | ; 1) find the variables which are available on this type of |
---|
68 | ; sections woth this name |
---|
69 | ; 2) if ODDPT, EVENPT or ODDEVENPT are specified, consider only |
---|
70 | ; these types of sections |
---|
71 | ; 3) for an XY section the chosen variable is the one which has |
---|
72 | ; the most level in the vertical domain specified by ZLIMITS. |
---|
73 | ; for an XZ section the chosen variable is the one which has |
---|
74 | ; the most points in the latitude domain specified by YLIMITS. |
---|
75 | ; for an YZ section the chosen variable is the one which has |
---|
76 | ; the most points in the longitude domain specified by XLIMITS. |
---|
77 | ; |
---|
78 | ; |
---|
79 | ; EXAMPLE: |
---|
80 | ; |
---|
81 | ; IDL> a=read_hope('xy','ocpt',filename='CLIM_CNT_1993-1998.nc') |
---|
82 | ; IDL> help, a,/struct |
---|
83 | ; ** Structure <82ec344>, 6 tags, length=1860176, refs=1: |
---|
84 | ; ARRAY FLOAT Array[128, 242, 15] |
---|
85 | ; UNIT STRING 'deg C' |
---|
86 | ; NAME STRING 'Ocean potential temperature' |
---|
87 | ; DATE FLOAT Array[1] |
---|
88 | ; GRID STRING 'T' |
---|
89 | ; HOPEGRID STRUCT -> <Anonymous> Array[1] |
---|
90 | ; IDL> help, a.hopegrid,/struct |
---|
91 | ; ** Structure <82eb9cc>, 8 tags, length=1588, refs=2: |
---|
92 | ; XAXIS FLOAT Array[128] |
---|
93 | ; YAXIS FLOAT Array[242] |
---|
94 | ; ZAXIS FLOAT Array[15] |
---|
95 | ; FIRSTS LONG Array[3] |
---|
96 | ; LASTS LONG Array[3] |
---|
97 | ; TYPE STRING 'xy' |
---|
98 | ; LINETYPE STRING 'odd-even' |
---|
99 | ; PTTYPE STRING 'T' |
---|
100 | ; IDL> help, litchamp(a) |
---|
101 | ; <Expression> FLOAT = Array[128, 242, 15] |
---|
102 | ; |
---|
103 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
104 | ; June 2001 |
---|
105 | ;- |
---|
106 | ;------------------------------------------------------------ |
---|
107 | ;------------------------------------------------------------ |
---|
108 | ;------------------------------------------------------------ |
---|
109 | |
---|
110 | |
---|
111 | ; |
---|
112 | pro read_hope_event, event |
---|
113 | ; |
---|
114 | compile_opt idl2, strictarrsubs |
---|
115 | ; |
---|
116 | widget_control, event.id, get_uvalue=uval |
---|
117 | widget_control, event.top, get_uvalue=top_uvalue |
---|
118 | case uval.name OF |
---|
119 | ;--------------------------------- |
---|
120 | 'cancel':begin |
---|
121 | ; close the file |
---|
122 | cdfid=*top_uvalue[1, findline(top_uvalue, 'cdfid')] |
---|
123 | ncdf_close, cdfid |
---|
124 | ; clear the pointer |
---|
125 | for i=0,n_elements(top_uvalue)-1 do ptr_free, top_uvalue[i] |
---|
126 | ; kill the widget |
---|
127 | widget_control,event.top,/destroy |
---|
128 | end |
---|
129 | ;--------------------------------- |
---|
130 | 'type choice':begin |
---|
131 | ; find the new type of selected section |
---|
132 | typeindex=widget_info(event.id,/droplist_select) |
---|
133 | selectedtype=(*top_uvalue[1, findline(top_uvalue, 'type choice')])[typeindex] |
---|
134 | ; find the available variables for this type of section |
---|
135 | sectype = *top_uvalue[1, findline(top_uvalue, 'sectype')] |
---|
136 | goodvar = where(sectype EQ selectedtype) |
---|
137 | namevar = *top_uvalue[1, findline(top_uvalue, 'namevar')] |
---|
138 | goodnamevar = namevar[goodvar] |
---|
139 | ; find the selected var name |
---|
140 | varchoiceid = widget_info(event.top,find_by_uname = 'var choice') |
---|
141 | varindex = widget_info(varchoiceid,/droplist_select) |
---|
142 | varchoice = *top_uvalue[1, findline(top_uvalue, 'var choice')] |
---|
143 | selectedvarname=varchoice[varindex] |
---|
144 | ; do we change the variable? |
---|
145 | if (where(goodnamevar EQ selectedvarname))[0] EQ -1 then begin |
---|
146 | selectedvarname = goodnamevar[0] |
---|
147 | varindex = (where(varchoice EQ selectedvarname))[0] |
---|
148 | widget_control, varchoiceid, set_droplist_select = varindex |
---|
149 | ENDIF |
---|
150 | ; displays the different domains |
---|
151 | selected = goodvar[where(goodnamevar EQ selectedvarname)] |
---|
152 | rh_alldomains, event.top, selected |
---|
153 | end |
---|
154 | ;--------------------------------- |
---|
155 | 'var choice':BEGIN |
---|
156 | ; find the new variable |
---|
157 | varindex=widget_info(event.id,/droplist_select) |
---|
158 | selectedvar=(*top_uvalue[1, findline(top_uvalue, 'var choice')])[varindex] |
---|
159 | ; find the available variables for this type of section |
---|
160 | namevar = *top_uvalue[1, findline(top_uvalue, 'namevar')] |
---|
161 | goodvar = where(namevar EQ selectedvar) |
---|
162 | sectype = *top_uvalue[1, findline(top_uvalue, 'sectype')] |
---|
163 | goodtype = sectype[goodvar] |
---|
164 | ; find the selected type of section |
---|
165 | typechoiceid = widget_info(event.top,find_by_uname = 'type choice') |
---|
166 | typeindex = widget_info(typechoiceid,/droplist_select) |
---|
167 | typechoice = *top_uvalue[1, findline(top_uvalue, 'type choice')] |
---|
168 | selectedtype=typechoice[typeindex] |
---|
169 | ; do we change the type of section ? |
---|
170 | if (where(goodtype EQ selectedtype))[0] EQ -1 then begin |
---|
171 | selectedtype = goodtype[0] |
---|
172 | typeindex = (where(typechoice EQ selectedtype))[0] |
---|
173 | widget_control, typechoiceid, set_droplist_select = typeindex |
---|
174 | ENDIF |
---|
175 | ; displays the different domains |
---|
176 | selected = goodvar[where(goodtype EQ selectedtype)] |
---|
177 | rh_alldomains, event.top, selected |
---|
178 | END |
---|
179 | ;--------------------------------- |
---|
180 | 'plot':BEGIN |
---|
181 | ; plot the array |
---|
182 | res = createhopestruct(event) |
---|
183 | ; type of section |
---|
184 | selected = *top_uvalue[1, findline(top_uvalue, 'selected')] |
---|
185 | type = (*top_uvalue[1, findline(top_uvalue, 'sectype')])[selected] |
---|
186 | ; get the informations of cw_specifie |
---|
187 | specifieid=widget_info(event.top,find_by_uname = 'specifie') |
---|
188 | widget_control, specifieid, get_value = specifie |
---|
189 | specifie = struct2string(specifie,/direct2string) |
---|
190 | case type of |
---|
191 | 'x':command = 'plt1d,res,''x'','+specifie |
---|
192 | 'y':command = 'plt1d,res,''y'','+specifie |
---|
193 | 'z':command = 'plt1d,res,''z'','+specifie |
---|
194 | 't':command = 'pltt,res,''t'' ,'+specifie |
---|
195 | 'xy':command = 'plt, res,'+specifie |
---|
196 | 'xz':command = 'pltz, res,''xz'','+specifie |
---|
197 | 'yz':command = 'pltz, res,''yz'','+specifie |
---|
198 | 'xt':command = 'pltt,res,''xt'','+specifie |
---|
199 | 'yt':command = 'pltt,res,''yt'','+specifie |
---|
200 | 'zt':command = 'pltt,res,''zt'','+specifie |
---|
201 | 'xyz': |
---|
202 | 'xyt': |
---|
203 | 'yzt': |
---|
204 | 'xyzt': |
---|
205 | ENDCASE |
---|
206 | test = execute(command) |
---|
207 | if test EQ 0 then stop |
---|
208 | end |
---|
209 | ;--------------------------------- |
---|
210 | 'linechoice':BEGIN |
---|
211 | if event.select EQ 1 then begin |
---|
212 | sensitive = bytarr(3) |
---|
213 | sensitive[where(['odd', 'even', 'odd-even'] eq event.value)] = 1 |
---|
214 | basedomainodd=widget_info(event.top,find_by_uname = 'basedomainodd') |
---|
215 | widget_control, basedomainodd, sensitive = sensitive[0] |
---|
216 | basedomaineven=widget_info(event.top,find_by_uname = 'basedomaineven') |
---|
217 | widget_control, basedomaineven, sensitive = sensitive[1] |
---|
218 | basedomainoddeven=widget_info(event.top,find_by_uname = 'basedomainodd-even') |
---|
219 | widget_control, basedomainoddeven, sensitive = sensitive[2] |
---|
220 | case (where(sensitive EQ 1))[0] of |
---|
221 | 0:BEGIN |
---|
222 | widget_control, basedomainodd, get_uvalue = oddsecchoice |
---|
223 | oddsecchoiceid=widget_info(event.top,find_by_uname = 'oddsecchoice') |
---|
224 | if oddsecchoiceid NE 0 then $ |
---|
225 | index = widget_info(oddsecchoiceid, /droplist_select) $ |
---|
226 | ELSE index = 0 |
---|
227 | *top_uvalue[1, findline(top_uvalue, 'selected')] = oddsecchoice[index] |
---|
228 | END |
---|
229 | 1:BEGIN |
---|
230 | widget_control, basedomaineven, get_uvalue = evensecchoice |
---|
231 | evensecchoiceid=widget_info(event.top,find_by_uname = 'evensecchoice') |
---|
232 | if evensecchoiceid NE 0 then $ |
---|
233 | index = widget_info(evensecchoiceid, /droplist_select) $ |
---|
234 | ELSE index = 0 |
---|
235 | *top_uvalue[1, findline(top_uvalue, 'selected')] = evensecchoice[index] |
---|
236 | END |
---|
237 | 2:BEGIN |
---|
238 | widget_control, basedomainodd, get_uvalue = oddevensecchoice |
---|
239 | oddevensecchoiceid=widget_info(event.top,find_by_uname = 'odd-evensecchoice') |
---|
240 | if oddevensecchoiceid NE 0 then $ |
---|
241 | index = widget_info(oddevensecchoiceid, /droplist_select) $ |
---|
242 | ELSE index = 0 |
---|
243 | *top_uvalue[1, findline(top_uvalue, 'selected')] = oddevensecchoice[index] |
---|
244 | END |
---|
245 | endcase |
---|
246 | endif |
---|
247 | END |
---|
248 | ;--------------------------------- |
---|
249 | 'oddsecchoice':BEGIN |
---|
250 | widget_control, event.top, update=0 |
---|
251 | basedomainodd=widget_info(event.top,find_by_uname = 'basedomainodd') |
---|
252 | widget_control, basedomainodd, get_uvalue = oddsecchoice |
---|
253 | domainpart, top_uvalue, basedomainodd, oddsecchoice[event.index] |
---|
254 | *top_uvalue[1, findline(top_uvalue, 'selected')] = oddsecchoice[event.index] |
---|
255 | widget_control, event.top, update=1 |
---|
256 | END |
---|
257 | ;--------------------------------- |
---|
258 | 'evensecchoice':BEGIN |
---|
259 | widget_control, event.top, update=0 |
---|
260 | basedomaineven=widget_info(event.top,find_by_uname = 'basedomaineven') |
---|
261 | widget_control, basedomaineven, get_uvalue = evensecchoice |
---|
262 | domainpart, top_uvalue, basedomaineven, evensecchoice[event.index] |
---|
263 | *top_uvalue[1, findline(top_uvalue, 'selected')] = evensecchoice[event.index] |
---|
264 | widget_control, event.top, update=1 |
---|
265 | END |
---|
266 | ;--------------------------------- |
---|
267 | 'odd-evensecchoice':BEGIN |
---|
268 | widget_control, event.top, update=0 |
---|
269 | basedomainoddeven=widget_info(event.top,find_by_uname = 'basedomainodd-even') |
---|
270 | widget_control, basedomainoddeven, get_uvalue = oddevensecchoice |
---|
271 | domainpart, top_uvalue, basedomainoddeven, oddevensecchoice[event.index] |
---|
272 | *top_uvalue[1, findline(top_uvalue, 'selected')] = oddevensecchoice[event.index] |
---|
273 | widget_control, event.top, update=1 |
---|
274 | END |
---|
275 | ;--------------------------------- |
---|
276 | 'date1':BEGIN |
---|
277 | date2id = widget_info(event.top, find_by_uname = 'date2') |
---|
278 | widget_control, date2id, get_value = date2 |
---|
279 | if event.value GT date2 then widget_control, date2id, set_value = event.value |
---|
280 | END |
---|
281 | ;--------------------------------- |
---|
282 | 'date2':BEGIN |
---|
283 | date1id = widget_info(event.top, find_by_uname = 'date1') |
---|
284 | widget_control, date1id, get_value = date1 |
---|
285 | if event.value LT date1 then widget_control, date1id, set_value = event.value |
---|
286 | END |
---|
287 | ;--------------------------------- |
---|
288 | else: |
---|
289 | endcase |
---|
290 | return |
---|
291 | end |
---|
292 | ; |
---|
293 | ; |
---|
294 | ; |
---|
295 | ; |
---|
296 | ; |
---|
297 | ; |
---|
298 | ; |
---|
299 | ; |
---|
300 | ; |
---|
301 | FUNCTION read_hope, typein, varnamein, FILENAME = filename, XLIMITS = xlimits, YLIMITS = ylimits, ZLIMITS = zlimits, TLIMITS = tlimits, ODDPT = oddpt, ODDEVENPT = oddevenpt, EVENPT = evenpt, _extra = ex |
---|
302 | ; |
---|
303 | compile_opt idl2, strictarrsubs |
---|
304 | ; |
---|
305 | @common ; usefull only for the definition of iodir |
---|
306 | if n_elements(filename) EQ 0 then filename = isafile(iodirectory = iodir, _extra = ex) |
---|
307 | IF size(filename, /type) NE 7 THEN return, -1 |
---|
308 | filename = isafile(filename = filename, iodirectory = iodir, _extra = ex) |
---|
309 | ; |
---|
310 | cdfid = ncdf_open(filename) ; id of the netcdf file |
---|
311 | wathinside = ncdf_inquire(cdfid) ; structure with global informations |
---|
312 | ;------------------------------- |
---|
313 | ; dimensions |
---|
314 | ;------------------------------- |
---|
315 | namedim = strarr(wathinside.ndims) ; name of the dimensions |
---|
316 | typedim = strarr(wathinside.ndims) ; type of the dimensions (x,y,z,t) |
---|
317 | sizedim = lonarr(wathinside.ndims) ; size of each dimension |
---|
318 | ; loop on the dimensions to get the names and sizes |
---|
319 | for dimiq = 0, wathinside.ndims-1 do begin |
---|
320 | ncdf_diminq, cdfid, dimiq, name, value |
---|
321 | namedim[dimiq] = name |
---|
322 | case 1 of |
---|
323 | STRCMP(name, 'lon', 3, /FOLD_CASE):typedim[dimiq] = 'x' |
---|
324 | STRCMP(name, 'lat', 3, /FOLD_CASE):typedim[dimiq] = 'y' |
---|
325 | STRCMP(name, 'z', 1, /FOLD_CASE):typedim[dimiq] = 'z' |
---|
326 | STRCMP(name, 't', 1, /FOLD_CASE):typedim[dimiq] = 't' |
---|
327 | ELSE:BEGIN |
---|
328 | ncdf_close, cdfid |
---|
329 | return, report('Unknown name of dimension') |
---|
330 | END |
---|
331 | endcase |
---|
332 | sizedim[dimiq] = value |
---|
333 | endfor |
---|
334 | ; dimlist: structure which contains the name and the value of each |
---|
335 | ; dimension |
---|
336 | ; we suppose that there is always a variable which has the |
---|
337 | ; same name that the dimension and which gives the values of |
---|
338 | ; this dimension |
---|
339 | ncdf_varget, cdfid, namedim[0], value |
---|
340 | dimlist = create_struct(namedim[0], value) |
---|
341 | for dimiq = 1, wathinside.ndims-1 do begin |
---|
342 | ncdf_varget, cdfid, namedim[dimiq], value ;get the value |
---|
343 | dimlist = create_struct(dimlist, namedim[dimiq], value) |
---|
344 | endfor |
---|
345 | ;------------------------------- |
---|
346 | ; variables |
---|
347 | ;------------------------------- |
---|
348 | namevar = strarr(wathinside.nvars) ; names of the variables |
---|
349 | ndimsvar = lonarr(wathinside.nvars) ; number of dim for each variable |
---|
350 | dimvar = replicate(-1, wathinside.ndims, wathinside.nvars) ; dims of each variables |
---|
351 | ; loop over the variable ids to fill namevar, ndimsvar and dimvar |
---|
352 | for varid = 0, wathinside.nvars-1 do begin |
---|
353 | res = ncdf_varinq(cdfid, varid) |
---|
354 | namevar[varid] = res.name |
---|
355 | namevar[varid] = strjoin(strsplit(namevar[varid], '_[0-99]', /EXTRACT, /REGEX)) |
---|
356 | ndimsvar[varid] = res.ndims |
---|
357 | dimvar[0:res.ndims-1, varid] = res.dim |
---|
358 | ENDFOR |
---|
359 | ; we cut dimvar to select only the interessant part |
---|
360 | dimvar = dimvar[0:max(ndimsvar)-1, *] |
---|
361 | ; selection of the data variables which are diffrent from the |
---|
362 | ; dimension variables |
---|
363 | ; we suppose that that data variables are 4D array (with sometime |
---|
364 | ; dimensions equal to 1). they must be different from dimension |
---|
365 | ; variables which have only 1 dimension |
---|
366 | datavarid = where(ndimsvar eq 4) |
---|
367 | numberofvar = n_elements(datavarid) |
---|
368 | namevar = namevar[datavarid] |
---|
369 | ndimsvar = ndimsvar[datavarid] |
---|
370 | dimvar = dimvar[*, datavarid] |
---|
371 | ; |
---|
372 | sectype = strarr(numberofvar) ; the type of section for each variable :'xy', 'xz', 'yz'... |
---|
373 | linetype = strarr(numberofvar) ; the line of the points : odd, even or odd-even |
---|
374 | pointtype = strarr(numberofvar) ; the type of variable : scalar ('T') or vector ('U') |
---|
375 | for i = 0, numberofvar-1 do begin |
---|
376 | dimofthevar = dimvar[*, i] |
---|
377 | sectype[i] = typedim[dimofthevar[0]]+typedim[dimofthevar[1]] |
---|
378 | xaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'x')] |
---|
379 | yaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'y')] |
---|
380 | lineandpt = findlineandpointtype(sectype[i], dimlist.(xaxisid[0]), dimlist.(yaxisid[0]), iodir) |
---|
381 | linetype[i] = lineandpt.linetype |
---|
382 | pointtype[i] = lineandpt.pointtype |
---|
383 | endfor |
---|
384 | ; |
---|
385 | ;--------------------------------------------------- |
---|
386 | ;--------------------------------------------------- |
---|
387 | ;--------------------------------------------------- |
---|
388 | ; definition of the widget |
---|
389 | ;--------------------------------------------------- |
---|
390 | ;--------------------------------------------------- |
---|
391 | ;--------------------------------------------------- |
---|
392 | base = widget_base(/column) |
---|
393 | ;--------------------------------------------------- |
---|
394 | ; first base: |
---|
395 | ; droplist to select the type of section |
---|
396 | ; droplist to select the variable |
---|
397 | ; button to select type of line : odd, even or odd-even |
---|
398 | ;--------------------------------------------------- |
---|
399 | base1 = widget_base(base, /row, /frame) |
---|
400 | typechoice = sectype[uniq(sectype, sort(sectype))] |
---|
401 | if n_elements(typechoice) GT 1 then typechoice = typechoice[sortdim(typechoice)] |
---|
402 | base11 = widget_droplist(base1, title = 'Type of section', value = typechoice, uvalue = {name:'type choice'}, uname = 'type choice') |
---|
403 | if n_elements(typein) NE 0 then BEGIN |
---|
404 | selectedtype = strmid(typein, 0, 2) |
---|
405 | widget_control, base11, set_droplist_select $ |
---|
406 | = 0L > (where(typechoice EQ selectedtype))[0] |
---|
407 | ENDIF ELSE selectedtype = typechoice[0] |
---|
408 | ; |
---|
409 | varchoice = namevar[uniq(namevar, sort(namevar))] |
---|
410 | base12 = widget_droplist(base1, title = 'Available data', value = varchoice, uvalue = {name:'var choice'}, uname = 'var choice') |
---|
411 | if n_elements(varnamein) NE 0 THEN BEGIN |
---|
412 | selectedname = varnamein |
---|
413 | widget_control, base12, set_droplist_select $ |
---|
414 | = 0L > (where(strlowcase(varchoice) EQ strlowcase(varnamein)))[0] |
---|
415 | ENDIF ELSE selectedname = varchoice[0] |
---|
416 | ; |
---|
417 | base13 = widget_base(base1, /row, uname = 'linechoicebase') |
---|
418 | ;--------------------------------------------------- |
---|
419 | ; base 2: base to select the domain of the odd points |
---|
420 | ;--------------------------------------------------- |
---|
421 | base2 = widget_base(base, /column, uname = 'basedomainodd', /frame) |
---|
422 | ;--------------------------------------------------- |
---|
423 | ; base 3: base to select the domain of the even points |
---|
424 | ;--------------------------------------------------- |
---|
425 | base3 = widget_base(base, /column, uname = 'basedomaineven', /frame) |
---|
426 | ;--------------------------------------------------- |
---|
427 | ; base 4: base to select the domain of the odd-even points |
---|
428 | ;--------------------------------------------------- |
---|
429 | base4 = widget_base(base, /column, uname = 'basedomainodd-even', /frame) |
---|
430 | ;--------------------------------------------------- |
---|
431 | ; base 5: calendar |
---|
432 | ;--------------------------------------------------- |
---|
433 | base5 = widget_base(base, /row, uname = 'baset', /frame) |
---|
434 | timename = strlowcase((tag_names(dimlist))[wathinside.recdim]) |
---|
435 | ; read the time axis in julina days |
---|
436 | time = ncdf_timeget(cdfid, timename) |
---|
437 | ; update the dimlist structure |
---|
438 | dimlist.(wathinside.recdim) = time |
---|
439 | base51 = cw_calendar(base5, time, uname = 'date1', uvalue = {name:'date1'}) |
---|
440 | base52 = cw_calendar(base5, time, uname = 'date2', uvalue = {name:'date2'}) |
---|
441 | ;--------------------------------------------------- |
---|
442 | ; base 6: base to select the min, max, ... and others keywords |
---|
443 | ;--------------------------------------------------- |
---|
444 | base6 = cw_specifie(base, /column, uname = 'specifie', uvalue = {name:'specifie'}) |
---|
445 | ;--------------------------------------------------- |
---|
446 | ; base 7: last base with the action buttons |
---|
447 | ;--------------------------------------------------- |
---|
448 | base7 = widget_base(base, /row, uname = 'finalaction') |
---|
449 | base71 = widget_button(base7, value = 'Plot', uvalue = {name:'plot'}) |
---|
450 | base72 = widget_button(base7, value = 'Cancel', uvalue = {name:'cancel'}) |
---|
451 | ;--------------------------------------------------- |
---|
452 | ; determination of the selected variable ...... |
---|
453 | ;--------------------------------------------------- |
---|
454 | goodname = 0 > where(strlowcase(namevar) EQ strlowcase(selectedname)) |
---|
455 | goodtype = 0 > where(sectype EQ selectedtype) |
---|
456 | selected = inter(goodname, goodtype) |
---|
457 | if selected[0] EQ -1 then BEGIN |
---|
458 | widget_control, base, /destroy |
---|
459 | ncdf_close, cdfid |
---|
460 | return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname) |
---|
461 | ENDIF |
---|
462 | if n_elements(typein) NE 0 then BEGIN |
---|
463 | if NOT keyword_set(xlimits) then xlimits = [-1e9, 1e9] |
---|
464 | if NOT keyword_set(ylimits) then ylimits = [-1e9, 1e9] |
---|
465 | if NOT keyword_set(zlimits) then zlimits = [-1e9, 1e9] |
---|
466 | if NOT keyword_set(tlimits) then tlimits = [-1e9, 1e9] |
---|
467 | ENDIF |
---|
468 | if n_elements(typein) NE 0 AND n_elements(selected) NE 1 then BEGIN |
---|
469 | if keyword_set(oddpt) then selected = inter(selected, where(linetype EQ 'odd')) |
---|
470 | if keyword_set(evenpt) then selected = inter(selected, where(linetype EQ 'even')) |
---|
471 | if keyword_set(oddevenpt) then selected = inter(selected, where(linetype EQ 'odd-even')) |
---|
472 | if selected[0] EQ -1 then BEGIN |
---|
473 | widget_control, base, /destroy |
---|
474 | ncdf_close, cdfid |
---|
475 | return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname+' and line type ') |
---|
476 | endif |
---|
477 | if n_elements(selected) NE 1 then begin |
---|
478 | case selectedtype of |
---|
479 | 'xy':BEGIN |
---|
480 | ; choice on the vertical axis |
---|
481 | ; choice based on the variable which has the most available levels |
---|
482 | ; between the zlimits. |
---|
483 | if NOT keyword_set(zlimits) then begin |
---|
484 | print, 'case not coded...' |
---|
485 | stop |
---|
486 | ENDIF |
---|
487 | number = lonarr(n_elements(selected)) |
---|
488 | for i = 0, n_elements(selected)-1 do begin |
---|
489 | zdim = dimvar[2, selected[i]] |
---|
490 | zaxis = dimlist.(zdim) |
---|
491 | nothing = where(zaxis GE zlimits[0] AND zaxis LE zlimits[1], count) |
---|
492 | number[i] = count |
---|
493 | ENDFOR |
---|
494 | selected = selected[where(number EQ max(number))] |
---|
495 | if n_elements(selected) NE 1 then begin |
---|
496 | print, 'case not coded...' |
---|
497 | stop |
---|
498 | endif |
---|
499 | END |
---|
500 | 'xz':BEGIN |
---|
501 | ; choice on the latitude axis |
---|
502 | if NOT keyword_set(ylimits) then begin |
---|
503 | print, 'case not coded...' |
---|
504 | stop |
---|
505 | ENDIF |
---|
506 | number = lonarr(n_elements(selected)) |
---|
507 | for i = 0, n_elements(selected)-1 do begin |
---|
508 | ydim = dimvar[2, selected[i]] |
---|
509 | yaxis = dimlist.(ydim) |
---|
510 | nothing = where(yaxis GE ylimits[0] AND yaxis LE ylimits[1], count) |
---|
511 | number[i] = count |
---|
512 | ENDFOR |
---|
513 | selected = selected[where(number EQ max(number))] |
---|
514 | if n_elements(selected) NE 1 then begin |
---|
515 | print, 'case not coded...' |
---|
516 | stop |
---|
517 | endif |
---|
518 | END |
---|
519 | 'yz':BEGIN |
---|
520 | ; choice on the longitude axis |
---|
521 | if NOT keyword_set(xlimits) then begin |
---|
522 | print, 'case not coded...' |
---|
523 | stop |
---|
524 | ENDIF |
---|
525 | number = lonarr(n_elements(selected)) |
---|
526 | for i = 0, n_elements(selected)-1 do begin |
---|
527 | xdim = dimvar[2, selected[i]] |
---|
528 | xaxis = dimlist.(xdim) |
---|
529 | nothing = where(xaxis GE xlimits[0] AND xaxis LE xlimits[1], count) |
---|
530 | number[i] = count |
---|
531 | ENDFOR |
---|
532 | selected = selected[where(number EQ max(number))] |
---|
533 | if n_elements(selected) NE 1 then begin |
---|
534 | print, 'case not coded...' |
---|
535 | stop |
---|
536 | endif |
---|
537 | END |
---|
538 | endcase |
---|
539 | endif |
---|
540 | ENDIF |
---|
541 | ;--------------------------------------------------- |
---|
542 | ; definition of the uvalue of the base which allows to share the |
---|
543 | ; variables between programs. |
---|
544 | ;--------------------------------------------------- |
---|
545 | top_uvalue = ptrarr(2, 18, /allocate_heap) |
---|
546 | *top_uvalue[0, 0] = 'type choice' & *top_uvalue[1, 0] = temporary(typechoice) |
---|
547 | *top_uvalue[0, 1] = 'var choice' & *top_uvalue[1, 1] = temporary(varchoice) |
---|
548 | *top_uvalue[0, 2] = 'namevar' & *top_uvalue[1, 2] = temporary(namevar) |
---|
549 | *top_uvalue[0, 3] = 'dimvar' & *top_uvalue[1, 3] = temporary(dimvar) |
---|
550 | *top_uvalue[0, 4] = 'sectype' & *top_uvalue[1, 4] = temporary(sectype) |
---|
551 | *top_uvalue[0, 5] = 'linetype' & *top_uvalue[1, 5] = temporary(linetype) |
---|
552 | *top_uvalue[0, 6] = 'pointtype' & *top_uvalue[1, 6] = temporary(pointtype) |
---|
553 | *top_uvalue[0, 7] = 'dimlist' & *top_uvalue[1, 7] = temporary(dimlist) |
---|
554 | *top_uvalue[0, 8] = 'typedim' & *top_uvalue[1, 8] = temporary(typedim) |
---|
555 | *top_uvalue[0, 9] = 'sizedim' & *top_uvalue[1, 9] = temporary(sizedim) |
---|
556 | *top_uvalue[0, 10] = 'cdfid' & *top_uvalue[1, 10] = cdfid |
---|
557 | *top_uvalue[0, 11] = 'datavarid' & *top_uvalue[1, 11] = datavarid |
---|
558 | *top_uvalue[0, 12] = 'selected' & *top_uvalue[1, 12] = selected |
---|
559 | *top_uvalue[0, 13] = 'filename' & *top_uvalue[1, 13] = filename |
---|
560 | *top_uvalue[0, 14] = 'xlimits' & *top_uvalue[1, 14] = testvar(var = xlimits) |
---|
561 | *top_uvalue[0, 15] = 'ylimits' & *top_uvalue[1, 15] = testvar(var = ylimits) |
---|
562 | *top_uvalue[0, 16] = 'zlimits' & *top_uvalue[1, 16] = testvar(var = zlimits) |
---|
563 | *top_uvalue[0, 17] = 'tlimits' & *top_uvalue[1, 17] = testvar(var = tlimits) |
---|
564 | |
---|
565 | |
---|
566 | widget_control, base, set_uvalue = top_uvalue |
---|
567 | rh_alldomains, base, selected |
---|
568 | |
---|
569 | if n_params() EQ 0 then BEGIN |
---|
570 | ; we use the widget |
---|
571 | widget_control, base, /REALIZE |
---|
572 | xmanager, 'read_hope', base, /no_block |
---|
573 | return, -1 |
---|
574 | ENDIF |
---|
575 | ; get the output |
---|
576 | output = createhopestruct({top:base}) |
---|
577 | ; clear the pointer |
---|
578 | for i = 0, n_elements(top_uvalue)-1 do ptr_free, top_uvalue[i] |
---|
579 | ; close the file |
---|
580 | ncdf_close, cdfid |
---|
581 | return, output |
---|
582 | end |
---|