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

Home » Public Forums » archive » format codes
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
format codes [message #93669] Tue, 27 September 2016 07:49 Go to next message
sayaniforever is currently offline  sayaniforever
Messages: 2
Registered: September 2016
Junior Member
I am working with with phase data that looks like 23568978.124578 in cycles.
I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.
Re: format codes [message #93670 is a reply to message #93669] Tue, 27 September 2016 07:59 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, September 27, 2016 at 10:49:42 AM UTC-4, sayani ghosh wrote:
> I am working with with phase data that looks like 23568978.124578 in cycles.
> I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.

You are telling IDL that you want exactly 4 digits after the decimal point, so that is what it is giving you. If you want 5 digits than use E11.5
Better yet try the '(D)' format
Re: format codes [message #93671 is a reply to message #93670] Tue, 27 September 2016 09:19 Go to previous messageGo to next message
sayaniforever is currently offline  sayaniforever
Messages: 2
Registered: September 2016
Junior Member
When I am using (D), some kind of overflow is occurring as a result IDL is printing ***************.

I have realised IDL is reading the data as 2.3568e+007.. I can't seem to work around it.
Re: format codes [message #93672 is a reply to message #93671] Tue, 27 September 2016 09:27 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, September 27, 2016 at 12:20:11 PM UTC-4, sayani ghosh wrote:
> When I am using (D), some kind of overflow is occurring as a result IDL is printing ***************.
>
> I have realised IDL is reading the data as 2.3568e+007.. I can't seem to work around it.

Are you reading it as double precision?
Re: format codes [message #93676 is a reply to message #93671] Wed, 28 September 2016 01:36 Go to previous messageGo to next message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 09/27/2016 06:19 PM, sayani ghosh wrote:
> When I am using (D), some kind of overflow is occurring as a result IDL is printing ***************.
>
> I have realised IDL is reading the data as 2.3568e+007.. I can't seem to work around it.

Try using format='(e12.4)'
or with more digits format='(e14.6)'
where the first number gives the width of the column and the second the
number of digits after .

@ wayne: e11.5 doesn't work on windows, because it uses 3 digits in the
exponent

Depending on how large the numbers you want to print, something like
format='(d16.6)'
might also be an option. if you get ****************, then you have to
increase the width, e.g. format='(d20.6)'

More details you can find under [1],

I hope that helps, Markus

[1]:
http://www.harrisgeospatial.com/docs/format_codes.html#files _2839720996_168654
Re: format codes [message #93677 is a reply to message #93669] Wed, 28 September 2016 04:44 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, September 27, 2016 at 10:49:42 AM UTC-4, sayani ghosh wrote:
> I am working with with phase data that looks like 23568978.124578 in cycles.
> I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.

FORMAT='(G)'

will print the full double precision and include the exponent where necessary.
Re: format codes [message #93679 is a reply to message #93677] Wed, 28 September 2016 08:00 Go to previous messageGo to next message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
On Wednesday, September 28, 2016 at 5:44:57 AM UTC-6, Craig Markwardt wrote:
> On Tuesday, September 27, 2016 at 10:49:42 AM UTC-4, sayani ghosh wrote:
>> I am working with with phase data that looks like 23568978.124578 in cycles.
>> I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.
>
> FORMAT='(G)'
>
> will print the full double precision and include the exponent where necessary.

For those reading this thread in the future with IDL 8.6 or later, be aware of the difference between "(G)" (FORTRAN-style) and "%g" (C_style) FORMAT specifiers because they are not equivalent.

IDL> print, a, format = '(G)'
1.234567891011112E-066
IDL> print, a, format = '%g'
1.23457e-066
IDL> print, a, format = '%22g'
1.234567891011112e-066

Jim P.
Re: format codes [message #93680 is a reply to message #93679] Wed, 28 September 2016 08:22 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Interesting. I seem not to be able to travel forward in time... When is 8.6 appearing for non-time travelers?
Any further sneak preview info (apart from the c_style output formatting)?

Thanks,
h



On Wednesday, September 28, 2016 at 5:00:20 PM UTC+2, Jim P wrote:
> On Wednesday, September 28, 2016 at 5:44:57 AM UTC-6, Craig Markwardt wrote:
>> On Tuesday, September 27, 2016 at 10:49:42 AM UTC-4, sayani ghosh wrote:
>>> I am working with with phase data that looks like 23568978.124578 in cycles.
>>> I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.
>>
>> FORMAT='(G)'
>>
>> will print the full double precision and include the exponent where necessary.
>
> For those reading this thread in the future with IDL 8.6 or later, be aware of the difference between "(G)" (FORTRAN-style) and "%g" (C_style) FORMAT specifiers because they are not equivalent.
>
> IDL> print, a, format = '(G)'
> 1.234567891011112E-066
> IDL> print, a, format = '%g'
> 1.23457e-066
> IDL> print, a, format = '%22g'
> 1.234567891011112e-066
>
> Jim P.
Re: format codes [message #93682 is a reply to message #93680] Wed, 28 September 2016 11:17 Go to previous messageGo to next message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
On Wednesday, September 28, 2016 at 9:22:08 AM UTC-6, Helder wrote:
> Interesting. I seem not to be able to travel forward in time... When is 8.6 appearing for non-time travelers?
> Any further sneak preview info (apart from the c_style output formatting)?
>
> Thanks,
> h
>
>
>
> On Wednesday, September 28, 2016 at 5:00:20 PM UTC+2, Jim P wrote:
>> On Wednesday, September 28, 2016 at 5:44:57 AM UTC-6, Craig Markwardt wrote:
>>> On Tuesday, September 27, 2016 at 10:49:42 AM UTC-4, sayani ghosh wrote:
>>>> I am working with with phase data that looks like 23568978.124578 in cycles.
>>>> I want to export the whole value in decimal format without rounding off. The problem while using E11.4 or a or G10.4 is, IDL is rounding my data like 2.3568e+007.. Which is leading to errors in consequent calculations.
>>>
>>> FORMAT='(G)'
>>>
>>> will print the full double precision and include the exponent where necessary.
>>
>> For those reading this thread in the future with IDL 8.6 or later, be aware of the difference between "(G)" (FORTRAN-style) and "%g" (C_style) FORMAT specifiers because they are not equivalent.
>>
>> IDL> print, a, format = '(G)'
>> 1.234567891011112E-066
>> IDL> print, a, format = '%g'
>> 1.23457e-066
>> IDL> print, a, format = '%22g'
>> 1.234567891011112e-066
>>
>> Jim P.

Info on a few new features in 8.6 has been leaking out over the past months over on the IDL Data Point blog on the www.harrisgeospatial.com website. The time frame for release is still in the works as of September 28, 2016.
Re: format codes [message #93694 is a reply to message #93669] Sat, 01 October 2016 22:34 Go to previous message
sg26041991 is currently offline  sg26041991
Messages: 3
Registered: July 2016
Junior Member
I have tried entering the data as string input and reading them as double precision values. It's working that way..

Thanks a lot everybody for your suggestions.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to read nc variable partly?
Next Topic: high rise building extraction from satellite image

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

Current Time: Wed Oct 08 09:08:11 PDT 2025

Total time taken to generate the page: 0.02375 seconds