;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:buildcmd ; ; 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 buildcmd, base, BOXZOOM = boxzoom, FORCETYPE = forcetype ; ;------------------------------------------------------------ ; we get back the ids of the widget parts ;------------------------------------------------------------ txtcmdid = widget_info(base, find_by_uname = 'txtcmd') domainid = widget_info(base, find_by_uname = 'domain') actionid = widget_info(base, find_by_uname = 'action') ; optionid = widget_info(base, find_by_uname = 'option') ;------------------------------------------------------------ widget_control, base, get_uvalue = top_uvalue smallin = extractatt(top_uvalue, 'smallin') numdessinin = smallin[2]-1 smallout = extractatt(top_uvalue, 'smallout') numdessinout = smallout[2]-1 ; options = extractatt(top_uvalue, 'options') optionsflag = extractatt(top_uvalue, 'optionsflag') portrait = (strtrim(optionsflag[where(options EQ 'Portrait/Landscape'), 0], 1))[0] ;------------------------------------------------------------ ;--------------- ; on determine quelle procedure on va etre appele pour faire le dessin ; et le type ;--------------- IF keyword_set(forcetype) THEN type = forcetype $ ELSE type = widget_info(actionid, /combobox_gettext) case type of 'plt':procedure = 'plt' 'pltz':procedure = 'pltz' 'pltz_diag':procedure = 'pltz' 'pltt':procedure = 'pltt' 'pltt_diag':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 ; ; 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 readswitch = 'over' END alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN toread = alreadyvector+1 readswitch = 'vector' END alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN toread = alreadyread+1 readswitch = 'classic' END else:BEGIN case 1 of alreadyvector eq !pi:BEGIN toread = alreadyover+1 readswitch = 'over' END alreadyread EQ !pi:BEGIN toread = alreadyvector+1 readswitch = 'vector' END alreadyread EQ 2.*!pi:BEGIN toread = alreadyover+1 readswitch = 'over' END ELSE:BEGIN toread = alreadyread+1 readswitch = 'classic' END endcase END ENDCASE ; widget_control, txtcmdid, get_value = widcmd IF widcmd[0] EQ '' THEN widcmd = 'zzz' cutcmd, widcmd[0], toread, numberofread, prefix, nameexp, ending ; readcmd = buildreadcmd(base, ''''+nameexp+'''', procedure, type $ , BOXZOOM = boxzoom, complete = readswitch EQ 'classic' AND alreadyread EQ -1) ; we look for the line containing funclec_name currentfile = extractatt(top_uvalue, 'currentfile') readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] i = 0 while strpos(readcmd[i], readparameters.funclec_name + '(') EQ -1 do i = i+1 ;----------------------- ;----------------------- ;----------------------- ;----------------------- ;----------------------- case readswitch of 'classic':BEGIN if alreadyread+1 EQ 0 then BEGIN ; we start the reading command readcmd = ['; beginning of reading the field to draw', readcmd] readcmd[i+1] = 'field = ' + prefix + readcmd[i+1] ENDIF ELSE BEGIN ; we complet the reading command oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') nl = n_elements(oldrdcmd) oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' readcmd[i] = prefix + readcmd[i] readcmd = [temporary(oldrdcmd), temporary(readcmd)] ENDELSE ; exit if we have to read other fields... if alreadyread+1 NE numberofread-1 THEN BEGIN *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd *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 ; we finalize the reading command IF ending NE '' THEN BEGIN nl = n_elements(readcmd) readcmd[nl-1] = readcmd[nl-1] + ' $' readcmd = [temporary(readcmd), ending] ENDIF readcmd = [temporary(readcmd) $ , 'field = create_struct({arr:temporary(field), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ , '; end of reading the field to draw', ';'] ; we get back _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) readcmd = [temporary(readcmd), 'extra = '+sextra] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd case 1 of drawvecteur:BEGIN ; we have to read the vectors *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector') return, '' END drawover:BEGIN ; we have to read the field to overlay... *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') return, '' END ; finished, we draw the plot... ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 endcase END 'vector':BEGIN ; for the vectors, there is 2 components. we read u when alreadyvector ; is a interger and v when alreadyvector is a interger+0.5 if floor(alreadyvector)+1 EQ 0 then begin if floor(alreadyvector) EQ alreadyvector then begin readcmd = ['; beginning of reading the zonal component of vector', readcmd] readcmd[i+1] = 'fieldu = ' + prefix + readcmd[i+1] ENDIF ELSE BEGIN readcmd = ['; beginning of reading the meridional component of vector', readcmd] readcmd[i+1] = 'fieldv = ' + prefix + readcmd[i+1] ENDELSE readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)] ENDIF ELSE BEGIN oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') nl = n_elements(oldrdcmd) oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' readcmd[i] = prefix + readcmd[i] readcmd = [temporary(oldrdcmd), temporary(readcmd)] ENDELSE ; case alreadyvector+1 of numberofread-1:BEGIN ; we finalize the reading command IF ending NE '' THEN BEGIN nl = n_elements(readcmd) readcmd[nl-1] = readcmd[nl-1] + ' $' readcmd = [temporary(readcmd), ending] ENDIF readcmd = [temporary(readcmd) $ , 'fieldu = create_struct({arr:temporary(fieldu), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ , '; end of reading the zonal component of vector', ';'] *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd ; we finished zonal component reading... ; we know switch to meridional component... *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 ; we finalize the reading command IF ending NE '' THEN BEGIN nl = n_elements(readcmd) readcmd[nl-1] = readcmd[nl-1] + ' $' readcmd = [temporary(readcmd), ending] ENDIF readcmd = [temporary(readcmd) $ , 'fieldv = create_struct({arr:temporary(fieldv), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ , '; end of reading the meridional component of vector', ';'] ; we finished meridional component reading... ; ; we get back _EXTRA of the vector and we complet extra already build extra = extractatt(top_uvalue, 'extra') exextra = cw_specifie_get_value(base) extra = mixstru(exextra, extra) sextra = struct2string(extra) readcmd = [readcmd, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)'] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd ; if drawover then BEGIN ; shall we do an overlay??? *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 ; it is done know! *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 ENDELSE END ELSE:BEGIN ; we still need to read some vector components... *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd *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 ; we start the reading... readcmd = ['; beginning of reading the field to overdraw', readcmd] readcmd[i+1] = 'fieldover = '+ prefix +readcmd[i+1] readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)] ENDIF ELSE BEGIN oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') nl = n_elements(oldrdcmd) oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' readcmd[i] = prefix + readcmd[i] readcmd = [temporary(oldrdcmd), temporary(readcmd)] ENDELSE ; if alreadyover+1 NE numberofread-1 THEN BEGIN ; we still need to read some files... *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd *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 ; we finalize the reading command IF ending NE '' THEN BEGIN nl = n_elements(readcmd) readcmd[nl-1] = readcmd[nl-1] + ' $' readcmd = [temporary(readcmd), ending] ENDIF ; on finalise la commande de lecture readcmd = [readcmd $ , 'fieldover = create_struct({arr:temporary(fieldover), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ , '; end of reading the field to overdraw', ';'] ; we get back _EXTRA of over and we complet extra already build extra = extractatt(top_uvalue, 'extra') exextra = cw_specifie_get_value(base) extra = mixstru(exextra, extra) sextra = struct2string(extra) readcmd = [readcmd, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)'] ; *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd ; we reinitialize *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 boxzoom ;--------------- if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom ; ecriture de celle-ci sous forme d''un string box = '['+strtrim(boxzoom[0], 1) for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ box = box+', '+strtrim(boxzoom[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 = 'dthlv1'), get_value = niv1 niv1 = niv1.combobox_index widget_control, widget_info(base, find_by_uname = 'dthlv2'), get_value = niv2 niv2 = niv2.combobox_index if niv1 NE niv2 then begin box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[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+']' IF strpos(type, '_diag') NE -1 THEN BEGIN sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $ ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']' ENDIF ;--------------- ; on determine typein ;--------------- IF strpos(type, '_diag') NE -1 THEN typein = ''''+strmid(type, 0, 4)+'''' $ ELSE typein = ''''+type+'''' ;--------------- ;--------------- ; determination de small ;--------------- ssmall = tostr(smallout) ;------------------------------------------------------------ ; on va definir le string qui contiendra la commande a executer par widgetdessine.pro ;------------------------------------------------------------ Cmd = [readCmd, procedure+ ', field $' $ , ' , boxzoom = '+box+', typein='+typein+', small='+ssmall+' $'] IF drawvecteur then Cmd = [Cmd, ' , vecteur = {u: fieldu,v: fieldv} $'] IF drawover then Cmd = [Cmd, ' , contour = fieldover $'] IF n_elements(sendpoints) NE 0 then Cmd = [Cmd, ' , endpoints = ' + sendpoints + ' $'] Cmd = [Cmd, ' , _extra= mixstru(ex, extra), portrait = ' + portrait + ', NOERASE=noerase'] ; print, '---------------' ; for i = 0, n_elements(Cmd)-1 do print, Cmd[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] = boxzoom (*top_uvalue[1, findline(top_uvalue, 'txtcmd')])[numdessinout] = widcmd (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra ;------------------------------------------------------------ return, Cmd end