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

Home » Public Forums » archive » Re: Am I having a blackout?
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: Am I having a blackout? [message #66646 is a reply to message #66645] Fri, 29 May 2009 02:14 Go to previous messageGo to previous message
Allan Whiteford is currently offline  Allan Whiteford
Messages: 117
Registered: June 2006
Senior Member
Mark wrote:
> Hi all,
>
> I'm trying to read a very simple file with very basic commands, but it
> reads the wrong values for the last variable (d2): readf does not see
> it are negative values and reads only the last five digits. The first
> five items it reads OK. I guess I'm making a very trivial mistake
> here, but I don't see it. Anyone having a clearer mind than me?
> Thanks!
>
> Mark
>
> sum1 = 0.0
> sum2 = 0.0
> sum3 = 0.0
> sum4 = 0.0
> count = 0
> dummy1=''
> openr, unit, /get_lun, 'sunny_days.fits'
> while ~eof(unit) do begin
> readf, unit, format='(A8,F,F,F,F,F)', dummy1, dummy2, A, beta, d1,
> d2

Mark,

My understanding of simply using 'F' as a format code doesn't mean "read
a floating point number in a smart way" it means "use the default values
for a floating point number". These are (according to the manual)
equivalent to 'F15.7'.

So, when you write:

format='(A8,F,F,F,F,F)'

this is equivalent to:

format='(A8,F15.7,F15.7,F15.7,F15.7,F15.7)',

A cursory glance at your file seems to explain what is happening, all
your whitespace are being slowly eaten until finally things go wrong at
the last column.

The behaviour of 'F' doesn't seem to be as useful as you would
reasonably expect it to be.

You probably want to use:

format='(A8,5F13)'

but when reading data in like this it's usually better not to supply a
format code at all - then IDL will try to do something smart for you
based on the types of variables you're using.

Thanks,

Allan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Debugging Rules
Next Topic: Re: read multiple files with varying names

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

Current Time: Thu Oct 09 20:25:25 PDT 2025

Total time taken to generate the page: 0.79712 seconds