source: trunk/ToBeReviewed/HOPE/read_hope.pro @ 53

Last change on this file since 53 was 53, checked in by pinsard, 18 years ago

upgrade of ToBeReviewed?/HOPE according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

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