source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro @ 157

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

header improvements + xxx doc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.4 KB
RevLine 
[2]1;+
[150]2;
3; @param BASE {in}{required}
4; The id of the widget where apply the drawing.
[2]5;
[150]6; @param SNAMEEXP {in}{required}
[2]7;
8;
[150]9; @param PROCEDURE {in}{required}
[2]10;
11;
[150]12; @param TYPE {in}{required}
[2]13;
[150]14;
15; @keyword BOXZOOM
16; Vector indicating the geographic zone on which we want to cut the map.
17; If BOXZOOM has :
18;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
19;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
20;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
21;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
22;   6 elements: The extraction is made on Boxzoom
23; Where lon1, lon2,lat1,lat2 are global variables defined at the last domdef!
[2]24;
[150]25; @keyword COMPLETE
[2]26;
[150]27
28; @keyword NAMEFIELD
[2]29;
30;
[150]31; @uses
32; common.pro
33;
34; @history
[157]35; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[150]36;
37; @version
38; $Id$
[2]39;
[150]40; @todo
41; seb: documenter les param et les keyword qui ne le sont pas.
42;
[2]43;-
[69]44FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $
45                       , COMPLETE = complete, NAMEFIELD = namefield
46;
[114]47;
48  compile_opt idl2, strictarrsubs
49;
[69]50@cm_4cal ; for key_caltype
[2]51;------------------------------------------------------------
[69]52; get back widgets IDs
[2]53;------------------------------------------------------------
[69]54  vlstid = widget_info(base, find_by_uname = 'varlist')
55  date1id = widget_info(base, find_by_uname = 'calendar1')
56  date2id = widget_info(base, find_by_uname = 'calendar2')
57  domainid = widget_info(base, find_by_uname = 'domain')
[2]58;   optionid = widget_info(base, find_by_uname = 'option')
59;------------------------------------------------------------
[69]60  widget_control, base, get_uvalue = top_uvalue
61  numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
62  numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1
[2]63;---------------
[69]64; name of the file
[2]65;---------------
[69]66  currentfile = extractatt(top_uvalue, 'currentfile')
67  filelist = extractatt(top_uvalue, 'filelist')
68  filename = filelist[currentfile]
69  sfilename = ''''+filename+''''
[2]70;---------------
[69]71; name of the variable
[2]72;---------------
[69]73  if keyword_set(namefield) then namevar = namefield $
74  ELSE namevar = widget_info(vlstid, /combobox_gettext)
75  snamevar = ''''+namevar+''''
[2]76;
[69]77; get the options
[2]78;
[69]79  options = extractatt(top_uvalue, 'options')   
80  flags = extractatt(top_uvalue, 'optionsflag')
81  flags = flags[*, numdessinin]
82  xindex = (flags[where(options EQ 'Longitude / x index')])[0]
83  yindex = (flags[where(options EQ 'Latitude / y index')])[0]
[2]84;
[69]85  extra = extractatt(top_uvalue, 'extra')
86  if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
87  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
88  exextra = cw_specifie_get_value(base)
89  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct'])
90  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra)
91  sextra = struct2string(extra)
[2]92;---------------
[69]93; find date1 and date2
[2]94;---------------
[69]95  key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype
96  widget_control, date1id, get_value = date1
97  widget_control, date2id, get_value = date2
98
99  if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN
100; we redefine the dates to the begining and end of the calendar
101    calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter
102    date1 = jul2date(calendar[0])
103    date2 = jul2date(calendar[n_elements(calendar)-1])
104    widget_control, date1id, set_value = date1
105    widget_control, date2id, set_value = date2
106  endif
[2]107;
[69]108  fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal
109  IF keyword_set(fakecal) THEN BEGIN
110    date1 = date2jul(date1) - fakecal
111    date2 = date2jul(date2) - fakecal
112  ENDIF
113  sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1)
[2]114;---------------
[69]115; find boxzoom
[2]116;---------------
[69]117  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
118; put boxzoom into a string
119  box = '['+strtrim(boxzoom[0], 1)
120  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
121     box = box+', '+strtrim(boxzoom[i], 1)
122  if strpos(type, 'z') NE -1 then BEGIN
[2]123      @common
124      min = min([gdept, gdepw], max = max)
125      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1)
[69]126    endif
127  box = box+']'
[74]128  IF strpos(type, ' diag up') NE -1 THEN BEGIN
[69]129    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
130                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
131  ENDIF
[74]132  IF strpos(type, ' diag dn') NE -1 THEN BEGIN
133    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $
134                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']'
135  ENDIF
[2]136;---------------
[69]137; find funclec_name, readparameters, meshparameters
[2]138;---------------
[69]139  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
140  funclec_name = readparameters.funclec_name
141  if keyword_set(complete) then begin
142    sreadparameters = struct2string(readparameters)
143    meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile]
144    smeshparameters = struct2string(meshparameters)
[2]145;------------------------------------------------------------
146;------------------------------------------------------------
147;------------------------------------------------------------
[150]148; We will define the string which will contain the command to be executed for the reading.
[2]149;------------------------------------------------------------
[69]150    Cmd = ['; Definition of extra structure:', 'extra = '+sextra $
151           , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $
152           , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $
153           , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $
154           , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $
155           , '; Read the data...' $
[74]156           , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $
157           , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $
[69]158           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $
[148]159           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2)+' $' $
160           , '    , boxzoom = '+box+', /findalways $' $
[69]161           , '    , filename = '+sfilename+' $']
162    if n_elements(sendpoints) NE 0 then $
163       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
164    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
165    (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar]
166    (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2]
167  ENDIF ELSE BEGIN
[146]168    Cmd = [funclec_name+'('+snamevar+', '+sdate1+', '+sdate2+', '+snameexp $
[148]169           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 1)+' $' $
170           , '    , boxzoom = '+box+', /findalways $' $
[69]171           , '    , filename = '+sfilename+' $']
172    if n_elements(sendpoints) NE 0 then $
173       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
174    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
175  ENDELSE
[2]176;    print, '::::::::::::::::::::::'
[69]177;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
[2]178;    print, '::::::::::::::::::::::'
179;------------------------------------------------------------
180
181;------------------------------------------------------------
[69]182  return, cmd
[2]183end
Note: See TracBrowser for help on using the repository browser.