Re: Basic format code question [message #50642] |
Mon, 16 October 2006 07:50  |
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 #50651 is a reply to message #50646] |
Mon, 16 October 2006 05:18   |
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   |
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   |
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 #50659 is a reply to message #50658] |
Mon, 16 October 2006 02:26   |
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 #50663 is a reply to message #50662] |
Mon, 16 October 2006 01:42   |
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.
>
>
|
|
|
|
|