Re: how to make it an array? [message #39160] |
Mon, 19 April 2004 09:47 |
Gauri Kulkarni
Messages: 2 Registered: April 2004
|
Junior Member |
|
|
Maybe what you are looking for is the procedure READCOL. It reads any file
with data in comlumn form. It ignores anything in that file that is not in
the column form. It usually comes with astronomy libraries, but very easy
to find on on the web and download. Here is a sample:
IDL> readcol,'random_catalog_xyz.dat',x,y,z
% Compiled module: READCOL.
% Compiled module: NUMLINES.
% READCOL: Format keyword not supplied - All columns assumed floating
point
% Compiled module: GETTOK.
% Compiled module: REPCHR.
% Compiled module: STRNUMBER.
% READCOL: 957153 valid lines read
IDL> array = transpose([[x],[y],[z]])
IDL> help,array
ARRAY FLOAT = Array[3, 957153]
IDL>
It took about 30 seconds to read those many rows. So it's fairly fast.
Hope this helps.
Gauri.
On Sun, 18 Apr 2004, Thomas Nehls wrote:
> Hi,
>
> as the result of calculations I produced a 3 column .dat-file . While
> using /APPEND and after calculation of some images of 400x400 the length
> of the file is about 1,000,000 rows.
>
> For further calculation I want to read the .dat-file(using read_ascii?)
> into an array. I already got the file read but the type is struct and
> the value is anonymus.
> How can I make it an array?
> Thanks
> Tom
>
>
|
|
|
Re: how to make it an array? [message #39166 is a reply to message #39160] |
Sun, 18 April 2004 12:17  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Thomas Nehls wrote:
> Hi,
>
> as the result of calculations I produced a 3 column .dat-file . While
> using /APPEND and after calculation of some images of 400x400 the length
> of the file is about 1,000,000 rows.
>
> For further calculation I want to read the .dat-file(using read_ascii?)
> into an array. I already got the file read but the type is struct and
> the value is anonymus.
> How can I make it an array?
> Thanks
> Tom
Dear Tom,
I don't like read_ascii but I know that there is a keyword to switch the
modes from structure to array.
We have our own read_data_file routine written, this analyses itselfs where
comments and where data is. You'll find this in our library.
If you know your file the easiest thing is to read it by a simple program
written yourself.
file='test.dat'
comment=''
data=make_array(3,1000000L,value=999.0,/float)
openr,lun,/get_lun,file
readf,lun,comment
; I don't know if you have one or more comments in front of the data
readf,lun,data
free_lun,lun
That's all and it is the fastest method you could use.
cheers
Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|