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
Line 
1;+
2;
3; @param BASE {in}{required}
4; The id of the widget where apply the drawing.
5;
6; @param SNAMEEXP {in}{required}
7;
8;
9; @param PROCEDURE {in}{required}
10;
11;
12; @param TYPE {in}{required}
13;
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!
24;
25; @keyword COMPLETE
26;
27
28; @keyword NAMEFIELD
29;
30;
31; @uses
32; common.pro
33;
34; @history
35; Sebastien Masson (smasson\@lodyc.jussieu.fr)
36;
37; @version
38; $Id$
39;
40; @todo
41; seb: documenter les param et les keyword qui ne le sont pas.
42;
43;-
44FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $
45                       , COMPLETE = complete, NAMEFIELD = namefield
46;
47;
48  compile_opt idl2, strictarrsubs
49;
50@cm_4cal ; for key_caltype
51;------------------------------------------------------------
52; get back widgets IDs
53;------------------------------------------------------------
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')
58;   optionid = widget_info(base, find_by_uname = 'option')
59;------------------------------------------------------------
60  widget_control, base, get_uvalue = top_uvalue
61  numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
62  numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1
63;---------------
64; name of the file
65;---------------
66  currentfile = extractatt(top_uvalue, 'currentfile')
67  filelist = extractatt(top_uvalue, 'filelist')
68  filename = filelist[currentfile]
69  sfilename = ''''+filename+''''
70;---------------
71; name of the variable
72;---------------
73  if keyword_set(namefield) then namevar = namefield $
74  ELSE namevar = widget_info(vlstid, /combobox_gettext)
75  snamevar = ''''+namevar+''''
76;
77; get the options
78;
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]
84;
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  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'])
93  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra)
94  sextra = struct2string(extra)
95;---------------
96; find date1 and date2
97;---------------
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
110;
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)
117;---------------
118; find boxzoom
119;---------------
120  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
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
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
134      @cm_4mesh
135      min = min([gdept, gdepw, boxzoom[4:5]], max = max)
136      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1)
137    endif
138  box = box+']'
139  IF strpos(type, ' diag up') NE -1 THEN BEGIN
140    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
141                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
142  ENDIF
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
147;---------------
148; find funclec_name, readparameters, meshparameters
149;---------------
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)
156;------------------------------------------------------------
157;------------------------------------------------------------
158;------------------------------------------------------------
159; We will define the string which will contain the command to be executed for the reading.
160;------------------------------------------------------------
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...' $
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 $
169           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $
170           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2)+' $' $
171           , '    , boxzoom = '+box+', /findalways $' $
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
179    Cmd = [funclec_name+'('+snamevar+', '+sdate1+', '+sdate2+', '+snameexp $
180           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 1)+' $' $
181           , '    , boxzoom = '+box+', /findalways $' $
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
187;    print, '::::::::::::::::::::::'
188;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
189;    print, '::::::::::::::::::::::'
190;------------------------------------------------------------
191
192;------------------------------------------------------------
193  return, cmd
194end
Note: See TracBrowser for help on using the repository browser.