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

Last change on this file since 378 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

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