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

Home » Public Forums » archive » Re: find max in 3D array -- slow
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: find max in 3D array -- slow [message #70375 is a reply to message #70370] Sun, 11 April 2010 03:44 Go to previous messageGo to previous message
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
On Apr 11, 2:03 am, "Timothy W. Hilton" <hil...@meteo.psu.edu> wrote:
> Hello IDL users,
>
> I have a 1200x1200x2900 array of floats.  The dimensions correspond to
> latitude x longitude x time.  I need to find the maxium at each
> location -- that is, I need the 1200x1200 array containing the max
> along the 3rd dimsion.  IDL takes almost 3 minutes to do this on my
> system.  This seemed slow.  I compared it with Matlab, which took ten
> seconds.  Is there a better way to search for the maxima using IDL?
>
> The demo code I used to compare IDL and Matlab is below (with output).
>
> I'm wondering if I ought to switch to Matlab.  I just spent a couple
> of days writing IDL code to read my data, so I'd rather not.
>
> Many thanks,
> Tim
>
> --
>
> Timothy W. Hilton
> PhD Candidate, Department of Meteorology
> The Pennsylvania State University
> 503 Walker Building, University Park, PA   16802
> hil...@meteo.psu.edu
>
> ========
> scratch.pro:
>
> foo = randomu(0, 1200, 1200, 2920)
> PRINT, systime()
> foo_max = max(foo, DIMENSION = 3)
> PRINT, systime()
> END
>
> IDL> .run scratch
> % Compiled module: $MAIN$.
> Sat Apr 10 10:44:44 2010
> Sat Apr 10 10:47:36 2010
> IDL>
>
> ========
> scratch.m:
>
> foo = rand(1200,1200,2920);
> fprintf('%s\n', datestr(now()));
> foo_max = max(foo, [], 3);
> fprintf('%s\n', datestr(now()));
>
>>> scratch
>
> 10-Apr-2010 10:42:45
> 10-Apr-2010 10:42:55

I don't know if it's any quicker, and it will sure chew some memory
but sort_nd might be worth a try.

http://www.dfanning.com/programs/sort_nd.pro

Just sort it along the 3rd dimension and then pull the slice of the
last band...
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: clever way to subregion an image?
Next Topic: wholesale Ray.Ban sunglasses in http://nikesoso.51.com

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

Current Time: Wed Oct 08 17:27:59 PDT 2025

Total time taken to generate the page: 0.00464 seconds