;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:buildreadcommand ; ; 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 buildreadcommand, base, snameexp, procedure, type, BOITE = boite, COMPLETE = complete, NAMEFIELD = namefield ;------------------------------------------------------------ ; 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') ; optionid = widget_info(base, find_by_uname = 'option') ;------------------------------------------------------------ widget_control,base, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'petitin'))[2]-1 numdessinout = (extractatt(top_uvalue, 'petitout'))[2]-1 ;--------------- ; determination du nom du fichier ;--------------- currentfile = extractatt(top_uvalue, 'currentfile') filelist = extractatt(top_uvalue, 'filelist') filename = filelist[currentfile] sfilename = ''''+filename+'''' ;--------------- ; on recupere le nom de la variable ;--------------- if NOT keyword_set(namefield) then begin listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar nomvariable = listvar[widget_info(champid, /droplist_select)] ENDIF ELSE nomvariable = namefield snomvariable = ''''+nomvariable+'''' ; ; recherche des 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) ;--------------- ; determination de date1 et date2 ;--------------- widget_control, date1id, get_value = date1 ; widget_control, date2id, get_value = date2 date1 = long(date1) & date2 = long(date2) ; if procedure EQ 'pltt' AND date1 EQ date2 then begin currentfile = extractatt(top_uvalue, 'currentfile') calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter caldat, calendar,monthcal,daycal,yearcal if total(daycal eq 15) EQ n_elements(calendar) then monthly = 1 if total(monthcal EQ 6) EQ n_elements(calendar) then BEGIN monthly = 1 yearly = 1 endif date1 = vairdate(calendar[0], mensuel = monthly, annuel = yearly) date2 = vairdate(calendar[n_elements(calendar)-1], mensuel = monthly, annuel = yearly) widget_control, date1id, set_value = date1 widget_control, date2id, set_value = date2 endif ; sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) ;--------------- ; 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) 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+']' ;--------------- ; determination de 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 ;------------------------------------------------------------ Commande = ['; declaration de la structure extra:', 'extra='+sextra $ , '; declaration de la structure readparameters:', 'readparameters='+sreadparameters $ , '; on change de lecture?:', 'nothing=changeread(readparameters)' $ , '; declaration de la structure meshparameters:', 'meshparameters='+smeshparameters $ , '; on change de grille?:', 'nothing=changegrid(meshparameters)' $ , '; lecture du champ' $ , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ +',parent='+strtrim(base, 1)+',boite='+box+' $',', filename='+sfilename+' $' $ , ', _extra=mixstru(ex, extra)))'] (*top_uvalue[1, findline(top_uvalue, 'champs')])[*, numdessinout] = [filename, nomvariable] (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] ENDIF ELSE BEGIN Commande = ['; lecture du champ' $ , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ +',parent='+strtrim(base, 1)+',boite='+box+' $',', filename='+sfilename+' $' $ , ', _extra=mixstru(ex, extra)))'] ENDELSE ; print, '::::::::::::::::::::::' ; for i = 0, n_elements(Commande)-1 do print, Commande[i] ; print, '::::::::::::::::::::::' ;------------------------------------------------------------ ;------------------------------------------------------------ return, commande end