Re: Very slow IDL vs Matlab (ascii file reading) [message #36883 is a reply to message #36873] |
Wed, 05 November 2003 08:54   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Good work !
Reimar
Richard G. French wrote:
> OK, I figured out a work-around using STRSPLIT:
>
> ; write the data file
>
> x=make_array(/double,value=999.d0,660L*496L)
> w=17L*660L*496L
> openw,lun,/get_lun,'Mydata.dat',width=w
> PRINTF,lun,x
> free_lun,lun
> ; read the file as a single string
> s=''
> openr,lun,'Mydata.dat',/get_lun
> readf,lun,s
> IDL> help,s
> S STRING = ' 999.00000 999.00000
> 999.000'...
> free_lun,lun
> ;convert the long string to desired floating point array
> Data=fltarr(660,496)
> Reads,strsplit(s,/EXTRACT),data
>
> This is fast, and should do what you need without having to split the file
> itself in to shorter lines. You can do it all in IDL.
>
>
> Dick French
>
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|