source: trunk/SRC/ToBeReviewed/HOPE/read_hope.pro @ 146

Last change on this file since 146 was 142, checked in by navarro, 18 years ago

english and nicer header (2a)

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