source: trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcommand.pro @ 49

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

upgrade of AUTOUR_de_XXX according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 19.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:buildcommand
6;
7; PURPOSE:cette fonction reourne un string qui contient la commande de
8; lecture et les parametres du trace.
9;
10; CATEGORY:
11;
12; CALLING SEQUENCE:
13;
14; INPUTS:
15;
16; KEYWORD PARAMETERS:
17;
18; OUTPUTS:
19;
20; COMMON BLOCKS:
21;
22; SIDE EFFECTS:
23;
24; RESTRICTIONS:
25;
26; EXAMPLE:
27;
28; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
29;
30;-
31;------------------------------------------------------------
32;------------------------------------------------------------
33;------------------------------------------------------------
34FUNCTION buildcommand, base, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, BOXZOOM = boxzoom
35;
36;------------------------------------------------------------
37; on recuper les ID des differents widgets
38;------------------------------------------------------------
39   filelistid = widget_info(base, find_by_uname = 'filelist')
40   champid = widget_info(base, find_by_uname = 'champ')
41   nomexpid = widget_info(base, find_by_uname = 'nom_exp')
42   date1id = widget_info(base, find_by_uname = 'calendar1')
43   date2id = widget_info(base, find_by_uname = 'calendar2')
44   domainid = widget_info(base, find_by_uname = 'domain')
45   graphtypeid = widget_info(base, find_by_uname = 'action')
46;   optionid = widget_info(base, find_by_uname = 'option')
47;------------------------------------------------------------
48   widget_control,base, get_uvalue = top_uvalue
49   smallin = extractatt(top_uvalue, 'smallin')
50   numdessinin = smallin[2]-1
51   smallout = extractatt(top_uvalue, 'smallout')
52   numdessinout = smallout[2]-1
53;------------------------------------------------------------
54;---------------
55; on determine quelle procedure on va etre appele pour faire le dessin
56; et le type
57;---------------
58   widget_control,graphtypeid, get_uvalue = graphtype_uvalue
59   type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)]
60;   type = top_uvalue.nameprocedures[numdessinin]
61   case type of
62      'plt':procedure = 'plt'
63      'pltz':procedure = 'pltz'
64      'pltt':procedure = 'pltt'
65      'xy':procedure = 'plt'
66      'xz':procedure = 'pltz'
67      'yz':procedure = 'pltz'
68      'xt':procedure = 'pltt'
69      'yt':procedure = 'pltt'
70      'zt':procedure = 'pltt'
71      'x':procedure = 'plt1d'
72      'y':procedure = 'plt1d'
73      'z':procedure = 'plt1d'
74      't':procedure = 'pltt'
75   endcase
76   if keyword_set(forplth) then BEGIN
77      procedure = 'plt'
78      type = 'plt'
79   ENDIF
80   if keyword_set(forpltz) then BEGIN
81      procedure = 'pltz'
82      type = 'pltz'
83   ENDIF
84   if keyword_set(forpltt) then BEGIN
85      procedure = 'pltt'
86      type = 'pltt'
87   ENDIF
88;
89;  recherche des options
90;
91   options = extractatt(top_uvalue, 'options')   
92   optionsflag = extractatt(top_uvalue, 'optionsflag')
93   flags = optionsflag[*, numdessinin]
94   xindex = (flags[where(options EQ 'Longitude / x index')])[0]
95   yindex = (flags[where(options EQ 'Latitude / y index')])[0]
96   drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt')
97   drawover = (flags[where(options EQ 'Overlay')])[0]
98;
99   alreadyread = extractatt(top_uvalue, 'alreadyread')
100   alreadyvector = extractatt(top_uvalue, 'alreadyvector')
101   alreadyover = extractatt(top_uvalue, 'alreadyoer')
102; que devons-nous lire ?
103   case 1 of
104      alreadyover NE -1:BEGIN
105         toread = alreadyover+1
106         whichread = 'over'
107      END
108      alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN
109         toread = alreadyvector+1
110         whichread = 'vector'
111      END
112      alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN
113         toread = alreadyread+1
114         whichread = 'classic'
115      END
116      else:BEGIN
117         case 1 of
118            alreadyvector eq !pi:BEGIN
119               toread = alreadyover+1
120               whichread = 'over'
121            END
122            alreadyread EQ !pi:BEGIN
123               toread = alreadyvector+1
124               whichread = 'vector'
125            END
126            alreadyread EQ 2.*!pi:BEGIN
127               toread = alreadyover+1
128               whichread = 'over'
129            END
130            ELSE:BEGIN
131               toread = alreadyread+1
132               whichread = 'classic'
133            END
134         endcase
135      END
136   ENDCASE
137;
138   widget_control, nomexpid, get_value = widcommand
139   widcommand = strcompress(widcommand[0], /remove_all)
140   cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add
141;
142   readcommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = whichread EQ 'classic' AND alreadyread EQ -1)
143; on choppe la ligne ou il y a litchamp pour appliquer coef et operateur
144   i = 0
145   while strpos(readcommande[i], 'litchamp') EQ -1 do i = i+1
146;-----------------------
147;-----------------------
148;-----------------------
149;-----------------------
150;-----------------------
151   case whichread of
152      'classic':BEGIN
153         if alreadyread+1 EQ 0 then BEGIN
154; on commence a ecrire la commande de lecture...
155            readcommande = ['; beginning of reading the field to draw' $
156                            , '; field number: '+strtrim(alreadyread+2, 1), readcommande]
157            readcommande[i+2] = 'field = '+coef+operation+readcommande[i+2]
158            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
159         ENDIF ELSE BEGIN
160            readcommande = ['; field number: '+strtrim(alreadyread+2, 1), readcommande]
161            readcommande[i+1] = 'field = field'+separator+coef+operation+readcommande[i+1]
162            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
163            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
164         ENDELSE
165         if alreadyread+1 NE numberofread-1 THEN BEGIN
166; si il faut lire d''autres champs on sort
167            *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1
168            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1))
169            return,  ''
170         ENDIF
171; on finalise la commande de lecture
172         readcommande = [readcommande, 'field = field'+add $
173                         , 'field = create_struct({tab:field, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
174                         , '; end of reading the field to draw', ';']
175; on recupere le _EXTRA:
176         extra = extractatt(top_uvalue, 'extra')
177         if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
178         if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
179         exextra = cw_specifie_get_value(base)
180         extra =  mixstru(exextra,extra)
181         sextra = struct2string(extra)
182         readcommande = [readcommande, 'extra = '+sextra]
183;
184         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
185         case 1 of
186            drawvecteur:BEGIN
187; quelle function de lecture utilisons nous? trace des vecteurs de
188; facon automatique ou non?
189               currentfile = extractatt(top_uvalue, 'currentfile')
190               funclec_name = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
191               funclec_name = funclec_name.funclec_name
192               if funclec_name EQ 'read_ncdf' then begin
193; il faut lire des vecteurs maintenant?
194                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi
195                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector')
196                  return,  ''
197               ENDIF ELSE BEGIN
198; on fait un trace automatique en appelant un et vn ...
199                  readuncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'un')
200                  i = 0
201                  while strpos(readuncommande[i], 'litchamp') EQ -1 do i = i+1
202                  readuncommande = ['; reading the zonal component of vector', readuncommande]
203                  readuncommande[i+1] = 'fieldu = '+readuncommande[i+1]
204                  readuncommande = [readuncommande,'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
205;
206                  readvncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'vn')
207                  i = 0
208                  while strpos(readvncommande[i], 'litchamp') EQ -1 do i = i+1
209                  readvncommande = ['; reading the zonal component of vector', readvncommande]
210                  readvncommande[i+1] = 'fieldv = '+readvncommande[i+1]
211                  readvncommande = [readvncommande,'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
212;
213                  readcommande = [readcommande,';', readuncommande, ';', readvncommande]
214                  *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
215; on enchaine sur un over plot???
216                  if drawover then begin
217                     *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
218                     *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
219                     return,  ''
220                  ENDIF ELSE *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
221               ENDELSE
222            END
223            drawover:BEGIN
224; il faut lire un autre champ a surcontourer?
225               *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
226               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
227               return,  ''
228            END
229; c'est tout pour la lecture, on va tracer!
230            ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
231         endcase
232      END
233      'vector':BEGIN
234; pour lesvecteurs, il y a 2 composantes! en u et en v donc il faut
235; doubler la lecture. pour alreadyvector entier, on lit u pour
236; alreadyvector entier+0.5, on lit v!
237         if floor(alreadyvector)+1 EQ 0 then begin
238            if floor(alreadyvector) EQ alreadyvector then begin
239               readcommande = ['; beginning of reading the zonal component of vector' $
240                               , '; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
241               readcommande[i+2] = 'fieldu = '+coef+operation+readcommande[i+2]
242               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
243            ENDIF ELSE BEGIN
244               readcommande = ['; beginning of reading the meridional component of vector' $
245                               , '; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
246               readcommande[i+2] = 'fieldv = '+coef+operation+readcommande[i+2]
247               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
248            ENDELSE
249         ENDIF ELSE BEGIN
250            if floor(alreadyvector) EQ alreadyvector then begin
251               readcommande = ['; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
252               readcommande[i+1] = 'fieldu = fieldu'+separator+coef+operation+readcommande[i+1]
253               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
254            ENDIF ELSE BEGIN
255               readcommande = ['; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
256               readcommande[i+1] = 'fieldv = fieldv'+separator+coef+operation+readcommande[i+1]
257               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
258            ENDELSE
259         ENDELSE
260         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
261;
262         case alreadyvector+1 of
263            numberofread-1:BEGIN
264; on finalise la commande de lecture
265               readcommande = [readcommande, 'fieldu = fieldu'+add $
266                               , 'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
267                               , '; end of reading the zonal component of vector', ';']
268               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
269; on vient de finir le lecture des U
270               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5
271               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector')
272               return,  ''
273            END
274            numberofread-0.5:BEGIN
275; on finalise la commande de lecture
276               readcommande = [readcommande, 'fieldv = fieldv'+add $
277                               , 'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
278                               , '; end of reading the meridional component of vector', ';']
279; on vient de finir le lecture des V
280;
281; on recupere le _EXTRA de vector et on complete eventuellement le extra
282; deja constitue:
283               extra = extractatt(top_uvalue, 'extra')
284               exextra = cw_specifie_get_value(base)
285               extra =  mixstru(exextra,extra)
286               sextra = struct2string(extra)
287               readcommande = [readcommande, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)']
288;
289               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
290;
291               if drawover then BEGIN
292; on enchaine sur un surcontour
293                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi
294                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
295                  return,  ''
296               ENDIF ELSE BEGIN
297                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
298                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
299               ENDELSE
300            END
301            ELSE:BEGIN
302               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1
303               if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $
304               ELSE text = ' meridional '
305               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector')
306               return,  ''
307            END
308         endcase
309      END
310      'over':BEGIN
311         if alreadyover+1 EQ 0 then begin
312; on commence a ecrire la commande de lecture...
313            readcommande = ['; beginning of reading the field to overdraw' $
314                            , '; fieldover number: '+strtrim(alreadyread+2, 1), readcommande]
315            readcommande[i+2] = 'fieldover = '+coef+operation+readcommande[i+2]
316            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
317         ENDIF ELSE BEGIN
318            readcommande = ['; fieldover number: '+strtrim(alreadyover+2, 1), readcommande]
319            readcommande[i+1] = 'fieldover = fieldover'+separator+coef+operation+readcommande[i+1]
320            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
321         ENDELSE
322         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
323;
324         if alreadyover+1 NE numberofread-1 THEN BEGIN
325; si il faut lire d''autres champs on sort
326            *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1
327            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay')
328            return,  ''
329         ENDIF
330; on finalise la commande de lecture
331         readcommande = [readcommande, 'fieldover = fieldover'+add $
332                         , 'fieldover = create_struct({tab:fieldover, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
333                         , '; end of reading the field to overdraw', ';']
334; on recupere le _EXTRA de over et on complete eventuellement le extra
335; deja constitue:
336         extra = extractatt(top_uvalue, 'extra')
337         exextra = cw_specifie_get_value(base)
338         extra =  mixstru(exextra,extra)
339         sextra = struct2string(extra)
340         readcommande = [readcommande, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)']
341;
342         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
343; on remet les compteurs a 0
344         *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
345         *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
346         *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1
347      END
348   endcase
349;
350;-----------------------
351;-----------------------
352;-----------------------
353;-----------------------
354;-----------------------
355;-----------------------
356;---------------
357; determination du nom de la boxzoom
358;---------------
359   if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
360; ecriture de celle-ci sous forme d''un string
361   box = '['+strtrim(boxzoom[0], 1)
362   for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
363    box = box+', '+strtrim(boxzoom[i], 1)
364; pour les [plots en z, box doit avoir par defaut 0,profmax
365   if strpos(type, 'z') NE -1 then BEGIN
366; si + de 1 niveau est selectionne:
367      widget_control, widget_info(base, find_by_uname = 'depthlev1'), get_value = niv1
368      niv1 = niv1.droplist_select
369      widget_control, widget_info(base, find_by_uname = 'depthlev2'), get_value = niv2
370      niv2 = niv2.droplist_select
371      if niv1 NE niv2 then begin
372         box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[5], 1)
373      ENDIF ELSE BEGIN
374         if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $
375         ELSE pmax = 200
376         box = box+',0,'+strtrim(pmax, 1)
377      ENDELSE
378   endif
379   box = box+']'
380;---------------
381; on determine typein
382;---------------
383   typein = ''''+type+''''
384;---------------
385;---------------
386; determination de small
387;---------------
388   ssmall = tostr(smallout)
389;------------------------------------------------------------
390; on va definir le string qui contiendra la commande a executer par widgetdessine.pro
391;------------------------------------------------------------
392   Commande = [readCommande, procedure+', field $', ', boxzoom=' $
393               +box+', typein='+typein+', small='+ssmall+' $']
394   IF drawvecteur then Commande = [Commande, ', vecteur = {u: fieldu,v: fieldv} $']
395   IF drawover then Commande = [Commande, ', contour = fieldover $']
396   Commande = [Commande, ', _extra= mixstru(ex, extra), NOERASE=noerase']
397
398;    print, '---------------'
399;    for i = 0, n_elements(Commande)-1 do print, Commande[i]
400;    print, '---------------'
401;---------------
402; on complete et/ou actualise la structure top_uvalue...
403;---------------
404   (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure
405   (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type
406   (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boxzoom
407   (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand
408   (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags
409   *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra
410;------------------------------------------------------------
411   return, Commande
412end
413
414
Note: See TracBrowser for help on using the repository browser.