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

Home » Public Forums » archive » Re: Avoiding loop stats
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: Avoiding loop stats [message #52154 is a reply to message #52153] Fri, 19 January 2007 10:11 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 19 Jan 2007 09:43:59 -0800, yp wrote:

> IDL Gurus,
> There is perhaps a smart solution to this problem, but I could not
> figure out.
> I have a series of EO images (2D) stacked over time which makes the
> data a 3D array of [4000, 2000, 900] i.e., [lon,lat,time]
> I need to compute various statistical parameters at each pixel over
> time and produce each of them as [4000,2000] array.
>
>
> for i=0,4000L-1 do for j=0,2000L-1 do data_st(i,j)=st_func(data(i,j,*))
>
> where, data=FLTARR[4000,2000,900]
> data_st is the output from a function 'st_func' which works with vector
> data only.
>
> Is there a way to do this avoiding the 4000x2000 loop? It is painfully
> slow on windows.

Yes, recode st_func to work on the full data cube at once. Sometimes
this is easier said than done. Let's imagine your st_func just
calculates the standard deviation. Unfortunately, IDL's built-in
statistics functions are almost all array-unaware, but some things are
easy to do "by hand":

s=size(data,/DIMEN)
mean=total(data,3)/s[2]
stddev=sqrt(total((data-rebin(mean,s))^2)/(s[2]-1))

Higher moments could be built as well. The "threadable" or
array-aware statistics/math functions (since IDL v5.6, anyway), are
MIN, MAX, MEDIAN, TOTAL, PRODUCT, SMOOTH, and CONVOL (any other I'm
missing?).

ITTVIS could invest a small amount of effort to improve this state of
affairs. For instance, it would be trivial to rewrite MOMENT.PRO to
take a DIMENSION keyword, such that VARIANCE, STDDEV, MEAN, SKEWNESS,
KURTOSIS could all be array-aware.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: nicing idl at startup from idlwave
Next Topic: ascii value of a char

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

Current Time: Sat Oct 11 03:56:25 PDT 2025

Total time taken to generate the page: 1.04086 seconds