Hi,
I wrote a IDL program to calculate the yearly average precipitation. It can correctly average 285 images but not more than that. It will give an error saying that result is invalid and I tried the equation by using the ENVI band math. It also give an error. So please help me to solve this problem it is strange even though..
pro Average_images_batchP
compile_opt idl2
ENVI, /RESTORE_ALL
;
envi_batch_init, log_file='batch.txt'
;
input_dir =DIALOG_PICKFILE(/DIRECTORY, TITLE='Select folder')
stack_file = FILE_SEARCH(input_dir+'*.dat',COUNT=count)
fid = lonarr(count)
pos = lonarr(count)
dims = lonarr(5,count)
for i=0L,count-1 do begin
st_file = stack_file[i]
envi_open_file,st_file, r_fid=t_fid
if (t_fid eq -1) then begin
envi_batch_exit
return
endif
fid[i] = t_fid
pos[i] = 0
envi_file_query, t_fid, $
ns=r_ns, nl=r_nl, nb=r_nb ,sname=rname
dims[0,i] = [-1,0,r_ns-1,0,r_nl-1]
print,r_ns,r_nl
if(i eq 0)then begin
expstring='(b'+string(i+1)
endif else begin
expstring=expstring+'+b'+string(i+1)
endelse
endfor
expstring=STRCOMPRESS(expstring+')/'+string( float(count)),/REMOVE_ALL)
print,expstring
cd,'E:\Academic\Research\Processing\percipitationSubset32\'
out_name=STRCOMPRESS('percipYearlyAvg'+'.img',/REMOVE_ALL)
;out_name=STRCOMPRESS('watershed_'+string(h)+'.dat',/REMOVE_ALL)
envi_doit, 'math_doit', $
fid=fid, pos=pos, dims=dims, $
exp=expstring, out_name=out_name, $
r_fid=r_fid
;endfor
envi_batch_exit
end
|