;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:buildreadcmd ; ; PURPOSE: ; ; CATEGORY: ; ; CALLING SEQUENCE: ; ; INPUTS: ; ; KEYWORD PARAMETERS: ; ; OUTPUTS: ; ; COMMON BLOCKS:common.pro ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) ; ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ 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) exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) 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 sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) ;--------------- ; find boxzoom ;--------------- if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom ; 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 @common min = min([gdept, gdepw], 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) ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ; on va definir le string qui contiendra la commande a executer pour ; la lecture ;------------------------------------------------------------ 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+', date1, date2, '+snameexp $ +', parent = '+strtrim(base, 1)+', boxzoom = '+box+' $' $ , ' , 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