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

Home » Public Forums » archive » Re: Basic format code question
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: Basic format code question [message #50642] Mon, 16 October 2006 07:50 Go to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 16 Oct 2006, Wox wrote:

> This will not work:
> readf,lun,b,format='(F13)'
>
> Where do I have to use the format keyword then?
>
> As far as I can see it now, I have to read strings or unformatted
> array and split+make float.
>
>
>
> On Mon, 16 Oct 2006 14:18:00 +0200, FÖLDY Lajos <foldy@rmki.kfki.hu>
> wrote:
>
>> Back to the original problem: in IDL, you will have to use an explicit
>> FORMAT specification in Windows.
>

and what about this: readf,lun,b,format='(5F13)'

Format reversion terminates the current record, and begins to work on the
next one. This means a new line both on read and write.

regards,
lajos
Re: Basic format code question [message #50646 is a reply to message #50642] Mon, 16 October 2006 07:06 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
This will not work:
readf,lun,b,format='(F13)'

Where do I have to use the format keyword then?

As far as I can see it now, I have to read strings or unformatted
array and split+make float.



On Mon, 16 Oct 2006 14:18:00 +0200, F�LDY Lajos <foldy@rmki.kfki.hu>
wrote:

> Back to the original problem: in IDL, you will have to use an explicit
> FORMAT specification in Windows.
Re: Basic format code question [message #50651 is a reply to message #50646] Mon, 16 October 2006 05:18 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 16 Oct 2006, greg michael wrote:

> But isn't the point of using an ascii file to make it human-readable?
> And editable? If not, you might as well just write the actual byte
> representation.
>
> Allowing numbers to run into one another in the special case of 13-char
> negative floats isn't so attractive to me. What if I write "3-4-5"?
> Should that make sense?
>
> regards,
> Greg
>

FL> i3=(i2=(i1=0))
FL> read, i1,i2,i3
: 3-4-5
FL> help, i1,i2,i3
I1 INT = 3
I2 INT = -4
I3 INT = -5

So FL tries to interpret the numbers without the separating space.

Back to the original problem: in IDL, you will have to use an explicit
FORMAT specification in Windows. In FL, I will print out a 2-digit
exponent in Windows, too, so there will be always at least one space in
the (default free-format) 13-char wide output.

regards,
lajos
Re: Basic format code question [message #50653 is a reply to message #50651] Mon, 16 October 2006 04:20 Go to previous messageGo to next message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
But isn't the point of using an ascii file to make it human-readable?
And editable? If not, you might as well just write the actual byte
representation.

Allowing numbers to run into one another in the special case of 13-char
negative floats isn't so attractive to me. What if I write "3-4-5"?
Should that make sense?

regards,
Greg

FÖLDY Lajos wrote:
> I don't think so. There is no space between the fields, the space you see
> is padding space inside the fields. For floats, the width of the field is
> 13, which results in no padding space in this case. My Fortran instinct
> says that no extra space is required, and I think IDL mimics Fortran here.
>
> regards,
> lajos
>
>
> On Mon, 16 Oct 2006, greg michael wrote:
>
>>
>> That's good that FL can do that, but correctly, they should both write
>> the numbers with an extra space...
>>
>> Greg
>>
>>
>> FÖLDY Lajos wrote:
>>>
>>> OK, I have discovered, that FL does the same :-). So it cames from the
>>> underlying system C library.
>>>
>>> On the other hand, FL can read back the following line, it can recognize,
>>> that the '-' sign is the beginning of the next number:
>>>
>>> 11.0335 11.0503 11.0615-1.60416e+006 1.05404e+007
>>>
>>> I think IDL should do the same.
>>>
>>> regards,
>>> lajos
>>
>>
> --110414000-150196392-1160993797=:20334--
Re: Basic format code question [message #50655 is a reply to message #50653] Mon, 16 October 2006 03:16 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
I don't think so. There is no space between the fields, the space you see
is padding space inside the fields. For floats, the width of the field is
13, which results in no padding space in this case. My Fortran instinct
says that no extra space is required, and I think IDL mimics Fortran here.

regards,
lajos


On Mon, 16 Oct 2006, greg michael wrote:

>
> That's good that FL can do that, but correctly, they should both write
> the numbers with an extra space...
>
> Greg
>
>
> FÖLDY Lajos wrote:
>>
>> OK, I have discovered, that FL does the same :-). So it cames from the
>> underlying system C library.
>>
>> On the other hand, FL can read back the following line, it can recognize,
>> that the '-' sign is the beginning of the next number:
>>
>> 11.0335 11.0503 11.0615-1.60416e+006 1.05404e+007
>>
>> I think IDL should do the same.
>>
>> regards,
>> lajos
>
>
Re: Basic format code question [message #50656 is a reply to message #50655] Mon, 16 October 2006 03:03 Go to previous messageGo to next message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
That's good that FL can do that, but correctly, they should both write
the numbers with an extra space...

Greg


FÖLDY Lajos wrote:
>
> OK, I have discovered, that FL does the same :-). So it cames from the
> underlying system C library.
>
> On the other hand, FL can read back the following line, it can recognize,
> that the '-' sign is the beginning of the next number:
>
> 11.0335 11.0503 11.0615-1.60416e+006 1.05404e+007
>
> I think IDL should do the same.
>
> regards,
> lajos
Re: Basic format code question [message #50657 is a reply to message #50656] Mon, 16 October 2006 02:51 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 16 Oct 2006, greg michael wrote:

>
> 6.2 Linux shows 2 figures.
> 6.3 Windows shows 3 figures...
>
> Greg


OK, I have discovered, that FL does the same :-). So it cames from the
underlying system C library.

On the other hand, FL can read back the following line, it can recognize,
that the '-' sign is the beginning of the next number:

11.0335 11.0503 11.0615-1.60416e+006 1.05404e+007

I think IDL should do the same.

regards,
lajos
Re: Basic format code question [message #50658 is a reply to message #50657] Mon, 16 October 2006 02:29 Go to previous messageGo to next message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
6.2 Linux shows 2 figures.
6.3 Windows shows 3 figures...

Greg
Re: Basic format code question [message #50659 is a reply to message #50658] Mon, 16 October 2006 02:26 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
I see. IDL portability :-)


On Mon, 16 Oct 2006, Wox wrote:

> Cfr. Manual on Format Code:
>
> ...
> Data Type w d e
> Float, Complex 15 7 2 (3 for Windows)
> ...
>
> Btw, I'm using 6.2 (Win)
>
>
>
> On Mon, 16 Oct 2006 11:08:19 +0200, FÖLDY Lajos <foldy@rmki.kfki.hu>
> wrote:
>
>>
>> the min/max exponent for float is -/+38. Two figures is enough :-)
>> I have tried IDL 5.3 (Solaris), with the same result. Which IDL version
>> prints three figures?
>>
>> regards,
>> lajos
>>
>>
>> On Mon, 16 Oct 2006, greg michael wrote:
>>
>>>
>>> So your version is using only two figures for the exponent - why is
>>> that?
>>>
>>> Greg
>>>
>>>
>
>
Re: Basic format code question [message #50660 is a reply to message #50659] Mon, 16 October 2006 02:16 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
Cfr. Manual on Format Code:

...
Data Type w d e
Float, Complex 15 7 2 (3 for Windows)
...

Btw, I'm using 6.2 (Win)



On Mon, 16 Oct 2006 11:08:19 +0200, F�LDY Lajos <foldy@rmki.kfki.hu>
wrote:

>
> the min/max exponent for float is -/+38. Two figures is enough :-)
> I have tried IDL 5.3 (Solaris), with the same result. Which IDL version
> prints three figures?
>
> regards,
> lajos
>
>
> On Mon, 16 Oct 2006, greg michael wrote:
>
>>
>> So your version is using only two figures for the exponent - why is
>> that?
>>
>> Greg
>>
>>
Re: Basic format code question [message #50661 is a reply to message #50660] Mon, 16 October 2006 02:08 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
the min/max exponent for float is -/+38. Two figures is enough :-)
I have tried IDL 5.3 (Solaris), with the same result. Which IDL version
prints three figures?

regards,
lajos


On Mon, 16 Oct 2006, greg michael wrote:

>
> So your version is using only two figures for the exponent - why is
> that?
>
> Greg
>
>
Re: Basic format code question [message #50662 is a reply to message #50661] Mon, 16 October 2006 01:55 Go to previous messageGo to next message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
So your version is using only two figures for the exponent - why is
that?

Greg
Re: Basic format code question [message #50663 is a reply to message #50662] Mon, 16 October 2006 01:42 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 16 Oct 2006, Wox wrote:

> Hi,
>
> Try this:
>
> openw,lun,path,/get_lun
> a=[11.0335 , 11.0503 , 11.0615,-1.60416e+006 , 1.05404e+007]
> printf,lun,a
> close,lun
> free_lun,lun
>
> openr,lun,path,/get_lun
> b=fltarr(5)
> readf,lun,b ; => this will not work

This works in IDL 6.2 (linux).

> close,lun
> free_lun,lun
>
> What is saved in the file looks like this:
> 11.0335 11.0503 11.0615-1.60416e+006 1.05404e+007
> Problems with the fourth number because of the '-'.
>

What is saved in the file looks like this:

11.0335 11.0503 11.0615 -1.60416e+06 1.05404e+07

regards,
lajos


> Is this normal behaviour for IDL's default formatting?
>
> Suppose the files are already there (can't set format keyword in
> printf), how should I read this file without reading strings (data is
> not fltarr(5) but fltarr(50,50,14))? Using format='(E13)' won't work
> and you can't use repeat count with readf.
>
>
Re: Basic format code question [message #50664 is a reply to message #50663] Mon, 16 October 2006 01:31 Go to previous messageGo to next message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
> Is this normal behaviour for IDL's default formatting?

Looks like it is.

> Suppose the files are already there (can't set format keyword in
> printf), how should I read this file without reading strings (data is
> not fltarr(5) but fltarr(50,50,14))?

Looks like you can't. So now I know what that paragraph in the STRMID
documentation must have been trying to explain...

Greg
Re: Basic format code question [message #50841 is a reply to message #50642] Mon, 16 October 2006 08:02 Go to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
Sorry, my mistake. I was using format='5(F13)'. Thanks.


On Mon, 16 Oct 2006 16:50:34 +0200, F�LDY Lajos <foldy@rmki.kfki.hu>
wrote:

> and what about this: readf,lun,b,format='(5F13)'
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Differentiation in IDL
Next Topic: Altered device coordinates after first call

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

Current Time: Wed Oct 08 15:18:01 PDT 2025

Total time taken to generate the page: 0.00776 seconds