Discussion:
Writing a dat file and opening in ENVI
(too old to reply)
Sarah Douglas
2015-01-26 14:05:25 UTC
Permalink
Hi,

I am quite new to IDL so this might be just a basic problem which I am overlooking.

I am trying to write a .dat file of an image which can be read in ENVI. I am able to write the array to the file but then when I open it in ENVI, I get an image with vertical stripes in every other pixel. However, if i re-read the file into IDL, I do not see these stripes.

I believe this could be to do with how ENVI reads .dat files or how the data is written to the file. Here is some example code,

nrows = 382L
ncols = 38L
num_bd = 102
test_arr = uintarr(nrows, num_bd, ncols)
for i=0,num_bd-1 do test_arr(*,i,*) = i+1

FILENAME = '/home/sarah/Data/Upscaled_pre_SVD/'+ 'test.dat'

openw, 1, filename
writeu, 1, test_arr
close, 1

result = 0
result = uintarr(nrows, num_bd, ncols)
openr, 1, filename
readu, 1, result
close, 1
Michael Galloy
2015-01-26 18:17:08 UTC
Permalink
Post by Sarah Douglas
Hi,
I am quite new to IDL so this might be just a basic problem which I am overlooking.
I am trying to write a .dat file of an image which can be read in ENVI. I am able to write the array to the file but then when I open it in ENVI, I get an image with vertical stripes in every other pixel. However, if i re-read the file into IDL, I do not see these stripes.
I believe this could be to do with how ENVI reads .dat files or how the data is written to the file. Here is some example code,
nrows = 382L
ncols = 38L
num_bd = 102
test_arr = uintarr(nrows, num_bd, ncols)
for i=0,num_bd-1 do test_arr(*,i,*) = i+1
FILENAME = '/home/sarah/Data/Upscaled_pre_SVD/'+ 'test.dat'
openw, 1, filename
writeu, 1, test_arr
close, 1
result = 0
result = uintarr(nrows, num_bd, ncols)
openr, 1, filename
readu, 1, result
close, 1
It's been awhile since I have dealt with ENVI files, but I believe there
is a ASCII .hdr file associated with the .dat file. Did you write that
as well? I think you probably have the interleave mixed up -- either
from writing the .hdr file incorrectly or not having one and ENVI using
some defaults that don't match your data.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
Loading...