[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
[69] | 5 | ; NAME:buildreadcmd |
---|
[2] | 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 | ;------------------------------------------------------------ |
---|
[69] | 33 | FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $ |
---|
| 34 | , COMPLETE = complete, NAMEFIELD = namefield |
---|
| 35 | ; |
---|
[114] | 36 | ; |
---|
| 37 | compile_opt idl2, strictarrsubs |
---|
| 38 | ; |
---|
[69] | 39 | @cm_4cal ; for key_caltype |
---|
[2] | 40 | ;------------------------------------------------------------ |
---|
[69] | 41 | ; get back widgets IDs |
---|
[2] | 42 | ;------------------------------------------------------------ |
---|
[69] | 43 | vlstid = widget_info(base, find_by_uname = 'varlist') |
---|
| 44 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
| 45 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
| 46 | domainid = widget_info(base, find_by_uname = 'domain') |
---|
[2] | 47 | ; optionid = widget_info(base, find_by_uname = 'option') |
---|
| 48 | ;------------------------------------------------------------ |
---|
[69] | 49 | widget_control, base, get_uvalue = top_uvalue |
---|
| 50 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
| 51 | numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 |
---|
[2] | 52 | ;--------------- |
---|
[69] | 53 | ; name of the file |
---|
[2] | 54 | ;--------------- |
---|
[69] | 55 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
| 56 | filelist = extractatt(top_uvalue, 'filelist') |
---|
| 57 | filename = filelist[currentfile] |
---|
| 58 | sfilename = ''''+filename+'''' |
---|
[2] | 59 | ;--------------- |
---|
[69] | 60 | ; name of the variable |
---|
[2] | 61 | ;--------------- |
---|
[69] | 62 | if keyword_set(namefield) then namevar = namefield $ |
---|
| 63 | ELSE namevar = widget_info(vlstid, /combobox_gettext) |
---|
| 64 | snamevar = ''''+namevar+'''' |
---|
[2] | 65 | ; |
---|
[69] | 66 | ; get the options |
---|
[2] | 67 | ; |
---|
[69] | 68 | options = extractatt(top_uvalue, 'options') |
---|
| 69 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
| 70 | flags = flags[*, numdessinin] |
---|
| 71 | xindex = (flags[where(options EQ 'Longitude / x index')])[0] |
---|
| 72 | yindex = (flags[where(options EQ 'Latitude / y index')])[0] |
---|
[2] | 73 | ; |
---|
[69] | 74 | extra = extractatt(top_uvalue, 'extra') |
---|
| 75 | if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) |
---|
| 76 | if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) |
---|
| 77 | exextra = cw_specifie_get_value(base) |
---|
| 78 | exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) |
---|
| 79 | if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra) |
---|
| 80 | sextra = struct2string(extra) |
---|
[2] | 81 | ;--------------- |
---|
[69] | 82 | ; find date1 and date2 |
---|
[2] | 83 | ;--------------- |
---|
[69] | 84 | key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype |
---|
| 85 | widget_control, date1id, get_value = date1 |
---|
| 86 | widget_control, date2id, get_value = date2 |
---|
| 87 | |
---|
| 88 | if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN |
---|
| 89 | ; we redefine the dates to the begining and end of the calendar |
---|
| 90 | calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter |
---|
| 91 | date1 = jul2date(calendar[0]) |
---|
| 92 | date2 = jul2date(calendar[n_elements(calendar)-1]) |
---|
| 93 | widget_control, date1id, set_value = date1 |
---|
| 94 | widget_control, date2id, set_value = date2 |
---|
| 95 | endif |
---|
[2] | 96 | ; |
---|
[69] | 97 | fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal |
---|
| 98 | IF keyword_set(fakecal) THEN BEGIN |
---|
| 99 | date1 = date2jul(date1) - fakecal |
---|
| 100 | date2 = date2jul(date2) - fakecal |
---|
| 101 | ENDIF |
---|
| 102 | sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) |
---|
[2] | 103 | ;--------------- |
---|
[69] | 104 | ; find boxzoom |
---|
[2] | 105 | ;--------------- |
---|
[69] | 106 | if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom |
---|
| 107 | ; put boxzoom into a string |
---|
| 108 | box = '['+strtrim(boxzoom[0], 1) |
---|
| 109 | for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ |
---|
| 110 | box = box+', '+strtrim(boxzoom[i], 1) |
---|
| 111 | if strpos(type, 'z') NE -1 then BEGIN |
---|
[2] | 112 | @common |
---|
| 113 | min = min([gdept, gdepw], max = max) |
---|
| 114 | box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) |
---|
[69] | 115 | endif |
---|
| 116 | box = box+']' |
---|
[74] | 117 | IF strpos(type, ' diag up') NE -1 THEN BEGIN |
---|
[69] | 118 | sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $ |
---|
| 119 | ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']' |
---|
| 120 | ENDIF |
---|
[74] | 121 | IF strpos(type, ' diag dn') NE -1 THEN BEGIN |
---|
| 122 | sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $ |
---|
| 123 | ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']' |
---|
| 124 | ENDIF |
---|
[2] | 125 | ;--------------- |
---|
[69] | 126 | ; find funclec_name, readparameters, meshparameters |
---|
[2] | 127 | ;--------------- |
---|
[69] | 128 | readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] |
---|
| 129 | funclec_name = readparameters.funclec_name |
---|
| 130 | if keyword_set(complete) then begin |
---|
| 131 | sreadparameters = struct2string(readparameters) |
---|
| 132 | meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] |
---|
| 133 | smeshparameters = struct2string(meshparameters) |
---|
[2] | 134 | ;------------------------------------------------------------ |
---|
| 135 | ;------------------------------------------------------------ |
---|
| 136 | ;------------------------------------------------------------ |
---|
| 137 | ; on va definir le string qui contiendra la commande a executer pour |
---|
| 138 | ; la lecture |
---|
| 139 | ;------------------------------------------------------------ |
---|
[69] | 140 | Cmd = ['; Definition of extra structure:', 'extra = '+sextra $ |
---|
| 141 | , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $ |
---|
| 142 | , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $ |
---|
| 143 | , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $ |
---|
| 144 | , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $ |
---|
| 145 | , '; Read the data...' $ |
---|
[74] | 146 | , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $ |
---|
| 147 | , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $ |
---|
[69] | 148 | , funclec_name+'('+snamevar+', date1, date2, '+snameexp $ |
---|
| 149 | + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2) $ |
---|
[74] | 150 | + ', boxzoom = '+box+', /findalways $' $ |
---|
[69] | 151 | , ' , filename = '+sfilename+' $'] |
---|
| 152 | if n_elements(sendpoints) NE 0 then $ |
---|
| 153 | Cmd = [Cmd, ' , endpoints = ' + sendpoints + ', type = ''' + type + ''' $'] |
---|
| 154 | Cmd = [Cmd, ' , _extra = mixstru(ex, extra), /nostruct)'] |
---|
| 155 | (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar] |
---|
| 156 | (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] |
---|
| 157 | ENDIF ELSE BEGIN |
---|
| 158 | Cmd = [funclec_name+'('+snamevar+', date1, date2, '+snameexp $ |
---|
| 159 | +', parent = '+strtrim(base, 1)+', boxzoom = '+box+' $' $ |
---|
| 160 | , ' , filename = '+sfilename+' $'] |
---|
| 161 | if n_elements(sendpoints) NE 0 then $ |
---|
| 162 | Cmd = [Cmd, ' , endpoints = ' + sendpoints + ', type = ''' + type + ''' $'] |
---|
| 163 | Cmd = [Cmd, ' , _extra = mixstru(ex, extra), /nostruct)'] |
---|
| 164 | ENDELSE |
---|
[2] | 165 | ; print, '::::::::::::::::::::::' |
---|
[69] | 166 | ; for i = 0, n_elements(Cmd)-1 do print, Cmd[i] |
---|
[2] | 167 | ; print, '::::::::::::::::::::::' |
---|
| 168 | ;------------------------------------------------------------ |
---|
| 169 | |
---|
| 170 | ;------------------------------------------------------------ |
---|
[69] | 171 | return, cmd |
---|
[2] | 172 | end |
---|