I am trying to perform batch processing in ENVI using band math. The input is a 7-band file of MODIS reflectance data which have been converted from hdf to bsq. The data type is integer.
I want to compute a normalized difference ratio using MODIS bands 2 and 6. I know that, in order to get bands 2 and 6, the POS syntax should refer to [1,5]. I've modified some code from another program (which works fine).
The problem is that the values I get are negative and incorrect when computed using the code below. When I compute in ENVI by hand they are positive and correct.
Here's what I'm doing:
;envi_open_data_file, filename, r_fid=r_fid, /ENVI
envi_open_file, filename, r_fid=r_fid ; open the file in ENVI
envi_file_query, r_fid, fname=filename, dims=dims, nl=nl, ns=ns, nb=nb
exp = '(float(b2)-float(b6))/(float(b2)+float(b6))'
pos=[1,5]-1
fid=[r_fid,r_fid]
; if the input file is valid, then compute LSWI
if (file_test(out_name(n)) ne 1) then envi_doit, 'math_doit', dims=dims, exp=exp, fid=fid, pos=pos, r_fid=math_fid, out_name=out_name(n)
Thanks for any insights you can provide.
|