;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:buildcommand ; ; PURPOSE:cette fonction reourne un string qui contient la commande de ; lecture et les parametres du trace. ; ; CATEGORY: ; ; CALLING SEQUENCE: ; ; INPUTS: ; ; KEYWORD PARAMETERS: ; ; OUTPUTS: ; ; COMMON BLOCKS: ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) ; ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ FUNCTION buildcommand, base, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, BOITE = boite ;------------------------------------------------------------ ; on recuper les ID des differents widgets ;------------------------------------------------------------ filelistid = widget_info(base, find_by_uname = 'filelist') champid = widget_info(base, find_by_uname = 'champ') nomexpid = widget_info(base, find_by_uname = 'nom_exp') date1id = widget_info(base, find_by_uname = 'calendar1') date2id = widget_info(base, find_by_uname = 'calendar2') domainid = widget_info(base, find_by_uname = 'domain') graphtypeid = widget_info(base, find_by_uname = 'action') ; optionid = widget_info(base, find_by_uname = 'option') ;------------------------------------------------------------ widget_control,base, get_uvalue = top_uvalue petitin = extractatt(top_uvalue, 'petitin') numdessinin = petitin[2]-1 petitout = extractatt(top_uvalue, 'petitout') numdessinout = petitout[2]-1 ;------------------------------------------------------------ ;--------------- ; on determine quelle procedure on va etre appele pour faire le dessin ; et le type ;--------------- widget_control,graphtypeid, get_uvalue = graphtype_uvalue type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)] ; type = top_uvalue.nameprocedures[numdessinin] case type of 'plt':procedure = 'plt' 'pltz':procedure = 'pltz' 'pltt':procedure = 'pltt' 'xy':procedure = 'plt' 'xz':procedure = 'pltz' 'yz':procedure = 'pltz' 'xt':procedure = 'pltt' 'yt':procedure = 'pltt' 'zt':procedure = 'pltt' 'x':procedure = 'plt1d' 'y':procedure = 'plt1d' 'z':procedure = 'plt1d' 't':procedure = 'pltt' endcase if keyword_set(forplth) then BEGIN procedure = 'plt' type = 'plt' ENDIF if keyword_set(forpltz) then BEGIN procedure = 'pltz' type = 'pltz' ENDIF if keyword_set(forpltt) then BEGIN procedure = 'pltt' type = 'pltt' ENDIF ; ; recherche des options ; options = extractatt(top_uvalue, 'options') optionsflag = extractatt(top_uvalue, 'optionsflag') flags = optionsflag[*, numdessinin] xindex = (flags[where(options EQ 'Longitude / x index')])[0] yindex = (flags[where(options EQ 'Latitude / y index')])[0] drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt') drawover = (flags[where(options EQ 'Overlay')])[0] ; alreadyread = extractatt(top_uvalue, 'alreadyread') alreadyvector = extractatt(top_uvalue, 'alreadyvector') alreadyover = extractatt(top_uvalue, 'alreadyoer') ; que devons-nous lire ? case 1 of alreadyover NE -1:BEGIN toread = alreadyover+1 whichread = 'over' END alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN toread = alreadyvector+1 whichread = 'vector' END alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN toread = alreadyread+1 whichread = 'classic' END else:BEGIN case 1 of alreadyvector eq !pi:BEGIN toread = alreadyover+1 whichread = 'over' END alreadyread EQ !pi:BEGIN toread = alreadyvector+1 whichread = 'vector' END alreadyread EQ 2.*!pi:BEGIN toread = alreadyover+1 whichread = 'over' END ELSE:BEGIN toread = alreadyread+1 whichread = 'classic' END endcase END ENDCASE ; widget_control, nomexpid, get_value = widcommand widcommand = strcompress(widcommand[0], /remove_all) cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add ; readcommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = whichread EQ 'classic' AND alreadyread EQ -1) ; on choppe la ligne ou il y a litchamp pour appliquer coef et operateur i = 0 while strpos(readcommande[i], 'litchamp') EQ -1 do i = i+1 ;----------------------- ;----------------------- ;----------------------- ;----------------------- ;----------------------- case whichread of 'classic':BEGIN if alreadyread+1 EQ 0 then BEGIN ; on commence a ecrire la commande de lecture... readcommande = ['; beginning of reading the field to draw' $ , '; field number: '+strtrim(alreadyread+2, 1), readcommande] readcommande[i+2] = 'field = '+coef+operation+readcommande[i+2] *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ENDIF ELSE BEGIN readcommande = ['; field number: '+strtrim(alreadyread+2, 1), readcommande] readcommande[i+1] = 'field = field'+separator+coef+operation+readcommande[i+1] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ENDELSE if alreadyread+1 NE numberofread-1 THEN BEGIN ; si il faut lire d''autres champs on sort *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1 *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1)) return, '' ENDIF ; on finalise la commande de lecture readcommande = [readcommande, 'field = field'+add $ , 'field = create_struct({tab:field, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ , '; end of reading the field to draw', ';'] ; on recupere le _EXTRA: extra = extractatt(top_uvalue, 'extra') if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) exextra = cw_specifie_get_value(base) extra = mixstru(exextra,extra) sextra = struct2string(extra) readcommande = [readcommande, 'extra = '+sextra] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande case 1 of drawvecteur:BEGIN ; quelle function de lecture utilisons nous? trace des vecteurs de ; facon automatique ou non? currentfile = extractatt(top_uvalue, 'currentfile') funclec_name = *(extractatt(top_uvalue, 'readparameters'))[currentfile] funclec_name = funclec_name.funclec_name if funclec_name EQ 'read_ncdf' then begin ; il faut lire des vecteurs maintenant? *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector') return, '' ENDIF ELSE BEGIN ; on fait un trace automatique en appelant un et vn ... readuncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = 0, namefield = 'un') i = 0 while strpos(readuncommande[i], 'litchamp') EQ -1 do i = i+1 readuncommande = ['; reading the zonal component of vector', readuncommande] readuncommande[i+1] = 'fieldu = '+readuncommande[i+1] readuncommande = [readuncommande,'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})'] ; readvncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = 0, namefield = 'vn') i = 0 while strpos(readvncommande[i], 'litchamp') EQ -1 do i = i+1 readvncommande = ['; reading the zonal component of vector', readvncommande] readvncommande[i+1] = 'fieldv = '+readvncommande[i+1] readvncommande = [readvncommande,'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})'] ; readcommande = [readcommande,';', readuncommande, ';', readvncommande] *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; on enchaine sur un over plot??? if drawover then begin *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') return, '' ENDIF ELSE *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 ENDELSE END drawover:BEGIN ; il faut lire un autre champ a surcontourer? *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') return, '' END ; c'est tout pour la lecture, on va tracer! ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 endcase END 'vector':BEGIN ; pour lesvecteurs, il y a 2 composantes! en u et en v donc il faut ; doubler la lecture. pour alreadyvector entier, on lit u pour ; alreadyvector entier+0.5, on lit v! if floor(alreadyvector)+1 EQ 0 then begin if floor(alreadyvector) EQ alreadyvector then begin readcommande = ['; beginning of reading the zonal component of vector' $ , '; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande] readcommande[i+2] = 'fieldu = '+coef+operation+readcommande[i+2] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDIF ELSE BEGIN readcommande = ['; beginning of reading the meridional component of vector' $ , '; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande] readcommande[i+2] = 'fieldv = '+coef+operation+readcommande[i+2] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDELSE ENDIF ELSE BEGIN if floor(alreadyvector) EQ alreadyvector then begin readcommande = ['; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande] readcommande[i+1] = 'fieldu = fieldu'+separator+coef+operation+readcommande[i+1] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDIF ELSE BEGIN readcommande = ['; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande] readcommande[i+1] = 'fieldv = fieldv'+separator+coef+operation+readcommande[i+1] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDELSE ENDELSE *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; case alreadyvector+1 of numberofread-1:BEGIN ; on finalise la commande de lecture readcommande = [readcommande, 'fieldu = fieldu'+add $ , 'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ , '; end of reading the zonal component of vector', ';'] *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; on vient de finir le lecture des U *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5 *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector') return, '' END numberofread-0.5:BEGIN ; on finalise la commande de lecture readcommande = [readcommande, 'fieldv = fieldv'+add $ , 'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ , '; end of reading the meridional component of vector', ';'] ; on vient de finir le lecture des V ; ; on recupere le _EXTRA de vector et on complete eventuellement le extra ; deja constitue: extra = extractatt(top_uvalue, 'extra') exextra = cw_specifie_get_value(base) extra = mixstru(exextra,extra) sextra = struct2string(extra) readcommande = [readcommande, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)'] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; if drawover then BEGIN ; on enchaine sur un surcontour *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') return, '' ENDIF ELSE BEGIN *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 ENDELSE END ELSE:BEGIN *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1 if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $ ELSE text = ' meridional ' *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector') return, '' END endcase END 'over':BEGIN if alreadyover+1 EQ 0 then begin ; on commence a ecrire la commande de lecture... readcommande = ['; beginning of reading the field to overdraw' $ , '; fieldover number: '+strtrim(alreadyread+2, 1), readcommande] readcommande[i+2] = 'fieldover = '+coef+operation+readcommande[i+2] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDIF ELSE BEGIN readcommande = ['; fieldover number: '+strtrim(alreadyover+2, 1), readcommande] readcommande[i+1] = 'fieldover = fieldover'+separator+coef+operation+readcommande[i+1] readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] ENDELSE *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; if alreadyover+1 NE numberofread-1 THEN BEGIN ; si il faut lire d''autres champs on sort *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1 *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay') return, '' ENDIF ; on finalise la commande de lecture readcommande = [readcommande, 'fieldover = fieldover'+add $ , 'fieldover = create_struct({tab:fieldover, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ , '; end of reading the field to overdraw', ';'] ; on recupere le _EXTRA de over et on complete eventuellement le extra ; deja constitue: extra = extractatt(top_uvalue, 'extra') exextra = cw_specifie_get_value(base) extra = mixstru(exextra,extra) sextra = struct2string(extra) readcommande = [readcommande, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)'] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande ; on remet les compteurs a 0 *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1 END endcase ; ;----------------------- ;----------------------- ;----------------------- ;----------------------- ;----------------------- ;----------------------- ;--------------- ; determination du nom de la boite ;--------------- if NOT keyword_set(boite) then widget_control, domainid, get_value = boite ; ecriture de celle-ci sous forme d''un string box = '['+strtrim(boite[0], 1) for i = 1, (n_elements(boite)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ box = box+', '+strtrim(boite[i], 1) ; pour les [plots en z, box doit avoir par defaut 0,profmax if strpos(type, 'z') NE -1 then BEGIN ; si + de 1 niveau est selectionne: widget_control, widget_info(base, find_by_uname = 'depthlev1'), get_value = niv1 niv1 = niv1.droplist_select widget_control, widget_info(base, find_by_uname = 'depthlev2'), get_value = niv2 niv2 = niv2.droplist_select if niv1 NE niv2 then begin box = box+','+strtrim(boite[4], 1)+','+strtrim(boite[5], 1) ENDIF ELSE BEGIN if chkstru(exextra, 'profmax') then pmax = exextra.profmax $ ELSE pmax = 200 box = box+',0,'+strtrim(pmax, 1) ENDELSE endif box = box+']' ;--------------- ; on determine typein ;--------------- typein = ''''+type+'''' ;--------------- ;--------------- ; determination de petit ;--------------- spetit = tostr(petitout) ;------------------------------------------------------------ ; on va definir le string qui contiendra la commande a executer par widgetdessine.pro ;------------------------------------------------------------ Commande = [readCommande, procedure+', field $', ', boite=' $ +box+', typein='+typein+', petit='+spetit+' $'] IF drawvecteur then Commande = [Commande, ', vecteur = {u: fieldu,v: fieldv} $'] IF drawover then Commande = [Commande, ', contour = fieldover $'] Commande = [Commande, ', _extra= mixstru(ex, extra), NOERASE=noerase'] ; print, '---------------' ; for i = 0, n_elements(Commande)-1 do print, Commande[i] ; print, '---------------' ;--------------- ; on complete et/ou actualise la structure top_uvalue... ;--------------- (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boite (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra ;------------------------------------------------------------ return, Commande end