comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Writing a dat file and opening in ENVI
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Writing a dat file and opening in ENVI [message #90095] Mon, 26 January 2015 06:05 Go to next message
Sarah Douglas is currently offline  Sarah Douglas
Messages: 3
Registered: December 2014
Junior Member
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
Re: Writing a dat file and opening in ENVI [message #90096 is a reply to message #90095] Mon, 26 January 2015 10:17 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 1/26/15 7:05 AM, Sarah Douglas wrote:
> 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: saving an output from the find.pro script
Next Topic: GPS Rinex reader

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:06:58 PDT 2025

Total time taken to generate the page: 0.00561 seconds