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

Home » Public Forums » archive » Re: Simple File I/O
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Simple File I/O [message #58350] Fri, 25 January 2008 21:11 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gary writes:

> This questions stems, as much as anything, from my newness to
> programming in general. I would like to take a pixmap my code
> generates, save it as a file for later use, and then read it in later
> after having restarted the code. Thus far, I've tried simply using
> writeu and readu. The error comes when readu is reached producing the
> error, readu: end of file encountered. I use TVRD() to generate a
> float array from the pixmap then writeu this to a file.

TVRD() doesn't generate floats. It generates bytes, and probably
not in the way you are expecting, to be honest. So, even if this
works, I don't think you will be happy with the results. Do you
mean you are *casting* the results of TVRD() into floats?

> This produces a file of byte format?

Huh!?

> On the other end, I generate a float array hard
> coded to the same size as the original pixmap, and simply use readu
> into the float array, whereupon I get the end of file encountered
> error.

When you make a float array, you tell IDL to read 4 bytes for each
floating value. Since I am certain you have a byte array, you are
running past the end of the file, which is why you are getting this
error. You are trying to read four times as many bytes as there
are in the file.

> I think I'm missing something between the conversion between
> the original float array to bytes and then back again.

The original array was in bytes to begin with. But if you hope
to recover your window, you will probably (unless you have an
ancient computer) want to read a 3 by x by y array out of that
window. If you do it the way you appear to be doing it, your
window when it is restored will look nothing like it did when
you saved it.

I would use TVREAD and save the data in a TIFF file. Then just
read the data from the TIFF file to recover it.

http://www.dfanning.com/programs/tvread.pro

> Also, fstat
> tells me that there are four extra bytes to the number of cells in the
> original array. 460x920 = 423200 cells, but fstat gives a file size of
> 423204 bytes. I'm guessing its really simple and I'm just missing it.
> Any and all help much appreciated.

I don't know. Let's solve the other problems first, then deal with
this. :-)

Cheers,

David
>

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Previous Topic: Using Postscript & Colours in IDL
Next Topic: Is there a good procedure for Minimum Variance Analysis?

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

Current Time: Wed Oct 08 16:00:49 PDT 2025

Total time taken to generate the page: 0.00412 seconds