;+ ; ; @param BASE {in}{required} ; The id of the widget where apply the drawing. ; ; @param SNAMEEXP {in}{required} ; ; @param PROCEDURE {in}{required} ; ; @param TYPE {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 COMPLETE ; ; @keyword NAMEFIELD ; ; @uses ; common.pro ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; ; @version ; $Id$ ; ; @todo ; seb: documenter les param et les keyword qui ne le sont pas. ; ;- ; FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $ , COMPLETE = complete, NAMEFIELD = namefield ; ; compile_opt idl2, strictarrsubs ; @cm_4cal ; for key_caltype ;------------------------------------------------------------ ; get back widgets IDs ;------------------------------------------------------------ vlstid = widget_info(base, find_by_uname = 'varlist') date1id = widget_info(base, find_by_uname = 'calendar1') date2id = widget_info(base, find_by_uname = 'calendar2') domainid = widget_info(base, find_by_uname = 'domain') ; optionid = widget_info(base, find_by_uname = 'option') ;------------------------------------------------------------ widget_control, base, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 ;--------------- ; name of the file ;--------------- currentfile = extractatt(top_uvalue, 'currentfile') filelist = extractatt(top_uvalue, 'filelist') filename = filelist[currentfile] sfilename = ''''+filename+'''' ;--------------- ; name of the variable ;--------------- if keyword_set(namefield) then namevar = namefield $ ELSE namevar = widget_info(vlstid, /combobox_gettext) snamevar = ''''+namevar+'''' ; ; get the options ; options = extractatt(top_uvalue, 'options') flags = extractatt(top_uvalue, 'optionsflag') flags = flags[*, numdessinin] xindex = (flags[where(options EQ 'Longitude / x index')])[0] yindex = (flags[where(options EQ 'Latitude / y index')])[0] ; 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 boxextra = exextra.(indtmp[0]) exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct', 'box', 'boxzoom']) if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra) sextra = struct2string(extra) ;--------------- ; find date1 and date2 ;--------------- key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype widget_control, date1id, get_value = date1 widget_control, date2id, get_value = date2 if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN ; we redefine the dates to the begining and end of the calendar calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter date1 = jul2date(calendar[0]) date2 = jul2date(calendar[n_elements(calendar)-1]) widget_control, date1id, set_value = date1 widget_control, date2id, set_value = date2 endif ; fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal IF keyword_set(fakecal) THEN BEGIN date1 = date2jul(date1) - fakecal date2 = date2jul(date2) - fakecal ENDIF IF size(date1, /type) EQ 5 THEN sdate1 = string(date1, format='(f15.6)')+'d' $ ELSE sdate1 = string(date1, format='(i10)')+'L' IF size(date2, /type) EQ 5 THEN sdate2 = string(date2, format='(f15.6)')+'d' $ ELSE sdate2 = string(date2, format='(i10)')+'L' ;--------------- ; find boxzoom ;--------------- 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 ; put boxzoom into 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) if strpos(type, 'z') NE -1 then BEGIN @cm_4mesh min = min([gdept, gdepw, boxzoom[4:5]], max = max) box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) 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 ;--------------- ; find funclec_name, readparameters, meshparameters ;--------------- readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] funclec_name = readparameters.funclec_name if keyword_set(complete) then begin sreadparameters = struct2string(readparameters) meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] smeshparameters = struct2string(meshparameters) ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ; We will define the string which will contain the command to be executed for the reading. ;------------------------------------------------------------ Cmd = ['; Definition of extra structure:', 'extra = '+sextra $ , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $ , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $ , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $ , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $ , '; Read the data...' $ , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $ , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $ , funclec_name+'('+snamevar+', date1, date2, '+snameexp $ + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2)+' $' $ , ' , boxzoom = '+box+', /findalways $' $ , ' , filename = '+sfilename+' $'] if n_elements(sendpoints) NE 0 then $ Cmd = [Cmd, ' , endpoints = ' + sendpoints + ', type = ''' + type + ''' $'] Cmd = [Cmd, ' , _extra = mixstru(ex, extra), /nostruct)'] (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar] (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] ENDIF ELSE BEGIN Cmd = [funclec_name+'('+snamevar+', '+sdate1+', '+sdate2+', '+snameexp $ + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 1)+' $' $ , ' , boxzoom = '+box+', /findalways $' $ , ' , filename = '+sfilename+' $'] if n_elements(sendpoints) NE 0 then $ Cmd = [Cmd, ' , endpoints = ' + sendpoints + ', type = ''' + type + ''' $'] Cmd = [Cmd, ' , _extra = mixstru(ex, extra), /nostruct)'] ENDELSE ; print, '::::::::::::::::::::::' ; for i = 0, n_elements(Cmd)-1 do print, Cmd[i] ; print, '::::::::::::::::::::::' ;------------------------------------------------------------ ;------------------------------------------------------------ return, cmd end