Double Accuracy [message #29679] |
Mon, 11 March 2002 10:46  |
michaeltcruz
Messages: 4 Registered: March 2002
|
Junior Member |
|
|
I am in the process of writing a program to read in exponential data
and plot its relationship to another variable. The trouble I am
having is that the values I am reading in are very small and I am
losing accuracy when I convert from a STRING to DOUBLE. Below is the
procedure I am using with a sample of the input and output. As you
can see, the output for this RATIO value is truncated to eight digits
which makes the value useless. I am fairly new to PVWAVE so I could
be making some fundamental mistakes. Appreciate help anyone can give.
PRO read_scc, file, VTCW, DOY, Year, Time, Ratio
Dummy = STRARR(4)
TempRatio = DOUBLE(1.0)
status = DC_READ_FIXED(file, Dummy, $
Format = "(7X, A33)", Nskip = 1)
VTCW = float(Dummy(0))
Year = STRMID(Dummy(1), 1, 4)
DOY = fix(STRMID(Dummy(1), 6, 3))
Time = float(STRMID(Dummy(1), 10, 33))
Ratio = Dummy(2)
print, 'BRatio', Ratio
Ratio = STRSUBST(Ratio, 'e', 'd');
print, 'ARatio', Ratio
Ratio = DOUBLE(Ratio)
info, Ratio
END
INPUT FILE
xxx ZZZZZ 02 022 07:29:11
VTCW = 5.447425871924000e+13
UTC = 2002 022 2.583419472210000e+04
RATIO = 9.999198181040011e-07
OUTPUT
;BRatio 9.999198181040011e-07
;ARatio 9.999198181040011d-07
RATIO DOUBLE = 9.9991982e-07
|
|
|
Re: Double Accuracy [message #29772 is a reply to message #29679] |
Thu, 14 March 2002 10:17  |
michaeltcruz
Messages: 4 Registered: March 2002
|
Junior Member |
|
|
Craig:
Unfortunately I don't have access to the online help. I am logging in
remotely to the machine with PVWAVE and the help command is one that
does not work because of the setup of the PC I am working from. I
have found the PVWAVE Reference manual online at VNI but they don't
have any of the other documentaion available. I have also found the
Referernce maunual online at some other sites but nothing that gets
into the detail I need on many commands. Was hoping for something
like online help on the web since I have seen it used and think it
would be helpful if I could get access to it.
Thanks,
Mike Cruz
Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote in message news:<ond6y934jr.fsf@cow.physics.wisc.edu>...
> michaeltcruz@yahoo.com (Michael Cruz) writes:
>>
>> Craig, I couldn't get the format='(D0)' to pass muster with the
>> complier but format = '(d)' gives me most of the accuracy. Do you
>> know of any website or reference material that goes into depth about
>> the use of the format command that would be helpful?
>
> How about the online help? Under IDL 4, this is documented under the
> topic "Format Codes". I believe that IDL 4 and PVWAVE share the same
> pedigree.
>
> Craig
|
|
|
Re: Double Accuracy [message #29803 is a reply to message #29679] |
Tue, 12 March 2002 12:38  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
michaeltcruz@yahoo.com (Michael Cruz) writes:
>
> Craig, I couldn't get the format='(D0)' to pass muster with the
> complier but format = '(d)' gives me most of the accuracy. Do you
> know of any website or reference material that goes into depth about
> the use of the format command that would be helpful?
How about the online help? Under IDL 4, this is documented under the
topic "Format Codes". I believe that IDL 4 and PVWAVE share the same
pedigree.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Double Accuracy [message #29804 is a reply to message #29679] |
Tue, 12 March 2002 11:50  |
michaeltcruz
Messages: 4 Registered: March 2002
|
Junior Member |
|
|
Okay, thanks to both of you Craig and David. The plotting shortcoming
explains why I have been having this trucation problem. I thought it
may have been due to the way I was handling the conversion.
Craig, I couldn't get the format='(D0)' to pass muster with the
complier but format = '(d)' gives me most of the accuracy. Do you
know of any website or reference material that goes into depth about
the use of the format command that would be helpful?
Thanks Again,
Mike
Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote in message news:<onvgc1g4qw.fsf@cow.physics.wisc.edu>...
> Hi Michael--
>
> I actually think that David is right. You are dealing with two things
> here. First of all, the printing precision by default is too low.
> Instead of using INFO, why not use more precision in your format
> statement, as in:
>
> print, ratio, format='(D0)'
>
> Then I think you will see that RATIO is kept to its full double
> precision.
>
> Now, on to the question of why it's *plotted* wrong. Up until
> recently IDL only kept its plot variables in single precision floating
> point. Any double precision values would be truncated down to single
> precision. Since you are using PVWAVE, I am sure that you are still
> using the "old" plotting engine of IDL.
>
> The solution for you is to subtract the mean value, or some other
> fiducial value, from the double precision values before plotting. If
> you really need to, you can relabel the axis ticks, but that gets
> involved.
>
> Craig
>
>
>
> michaeltcruz@yahoo.com (Michael Cruz) writes:
>
>
>> Thanks David but I'm sure that's not the problem. I probably should
>> have mentioned that I'm plotting several hundred of these values that
>> differ by less than the seven digits of truncated value and they are
>> end up being the same value. I was just using the INFO function to
>> show that the value was indeed getting changed to a DOUBLE.
>>
>>
>>
>> "David Burridge" <davidb@clogic.f9.co.uk> wrote in message news:<Pkkj8.6140$OP.179583@stones>...
>>> Hi Micheal,
>>>
>>> "Michael Cruz" <michaeltcruz@yahoo.com> wrote in message
>>> news:8e32c554.0203111046.35bd07c0@posting.google.com...
>>>> I am in the process of writing a program to read in exponential data
>>>> and plot its relationship to another variable. The trouble I am
>>>> having is that the values I am reading in are very small and I am
>>>> losing accuracy when I convert from a STRING to DOUBLE. Below is the
>>>> procedure I am using with a sample of the input and output. As you
>>>> can see, the output for this RATIO value is truncated to eight digits
>>>> which makes the value useless. I am fairly new to PVWAVE so I could
>>>> be making some fundamental mistakes. Appreciate help anyone can give.
>>> <snip>
>>>
>>> I'm more of an IDL user myself, but could it be the *printing* of the value
>>> that's truncating it, rather than the stored value itself? I notice that
>>> you're using "info" to print your ratio variable - what if you use 'print'
>>> like all the other values in the program?
>>>
>>> Hope this is useful,
>>>
>>> Dave
>>>
>>> David Burridge
>>> Burridge Computing
|
|
|
Re: Double Accuracy [message #29813 is a reply to message #29679] |
Tue, 12 March 2002 07:55  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Hi Michael--
I actually think that David is right. You are dealing with two things
here. First of all, the printing precision by default is too low.
Instead of using INFO, why not use more precision in your format
statement, as in:
print, ratio, format='(D0)'
Then I think you will see that RATIO is kept to its full double
precision.
Now, on to the question of why it's *plotted* wrong. Up until
recently IDL only kept its plot variables in single precision floating
point. Any double precision values would be truncated down to single
precision. Since you are using PVWAVE, I am sure that you are still
using the "old" plotting engine of IDL.
The solution for you is to subtract the mean value, or some other
fiducial value, from the double precision values before plotting. If
you really need to, you can relabel the axis ticks, but that gets
involved.
Craig
michaeltcruz@yahoo.com (Michael Cruz) writes:
> Thanks David but I'm sure that's not the problem. I probably should
> have mentioned that I'm plotting several hundred of these values that
> differ by less than the seven digits of truncated value and they are
> end up being the same value. I was just using the INFO function to
> show that the value was indeed getting changed to a DOUBLE.
>
>
>
> "David Burridge" <davidb@clogic.f9.co.uk> wrote in message news:<Pkkj8.6140$OP.179583@stones>...
>> Hi Micheal,
>>
>> "Michael Cruz" <michaeltcruz@yahoo.com> wrote in message
>> news:8e32c554.0203111046.35bd07c0@posting.google.com...
>>> I am in the process of writing a program to read in exponential data
>>> and plot its relationship to another variable. The trouble I am
>>> having is that the values I am reading in are very small and I am
>>> losing accuracy when I convert from a STRING to DOUBLE. Below is the
>>> procedure I am using with a sample of the input and output. As you
>>> can see, the output for this RATIO value is truncated to eight digits
>>> which makes the value useless. I am fairly new to PVWAVE so I could
>>> be making some fundamental mistakes. Appreciate help anyone can give.
>> <snip>
>>
>> I'm more of an IDL user myself, but could it be the *printing* of the value
>> that's truncating it, rather than the stored value itself? I notice that
>> you're using "info" to print your ratio variable - what if you use 'print'
>> like all the other values in the program?
>>
>> Hope this is useful,
>>
>> Dave
>>
>> David Burridge
>> Burridge Computing
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Double Accuracy [message #29815 is a reply to message #29679] |
Tue, 12 March 2002 07:24  |
michaeltcruz
Messages: 4 Registered: March 2002
|
Junior Member |
|
|
Thanks David but I'm sure that's not the problem. I probably should
have mentioned that I'm plotting several hundred of these values that
differ by less than the seven digits of truncated value and they are
end up being the same value. I was just using the INFO function to
show that the value was indeed getting changed to a DOUBLE.
"David Burridge" <davidb@clogic.f9.co.uk> wrote in message news:<Pkkj8.6140$OP.179583@stones>...
> Hi Micheal,
>
> "Michael Cruz" <michaeltcruz@yahoo.com> wrote in message
> news:8e32c554.0203111046.35bd07c0@posting.google.com...
>> I am in the process of writing a program to read in exponential data
>> and plot its relationship to another variable. The trouble I am
>> having is that the values I am reading in are very small and I am
>> losing accuracy when I convert from a STRING to DOUBLE. Below is the
>> procedure I am using with a sample of the input and output. As you
>> can see, the output for this RATIO value is truncated to eight digits
>> which makes the value useless. I am fairly new to PVWAVE so I could
>> be making some fundamental mistakes. Appreciate help anyone can give.
> <snip>
>
> I'm more of an IDL user myself, but could it be the *printing* of the value
> that's truncating it, rather than the stored value itself? I notice that
> you're using "info" to print your ratio variable - what if you use 'print'
> like all the other values in the program?
>
> Hope this is useful,
>
> Dave
>
> David Burridge
> Burridge Computing
|
|
|
Re: Double Accuracy [message #29818 is a reply to message #29679] |
Tue, 12 March 2002 02:01  |
David Burridge
Messages: 33 Registered: January 1998
|
Member |
|
|
Hi Micheal,
"Michael Cruz" <michaeltcruz@yahoo.com> wrote in message
news:8e32c554.0203111046.35bd07c0@posting.google.com...
> I am in the process of writing a program to read in exponential data
> and plot its relationship to another variable. The trouble I am
> having is that the values I am reading in are very small and I am
> losing accuracy when I convert from a STRING to DOUBLE. Below is the
> procedure I am using with a sample of the input and output. As you
> can see, the output for this RATIO value is truncated to eight digits
> which makes the value useless. I am fairly new to PVWAVE so I could
> be making some fundamental mistakes. Appreciate help anyone can give.
<snip>
I'm more of an IDL user myself, but could it be the *printing* of the value
that's truncating it, rather than the stored value itself? I notice that
you're using "info" to print your ratio variable - what if you use 'print'
like all the other values in the program?
Hope this is useful,
Dave
David Burridge
Burridge Computing
|
|
|