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

Last change on this file since 172 was 172, checked in by smasson, 18 years ago

bugfix + manage roms outputs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.8 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)
[172]89  tgnm = strlowcase(tag_names(exextra))
90  indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt)
91  IF cnt EQ 1 THEN boxextra = exextra.(indtmp[0])
92  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct', 'box', 'boxzoom'])
[69]93  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra)
94  sextra = struct2string(extra)
[2]95;---------------
[69]96; find date1 and date2
[2]97;---------------
[69]98  key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype
99  widget_control, date1id, get_value = date1
100  widget_control, date2id, get_value = date2
101
102  if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN
103; we redefine the dates to the begining and end of the calendar
104    calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter
105    date1 = jul2date(calendar[0])
106    date2 = jul2date(calendar[n_elements(calendar)-1])
107    widget_control, date1id, set_value = date1
108    widget_control, date2id, set_value = date2
109  endif
[2]110;
[69]111  fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal
112  IF keyword_set(fakecal) THEN BEGIN
113    date1 = date2jul(date1) - fakecal
114    date2 = date2jul(date2) - fakecal
115  ENDIF
116  sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1)
[2]117;---------------
[69]118; find boxzoom
[2]119;---------------
[69]120  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
[172]121  CASE n_elements(boxextra) OF
122    0:
123    1:boxzoom[5] = boxextra
124    2:boxzoom[4:5] = boxextra
125    4:boxzoom[0:3] = boxextra
126    5:boxzoom = [boxextra[0:3], 0, boxextra[4]]
127    6:boxzoom = boxextra
128  ENDCASE
[69]129; put boxzoom into a string
130  box = '['+strtrim(boxzoom[0], 1)
131  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
132     box = box+', '+strtrim(boxzoom[i], 1)
133  if strpos(type, 'z') NE -1 then BEGIN
[172]134      @cm_4mesh
135      min = min([gdept, gdepw, boxzoom[4:5]], max = max)
[2]136      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1)
[69]137    endif
138  box = box+']'
[74]139  IF strpos(type, ' diag up') NE -1 THEN BEGIN
[69]140    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
141                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
142  ENDIF
[74]143  IF strpos(type, ' diag dn') NE -1 THEN BEGIN
144    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $
145                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']'
146  ENDIF
[2]147;---------------
[69]148; find funclec_name, readparameters, meshparameters
[2]149;---------------
[69]150  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
151  funclec_name = readparameters.funclec_name
152  if keyword_set(complete) then begin
153    sreadparameters = struct2string(readparameters)
154    meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile]
155    smeshparameters = struct2string(meshparameters)
[2]156;------------------------------------------------------------
157;------------------------------------------------------------
158;------------------------------------------------------------
[150]159; We will define the string which will contain the command to be executed for the reading.
[2]160;------------------------------------------------------------
[69]161    Cmd = ['; Definition of extra structure:', 'extra = '+sextra $
162           , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $
163           , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $
164           , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $
165           , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $
166           , '; Read the data...' $
[74]167           , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $
168           , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $
[69]169           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $
[148]170           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2)+' $' $
171           , '    , boxzoom = '+box+', /findalways $' $
[69]172           , '    , filename = '+sfilename+' $']
173    if n_elements(sendpoints) NE 0 then $
174       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
175    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
176    (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar]
177    (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2]
178  ENDIF ELSE BEGIN
[146]179    Cmd = [funclec_name+'('+snamevar+', '+sdate1+', '+sdate2+', '+snameexp $
[148]180           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 1)+' $' $
181           , '    , boxzoom = '+box+', /findalways $' $
[69]182           , '    , filename = '+sfilename+' $']
183    if n_elements(sendpoints) NE 0 then $
184       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
185    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
186  ENDELSE
[2]187;    print, '::::::::::::::::::::::'
[69]188;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
[2]189;    print, '::::::::::::::::::::::'
190;------------------------------------------------------------
191
192;------------------------------------------------------------
[69]193  return, cmd
[2]194end
Note: See TracBrowser for help on using the repository browser.