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

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

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

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