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

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • 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; @examples
286;
287;   IDL> a=read_hope('xy','ocpt',filename='CLIM_CNT_1993-1998.nc')
288;   IDL> help, a,/struct
289;     ** Structure <82ec344>, 6 tags, length=1860176, refs=1:
290;        ARRAY           FLOAT     Array[128, 242, 15]
291;        UNIT            STRING    'deg C'
292;        NAME            STRING    'Ocean potential temperature'
293;        DATE            FLOAT     Array[1]
294;        GRID            STRING    'T'
295;        HOPEGRID        STRUCT    -> <Anonymous> Array[1]
296;   IDL> help, a.hopegrid,/struct
297;     ** Structure <82eb9cc>, 8 tags, length=1588, refs=2:
298;        XAXIS           FLOAT     Array[128]
299;        YAXIS           FLOAT     Array[242]
300;        ZAXIS           FLOAT     Array[15]
301;        FIRSTS          LONG      Array[3]
302;        LASTS           LONG      Array[3]
303;        TYPE            STRING    'xy'
304;        LINETYPE        STRING    'odd-even'
305;        PTTYPE          STRING    'T'
306;   IDL> help, litchamp(a)
307;     <Expression>    FLOAT     = Array[128, 242, 15]
308;
309; @history
310; Sebastien Masson (smasson\@lodyc.jussieu.fr)
311;                      June 2001
312;
313; @version
314; $Id$
315;
316;-
317FUNCTION read_hope, typein, varnamein, FILENAME=filename $
318                  , XLIMITS=xlimits, YLIMITS=ylimits, ZLIMITS=zlimits $
319                  , TLIMITS=tlimits, ODDPT=oddpt, ODDEVENPT=oddevenpt $
320                  , EVENPT=evenpt, _EXTRA=ex
321;
322  compile_opt idl2, strictarrsubs
323;
324@common                         ; useful only for the definition of iodir
325  if n_elements(filename) EQ 0 then filename = isafile(iodirectory = iodir, _extra = ex)
326  IF size(filename, /type) NE 7 THEN return, -1
327  filename = isafile(filename = filename, iodirectory = iodir, _extra = ex)
328;
329  cdfid = ncdf_open(filename)       ; id of the netcdf file
330  wathinside = ncdf_inquire(cdfid)  ; structure with global informations
331;-------------------------------
332;  dimensions
333;-------------------------------
334  namedim = strarr(wathinside.ndims)  ; name of the dimensions
335  typedim = strarr(wathinside.ndims)  ; type of the dimensions (x,y,z,t)
336  sizedim = lonarr(wathinside.ndims)  ; size of each dimension
337; loop on the dimensions to get the names and sizes
338  for dimiq = 0, wathinside.ndims-1 do begin
339    ncdf_diminq, cdfid, dimiq, name, value
340    namedim[dimiq] = name
341    case 1 of
342      STRCMP(name, 'lon', 3, /FOLD_CASE):typedim[dimiq] = 'x'
343      STRCMP(name, 'lat', 3, /FOLD_CASE):typedim[dimiq] = 'y'
344      STRCMP(name, 'z', 1, /FOLD_CASE):typedim[dimiq] = 'z'
345      STRCMP(name, 't', 1, /FOLD_CASE):typedim[dimiq] = 't'
346      ELSE:BEGIN
347        ncdf_close, cdfid
348        return, report('Unknown name of dimension')
349      END
350    endcase
351    sizedim[dimiq] = value
352  endfor
353; dimlist: structure which contains the name and the value of each
354; dimension
355; we suppose that there is always a variable which has the
356; same name that the dimension and which gives the values of
357; this dimension
358  ncdf_varget, cdfid, namedim[0], value
359  dimlist = create_struct(namedim[0], value)
360  for dimiq = 1, wathinside.ndims-1 do begin
361    ncdf_varget, cdfid, namedim[dimiq], value ;get the value
362    dimlist = create_struct(dimlist, namedim[dimiq], value)
363  endfor
364;-------------------------------
365;  variables
366;-------------------------------
367  namevar = strarr(wathinside.nvars)   ; names of the variables
368  ndimsvar = lonarr(wathinside.nvars)  ; number of dim for each variable
369  dimvar = replicate(-1, wathinside.ndims, wathinside.nvars) ; dims of each variables
370; loop over the variable ids to fill namevar, ndimsvar and dimvar
371  for varid = 0, wathinside.nvars-1 do begin
372    res = ncdf_varinq(cdfid, varid)
373    namevar[varid] = res.name
374    namevar[varid] = strjoin(strsplit(namevar[varid], '_[0-99]', /EXTRACT, /REGEX))
375    ndimsvar[varid] = res.ndims
376    dimvar[0:res.ndims-1, varid] = res.dim
377  ENDFOR
378; we cut dimvar to select only the interesting part
379  dimvar = dimvar[0:max(ndimsvar)-1, *]
380; selection of the data variables which are different from the
381; dimension variables
382; we suppose that that data variables are 4D array (with sometime
383; dimensions equal to 1). they must be different from dimension
384; variables which have only 1 dimension
385  datavarid = where(ndimsvar eq 4)
386  numberofvar = n_elements(datavarid)
387  namevar = namevar[datavarid]
388  ndimsvar = ndimsvar[datavarid]
389  dimvar = dimvar[*, datavarid]
390;
391  sectype = strarr(numberofvar) ; the type of section for each variable :'xy', 'xz', 'yz'...
392  linetype = strarr(numberofvar) ; the line of the points : odd, even or odd-even
393  pointtype = strarr(numberofvar) ; the type of variable : scalar ('T') or vector ('U')
394  for i = 0, numberofvar-1 do begin
395    dimofthevar = dimvar[*, i]
396    sectype[i] = typedim[dimofthevar[0]]+typedim[dimofthevar[1]]
397    xaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'x')]
398    yaxisid = dimofthevar[where(typedim[dimofthevar] EQ 'y')]
399    lineandpt = findlineandpointtype(sectype[i], dimlist.(xaxisid[0]), dimlist.(yaxisid[0]), iodir)
400    linetype[i] = lineandpt.linetype
401    pointtype[i] = lineandpt.pointtype
402  endfor
403;
404;---------------------------------------------------
405;---------------------------------------------------
406;---------------------------------------------------
407;  definition of the widget
408;---------------------------------------------------
409;---------------------------------------------------
410;---------------------------------------------------
411  base = widget_base(/column)
412;---------------------------------------------------
413; first base:
414;    droplist to select the type of section
415;    droplist to select the variable
416;    button to select type of line : odd, even or odd-even
417;---------------------------------------------------
418  base1 = widget_base(base, /row, /frame)
419  typechoice = sectype[uniq(sectype, sort(sectype))]
420  if n_elements(typechoice) GT 1 then typechoice = typechoice[sortdim(typechoice)]
421  base11 = widget_droplist(base1, title = 'Type of section', value = typechoice, uvalue = {name:'type choice'}, uname = 'type choice')
422  if n_elements(typein) NE 0 then BEGIN
423    selectedtype = strmid(typein, 0, 2)
424    widget_control, base11, set_droplist_select $
425                    = 0L > (where(typechoice EQ selectedtype))[0]
426  ENDIF ELSE selectedtype = typechoice[0]
427;
428  varchoice = namevar[uniq(namevar, sort(namevar))]
429  base12 = widget_droplist(base1, title = 'Available data', value = varchoice, uvalue = {name:'var choice'}, uname = 'var choice')
430  if n_elements(varnamein) NE 0 THEN BEGIN
431    selectedname = varnamein
432    widget_control, base12, set_droplist_select $
433                    = 0L > (where(strlowcase(varchoice) EQ strlowcase(varnamein)))[0]
434  ENDIF ELSE selectedname = varchoice[0]
435;
436  base13 = widget_base(base1, /row, uname = 'linechoicebase')
437;---------------------------------------------------
438; base 2: base to select the domain of the odd points
439;---------------------------------------------------
440  base2 = widget_base(base, /column, uname = 'basedomainodd', /frame)
441;---------------------------------------------------
442; base 3: base to select the domain of the even points
443;---------------------------------------------------
444  base3 = widget_base(base, /column, uname = 'basedomaineven', /frame)
445;---------------------------------------------------
446; base 4: base to select the domain of the odd-even points
447;---------------------------------------------------
448  base4 = widget_base(base, /column, uname = 'basedomainodd-even', /frame)
449;---------------------------------------------------
450; base 5: calendar
451;---------------------------------------------------
452  base5 = widget_base(base, /row, uname = 'baset', /frame)
453  timename = strlowcase((tag_names(dimlist))[wathinside.recdim])
454; read the time axis in Julian days
455  time = ncdf_gettime(filename, cdfid)
456; update the dimlist structure
457  dimlist.(wathinside.recdim) = time
458  base51 = cw_calendar(base5, time, uname = 'date1', uvalue = {name:'date1'})
459  base52 = cw_calendar(base5, time, uname = 'date2', uvalue = {name:'date2'})
460;---------------------------------------------------
461;  base 6: base to select the min, max, ... and others keywords
462;---------------------------------------------------
463  base6 = cw_specifie(base, /column, uname = 'specifie', uvalue = {name:'specifie'})
464;---------------------------------------------------
465;  base 7: last base with the action buttons
466;---------------------------------------------------
467  base7 = widget_base(base, /row, uname = 'finalaction')
468  base71 = widget_button(base7, value = 'Plot', uvalue = {name:'plot'})
469  base72 = widget_button(base7, value = 'Cancel', uvalue = {name:'cancel'})
470;---------------------------------------------------
471; determination of the selected variable ......
472;---------------------------------------------------
473  goodname = 0 > where(strlowcase(namevar) EQ strlowcase(selectedname))
474  goodtype = 0 > where(sectype EQ selectedtype)
475  selected = inter(goodname, goodtype)
476  if selected[0] EQ -1 then BEGIN
477    widget_control, base, /destroy
478    ncdf_close, cdfid
479    return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname)
480  ENDIF
481  if n_elements(typein) NE 0 then BEGIN
482    if NOT keyword_set(xlimits) then xlimits = [-1e9, 1e9]
483    if NOT keyword_set(ylimits) then ylimits = [-1e9, 1e9]
484    if NOT keyword_set(zlimits) then zlimits = [-1e9, 1e9]
485    if NOT keyword_set(tlimits) then tlimits = [-1e9, 1e9]
486  ENDIF
487  if n_elements(typein) NE 0 AND n_elements(selected) NE 1 then BEGIN
488    if keyword_set(oddpt) then selected = inter(selected, where(linetype EQ 'odd'))
489    if keyword_set(evenpt) then selected = inter(selected, where(linetype EQ 'even'))
490    if keyword_set(oddevenpt) then selected = inter(selected, where(linetype EQ 'odd-even'))
491    if selected[0] EQ -1 then BEGIN
492      widget_control, base, /destroy
493      ncdf_close, cdfid
494      return, report('impossible combinaison : type of section '+selectedtype+', variable name '+selectedname+' and line type ')
495    endif
496    if n_elements(selected) NE 1 then begin
497      case selectedtype of
498        'xy':BEGIN
499; choice on the vertical axis
500; choice based on the variable which has the most available levels
501; between the zlimits.
502          if NOT keyword_set(zlimits) 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            zdim = dimvar[2, selected[i]]
509            zaxis = dimlist.(zdim)
510            nothing = where(zaxis GE zlimits[0] AND zaxis LE zlimits[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        'xz':BEGIN
520; choice on the latitude axis
521          if NOT keyword_set(ylimits) 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            ydim = dimvar[2, selected[i]]
528            yaxis = dimlist.(ydim)
529            nothing = where(yaxis GE ylimits[0] AND yaxis LE ylimits[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        'yz':BEGIN
539; choice on the longitude axis
540          if NOT keyword_set(xlimits) then begin
541            print, 'case not coded...'
542            stop
543          ENDIF
544          number = lonarr(n_elements(selected))
545          for i = 0, n_elements(selected)-1 do begin
546            xdim = dimvar[2, selected[i]]
547            xaxis = dimlist.(xdim)
548            nothing = where(xaxis GE xlimits[0] AND xaxis LE xlimits[1], count)
549            number[i] = count
550          ENDFOR
551          selected = selected[where(number EQ max(number))]
552          if n_elements(selected) NE 1 then begin
553            print, 'case not coded...'
554            stop
555          endif
556        END
557      endcase
558    endif
559  ENDIF
560;---------------------------------------------------
561; definition of the uvalue of the base which allows to share the
562; variables between programs.
563;---------------------------------------------------
564  top_uvalue = ptrarr(2, 18, /allocate_heap)
565  *top_uvalue[0, 0] = 'type choice' & *top_uvalue[1, 0] = temporary(typechoice)
566  *top_uvalue[0, 1] = 'var choice' & *top_uvalue[1, 1] = temporary(varchoice)
567  *top_uvalue[0, 2] = 'namevar' & *top_uvalue[1, 2] = temporary(namevar)
568  *top_uvalue[0, 3] = 'dimvar' & *top_uvalue[1, 3] = temporary(dimvar)
569  *top_uvalue[0, 4] = 'sectype' & *top_uvalue[1, 4] = temporary(sectype)
570  *top_uvalue[0, 5] = 'linetype' & *top_uvalue[1, 5] = temporary(linetype)
571  *top_uvalue[0, 6] = 'pointtype' & *top_uvalue[1, 6] = temporary(pointtype)
572  *top_uvalue[0, 7] = 'dimlist' & *top_uvalue[1, 7] = temporary(dimlist)
573  *top_uvalue[0, 8] = 'typedim' & *top_uvalue[1, 8] = temporary(typedim)
574  *top_uvalue[0, 9] = 'sizedim' & *top_uvalue[1, 9] = temporary(sizedim)
575  *top_uvalue[0, 10] = 'cdfid' & *top_uvalue[1, 10] = cdfid
576  *top_uvalue[0, 11] = 'datavarid' & *top_uvalue[1, 11] = datavarid
577  *top_uvalue[0, 12] = 'selected' & *top_uvalue[1, 12] = selected
578  *top_uvalue[0, 13] = 'filename' & *top_uvalue[1, 13] = filename
579  *top_uvalue[0, 14] = 'xlimits' & *top_uvalue[1, 14] = testvar(var = xlimits)
580  *top_uvalue[0, 15] = 'ylimits' & *top_uvalue[1, 15] = testvar(var = ylimits)
581  *top_uvalue[0, 16] = 'zlimits' & *top_uvalue[1, 16] = testvar(var = zlimits)
582  *top_uvalue[0, 17] = 'tlimits' & *top_uvalue[1, 17] = testvar(var = tlimits)
583
584  widget_control, base, set_uvalue = top_uvalue
585  rh_alldomains, base, selected
586
587  if n_params() EQ 0 then BEGIN
588; we use the widget
589    widget_control, base, /REALIZE
590    xmanager, 'read_hope', base, /no_block
591    return,  -1
592  ENDIF
593; get the output
594  output = createhopestruct({top:base})
595; clear the pointer
596  for i = 0, n_elements(top_uvalue)-1 do ptr_free, top_uvalue[i]
597; close the file
598  ncdf_close, cdfid
599  return, output
600end
Note: See TracBrowser for help on using the repository browser.