;+ ; ; @file_comments ; This function send back a string which contain the reading command ; and drawing's parameters. ; ; @param BASE {in}{required} ; ; @keyword BOXZOOM ; Vector indicating the geographic zone on which we want to cut the map. ; If BOXZOOM has : ; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] ; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] ; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])] ; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]] ; 6 elements: The extraction is made on Boxzoom ; Where lon1, lon2,lat1,lat2 are global variables defined at the last ; domdef ! ; ; @keyword FORCETYPE ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; ; @version ; $Id$ ; ; @todo ; seb: documenter le param BASE et le keyword FORCETYPE ; ;- FUNCTION buildcmd, base, BOXZOOM=boxzoom, FORCETYPE=forcetype ; ;------------------------------------------------------------ ; we get back the ids of the widget parts ;------------------------------------------------------------ ; compile_opt idl2, strictarrsubs ; 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] ;------------------------------------------------------------ ;--------------- ; We determinate which procedure we will call to do the drawing and the type ;--------------- IF keyword_set(forcetype) THEN type = forcetype $ ELSE type = widget_info(actionid, /combobox_gettext) case type of 'pltz diag up':procedure = 'pltz' 'pltz diag dn':procedure = 'pltz' 'pltt diag up':procedure = 'pltt' 'pltt diag dn':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' ELSE:procedure = type endcase ; ; Search of 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') ; What must we read ? 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 widcmd = strtrim(widcmd, 2) 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) tgnm = strlowcase(tag_names(exextra)) indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt) IF cnt EQ 1 THEN BEGIN boxextra = exextra.(indtmp[0]) exextra = extractstru(exextra, ['box', 'boxzoom']) ENDIF 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 integer and v when alreadyvector is a integer+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 of the boxzoom's name. if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom CASE n_elements(boxextra) OF 0: 1:boxzoom[5] = boxextra 2:boxzoom[4:5] = boxextra 4:boxzoom[0:3] = boxextra 5:boxzoom = [boxextra[0:3], 0, boxextra[4]] 6:boxzoom = boxextra ENDCASE ; Writing of this one as a 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) ; For [plots in z, box must have by default 0,profmax if strpos(type, 'z') NE -1 then BEGIN ; If more than 1 level is selected: 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(boxzoom[5] > pmax, 1) ENDELSE endif box = box+']' IF strpos(type, ' diag up') NE -1 THEN BEGIN sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $ ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']' ENDIF IF strpos(type, ' diag dn') NE -1 THEN BEGIN sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $ ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']' ENDIF ;--------------- ; We determinate typein ;--------------- IF strpos(type, ' diag ') NE -1 THEN typein = ''''+strmid(type, 0, 4)+'''' $ ELSE typein = ''''+type+'''' ;--------------- ;--------------- ; determination of small ;--------------- ssmall = tostr(smallout) ;------------------------------------------------------------ ; We will define the string which will contain the command to be executed by widgetdessine.pro ;------------------------------------------------------------ Cmd = [readCmd, procedure+ ', field $' $ , ' , boxzoom = '+box+', /findalways, 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, '---------------' ;--------------- ; We complete and/or update the 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