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

Last change on this file since 230 was 230, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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