[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; NAME:buildreadcommand |
---|
| 6 | ; |
---|
| 7 | ; PURPOSE: |
---|
| 8 | ; |
---|
| 9 | ; CATEGORY: |
---|
| 10 | ; |
---|
| 11 | ; CALLING SEQUENCE: |
---|
| 12 | ; |
---|
| 13 | ; INPUTS: |
---|
| 14 | ; |
---|
| 15 | ; KEYWORD PARAMETERS: |
---|
| 16 | ; |
---|
| 17 | ; OUTPUTS: |
---|
| 18 | ; |
---|
| 19 | ; COMMON BLOCKS:common.pro |
---|
| 20 | ; |
---|
| 21 | ; SIDE EFFECTS: |
---|
| 22 | ; |
---|
| 23 | ; RESTRICTIONS: |
---|
| 24 | ; |
---|
| 25 | ; EXAMPLE: |
---|
| 26 | ; |
---|
| 27 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
| 28 | ; |
---|
| 29 | ;- |
---|
| 30 | ;------------------------------------------------------------ |
---|
| 31 | ;------------------------------------------------------------ |
---|
| 32 | ;------------------------------------------------------------ |
---|
[49] | 33 | FUNCTION buildreadcommand, base, snameexp, procedure, type, BOXZOOM = boxzoom, COMPLETE = complete, NAMEFIELD = namefield |
---|
[2] | 34 | ;------------------------------------------------------------ |
---|
| 35 | ; on recuper les ID des differents widgets |
---|
| 36 | ;------------------------------------------------------------ |
---|
| 37 | filelistid = widget_info(base, find_by_uname = 'filelist') |
---|
| 38 | champid = widget_info(base, find_by_uname = 'champ') |
---|
| 39 | nomexpid = widget_info(base, find_by_uname = 'nom_exp') |
---|
| 40 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
| 41 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
| 42 | domainid = widget_info(base, find_by_uname = 'domain') |
---|
| 43 | ; optionid = widget_info(base, find_by_uname = 'option') |
---|
| 44 | ;------------------------------------------------------------ |
---|
| 45 | widget_control,base, get_uvalue = top_uvalue |
---|
[49] | 46 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
| 47 | numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 |
---|
[2] | 48 | ;--------------- |
---|
| 49 | ; determination du nom du fichier |
---|
| 50 | ;--------------- |
---|
| 51 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
| 52 | filelist = extractatt(top_uvalue, 'filelist') |
---|
| 53 | filename = filelist[currentfile] |
---|
| 54 | sfilename = ''''+filename+'''' |
---|
| 55 | ;--------------- |
---|
| 56 | ; on recupere le nom de la variable |
---|
| 57 | ;--------------- |
---|
| 58 | if NOT keyword_set(namefield) then begin |
---|
| 59 | listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar |
---|
| 60 | nomvariable = listvar[widget_info(champid, /droplist_select)] |
---|
| 61 | ENDIF ELSE nomvariable = namefield |
---|
| 62 | snomvariable = ''''+nomvariable+'''' |
---|
| 63 | ; |
---|
| 64 | ; recherche des options |
---|
| 65 | ; |
---|
| 66 | options = extractatt(top_uvalue, 'options') |
---|
| 67 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
| 68 | flags = flags[*, numdessinin] |
---|
| 69 | xindex = (flags[where(options EQ 'Longitude / x index')])[0] |
---|
| 70 | yindex = (flags[where(options EQ 'Latitude / y index')])[0] |
---|
| 71 | ; |
---|
| 72 | extra = extractatt(top_uvalue, 'extra') |
---|
| 73 | if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) |
---|
| 74 | if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) |
---|
| 75 | exextra = cw_specifie_get_value(base) |
---|
| 76 | exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) |
---|
| 77 | if size(exextra, /type) EQ 8 then extra = mixstru(exextra,extra) |
---|
| 78 | sextra = struct2string(extra) |
---|
| 79 | |
---|
| 80 | ;--------------- |
---|
| 81 | ; determination de date1 et date2 |
---|
| 82 | ;--------------- |
---|
| 83 | widget_control, date1id, get_value = date1 |
---|
| 84 | ; |
---|
| 85 | widget_control, date2id, get_value = date2 |
---|
| 86 | date1 = long(date1) & date2 = long(date2) |
---|
| 87 | ; |
---|
| 88 | if procedure EQ 'pltt' AND date1 EQ date2 then begin |
---|
| 89 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
| 90 | calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter |
---|
| 91 | caldat, calendar,monthcal,daycal,yearcal |
---|
| 92 | if total(daycal eq 15) EQ n_elements(calendar) then monthly = 1 |
---|
| 93 | if total(monthcal EQ 6) EQ n_elements(calendar) then BEGIN |
---|
| 94 | monthly = 1 |
---|
| 95 | yearly = 1 |
---|
| 96 | endif |
---|
| 97 | date1 = vairdate(calendar[0], mensuel = monthly, annuel = yearly) |
---|
| 98 | date2 = vairdate(calendar[n_elements(calendar)-1], mensuel = monthly, annuel = yearly) |
---|
| 99 | widget_control, date1id, set_value = date1 |
---|
| 100 | widget_control, date2id, set_value = date2 |
---|
| 101 | endif |
---|
| 102 | ; |
---|
| 103 | sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) |
---|
| 104 | ;--------------- |
---|
[49] | 105 | ; determination du nom de la boxzoom |
---|
[2] | 106 | ;--------------- |
---|
[49] | 107 | if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom |
---|
[2] | 108 | ; ecriture de celle-ci sous forme d''un string |
---|
[49] | 109 | box = '['+strtrim(boxzoom[0], 1) |
---|
| 110 | for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ |
---|
| 111 | box = box+', '+strtrim(boxzoom[i], 1) |
---|
[2] | 112 | if strpos(type, 'z') NE -1 then BEGIN |
---|
| 113 | @common |
---|
| 114 | min = min([gdept, gdepw], max = max) |
---|
| 115 | box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) |
---|
| 116 | endif |
---|
| 117 | box = box+']' |
---|
| 118 | ;--------------- |
---|
| 119 | ; determination de funclec_name, readparameters, meshparameters |
---|
| 120 | ;--------------- |
---|
| 121 | readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] |
---|
| 122 | funclec_name = readparameters.funclec_name |
---|
| 123 | if keyword_set(complete) then begin |
---|
| 124 | sreadparameters = struct2string(readparameters) |
---|
| 125 | meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] |
---|
| 126 | smeshparameters = struct2string(meshparameters) |
---|
| 127 | ;------------------------------------------------------------ |
---|
| 128 | ;------------------------------------------------------------ |
---|
| 129 | ;------------------------------------------------------------ |
---|
| 130 | ; on va definir le string qui contiendra la commande a executer pour |
---|
| 131 | ; la lecture |
---|
| 132 | ;------------------------------------------------------------ |
---|
| 133 | Commande = ['; declaration de la structure extra:', 'extra='+sextra $ |
---|
| 134 | , '; declaration de la structure readparameters:', 'readparameters='+sreadparameters $ |
---|
| 135 | , '; on change de lecture?:', 'nothing=changeread(readparameters)' $ |
---|
| 136 | , '; declaration de la structure meshparameters:', 'meshparameters='+smeshparameters $ |
---|
| 137 | , '; on change de grille?:', 'nothing=changegrid(meshparameters)' $ |
---|
| 138 | , '; lecture du champ' $ |
---|
| 139 | , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ |
---|
| 140 | , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ |
---|
| 141 | , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ |
---|
[49] | 142 | +',parent='+strtrim(base, 1)+',boxzoom='+box+' $',', filename='+sfilename+' $' $ |
---|
[2] | 143 | , ', _extra=mixstru(ex, extra)))'] |
---|
| 144 | (*top_uvalue[1, findline(top_uvalue, 'champs')])[*, numdessinout] = [filename, nomvariable] |
---|
| 145 | (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] |
---|
| 146 | ENDIF ELSE BEGIN |
---|
| 147 | Commande = ['; lecture du champ' $ |
---|
| 148 | , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ |
---|
| 149 | , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ |
---|
| 150 | , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ |
---|
[49] | 151 | +',parent='+strtrim(base, 1)+',boxzoom='+box+' $',', filename='+sfilename+' $' $ |
---|
[2] | 152 | , ', _extra=mixstru(ex, extra)))'] |
---|
| 153 | ENDELSE |
---|
| 154 | ; print, '::::::::::::::::::::::' |
---|
| 155 | ; for i = 0, n_elements(Commande)-1 do print, Commande[i] |
---|
| 156 | ; print, '::::::::::::::::::::::' |
---|
| 157 | ;------------------------------------------------------------ |
---|
| 158 | |
---|
| 159 | ;------------------------------------------------------------ |
---|
| 160 | return, commande |
---|
| 161 | end |
---|