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

Home » Public Forums » archive » Re: Real Number on PVWAVE
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
Re: Real Number on PVWAVE [message #17878] Thu, 18 November 1999 00:00
Adrian Clark is currently offline  Adrian Clark
Messages: 6
Registered: October 1999
Junior Member
Dear Daniele,

It looks to me as though WAVE is interpreting your numbers as floats and
then truncating them. Did you specify your variable as a double before
reading? I suspect that if this is not specified, float is the expected
default when a '.' is found in a number. I got the following to work:

wave> DELVAR,varArray
make sure varArray doesn't already exist as a float from previous attempts!
wave> varArray=DBLARR(1)
tell wave to expect doubles
wave> status=DC_READ_FREE('filename',varArray,/resize)
/resize will resize varArray to cope with amount of data present
wave> PRINT,varArray,Format="(D11.5)"
print it in whatever format seems appropriate

HTH

Yours,
Adrian
Re: Real Number on PVWAVE [message #17890 is a reply to message #17878] Wed, 17 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Daniele Monti (daniele.monti@usa.net) writes:

> Thanks a lot for your help
> I've already tried to print data as you said but if I read these
> numbers using " DC_READ_FREE" :
>
> 37374.000200
> 37374.000400
> 37374.000600
> 37374.000800
> 37374.001000
> 37374.001200
> 37374.001400
> 37374.001600
> 37374.001800
> 37374.002000
>
>
> The result I get is:
>
> WAVE> Print, x , Format='(D20.6)'
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.000000
> 37374.003906
>
> Why????

Well, I suspect that DC_READ_FREE is reading the
data as Floats, rather than as Doubles. I'm not
familiar with the routine, but I'd guess it was
written in the PV-Wave language and probably of
the same quality as something like READ_IMAGE
in IDL. :-)

Is there a DOUBLE keyword that you can set?

In any case, I put your data into a text file
named "test.txt" and read it perfectly like this:

OpenR, lun, 'test.txt', /Get_Lun
data = DblArr(10)
ReadF, lun, data
Free_Lun, lun
Print, data, Format='(F20.6)'

Here is the output:

37374.000200
37374.000400
37374.000600
37374.000800
37374.001000
37374.001200
37374.001400
37374.001600
37374.001800
37374.002000

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Real Number on PVWAVE [message #17896 is a reply to message #17890] Wed, 17 November 1999 00:00 Go to previous message
daniele.monti is currently offline  daniele.monti
Messages: 3
Registered: November 1999
Junior Member
On Wed, 17 Nov 1999 09:48:29 -0700, davidf@dfanning.com (David
Fanning) wrote:

> Daniele Monti (daniele.monti@usa.net) writes:
>
>> I'm in big trouble with PV_WAVE.
>> I have to read a very simple file like this:
>> 37122.00002
>> 37122.00004
>> 37122.00006
>> ...
>> How can I read numbers with more then six or eight digits?
>> I tried using Double Precision format but I didn't get any positive
>> result.
>
> What makes you think you didn't get any positive results?
> I think you probably *did* read the numbers correctly,
> but you are printing them out improperly. Try printing
> the result like this:
>
> Print, result, Format='(D20.6)'
>
> Cheers,
>
> David


Dear David
Thanks a lot for your help
I've already tried to print data as you said but if I read these
numbers using " DC_READ_FREE" :

37374.000200
37374.000400
37374.000600
37374.000800
37374.001000
37374.001200
37374.001400
37374.001600
37374.001800
37374.002000


The result I get is:

WAVE> Print, x , Format='(D20.6)'
37374.000000
37374.000000
37374.000000
37374.000000
37374.000000
37374.000000
37374.000000
37374.000000
37374.000000
37374.003906

Why????
Re: Real Number on PVWAVE [message #17899 is a reply to message #17890] Wed, 17 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Daniele Monti (daniele.monti@usa.net) writes:

> I'm in big trouble with PV_WAVE.
> I have to read a very simple file like this:
> 37122.00002
> 37122.00004
> 37122.00006
> ...
> How can I read numbers with more then six or eight digits?
> I tried using Double Precision format but I didn't get any positive
> result.

What makes you think you didn't get any positive results?
I think you probably *did* read the numbers correctly,
but you are printing them out improperly. Try printing
the result like this:

Print, result, Format='(D20.6)'

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Windows PostScript Preview Image
Next Topic: Re: At Last! A Subsititute for CW_Field.

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

Current Time: Wed Oct 08 15:15:45 PDT 2025

Total time taken to generate the page: 0.00875 seconds