Re: calculating long term statistics on ALBEDO data [message #43298] |
Wed, 06 April 2005 00:51 |
Klaus Scipal
Messages: 45 Registered: November 1997
|
Member |
|
|
The problem with the moment function is that it can only be applied on the
entire array. If you want to apply it to a certain dimension you have to
loop through which slows everything down
Klaus
"Paul Van Delst" <paul.vandelst@noaa.gov> wrote in message
news:d2ur6h$u68$1@news.nems.noaa.gov...
> wita wrote:
>> Hi Klaus,
>>
>> You idea worked, I now have it implemented as follows:
>
> You might also want to look into the MOMENT function (I think that's the
> name). It does the mean, variance, skew and kurtosis in one go.
>
> paulv
>
> --
> Paul van Delst
> CIMSS @ NOAA/NCEP/EMC
>
|
|
|
|
Re: calculating long term statistics on ALBEDO data [message #43308 is a reply to message #43306] |
Tue, 05 April 2005 09:01  |
wita
Messages: 43 Registered: January 2005
|
Member |
|
|
Hi Klaus,
You idea worked, I now have it implemented as follows:
;Main processing loop
FOR i=0L, num_tiles-1 DO BEGIN
envi_report_stat,base, i, num_tiles
data = envi_get_tile(tile_id1, i)
mask = envi_get_tile(tile_id2, i)
;Only execute at first iterations to get the data dimensions
IF i EQ 0 THEN BEGIN
ds = SIZE(data, /DIMENSIONS)
means = FLTARR(ds[0],36)
stdev = means
decades = LINDGEN(ds[1]) MOD 36
index = WHERE(decades EQ 0)
ENDIF
;Loop over Z direction
FOR k=0, 35 DO BEGIN
tmpindex = index+k
count = TOTAL(FINITE(data[*,tmpindex]),2)
tmpmeans = TOTAL(data[*,tmpindex],2,/NAN)/FLOAT(count)
tmpmeans2d = REBIN(REFORM(tmpmeans, ds[0], 1), ds[0], $
N_ELEMENTS(index))
tmpstdev = SQRT(TOTAL((data[*,tmpindex] - tmpmeans2d)^2, $
2, /NAN)/(count[*]-1))
means[*,k] = tmpmeans
stdev[*,k] = tmpstdev
ENDFOR
WRITEU, unit1, means
WRITEU, unit2, stdev
ENDFOR
It now runs in a fraction of the time compared to the previous version.
Thanks,
Allard
|
|
|