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

Home » Public Forums » archive » Re: [Q] Reading from file, speed
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: [Q] Reading from file, speed [message #18912 is a reply to message #18911] Thu, 10 February 2000 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Koen Janssens (janssens@ifu.bepr.ethz.ch) writes:

> I am looking for a better way to import data into IDL, the one I am
> using now seems very slow (about 20 secs for reading in 2 MBytes). Here
> is the script that I use:
>
> openr, ms_dat_unit, ms_dat_file
> ms = bytarr(dimx,dimy,dimz)
> for z = 0,(dimz-1) do begin
> for y = 0,(dimy-1) do begin
> for x = 0,(dimx-1) do begin
> readu, ms_dat_unit, tmp
> ms[x,y,z] = tmp
> endfor
> endfor
> endfor
> close, ms_dat_unit
> free_lun, ms_dat_unit
>
> The file I am reading contains integers in binary format (volume data
> 128^3).

IDL is sometimes considered a loopy language, but
it is definitely NOT a looping language. :-)

Those FOR loops are killing you. Try something
like this:

openr, ms_dat_unit, ms_dat_file, /get_lun
ms = bytarr(dimx,dimy,dimz)
readu, ms_dat_unit, ms
free_lun, ms_dat_unit

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Error Handling, Was: Passing optional parameters
Next Topic: [Q] Reading from file, speed

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

Current Time: Wed Dec 03 10:36:01 PST 2025

Total time taken to generate the page: 2.38186 seconds