Daily to monthly [message #89879] |
Mon, 15 December 2014 20:10  |
manikbali
Messages: 4 Registered: December 2014
|
Junior Member |
|
|
Hi
I have daily satellite scan files of soil moisture from 1979 - 2008. I want to convert it into monthly values.
What is the best way to to it.
-GlanPlon
|
|
|
|
|
Re: Daily to monthly [message #89888 is a reply to message #89881] |
Wed, 17 December 2014 12:54   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Tuesday, December 16, 2014 1:21:46 PM UTC-5, mani...@gmail.com wrote:
> Hi Craig,
> I need Monthly means where missing values are taken care of
Average = sum / n_points
The only trick is that n_points could be different depending on missing data. So if I had an array of values DATA[*,*] where DATA[i,j] is the ith position on the jth day, and missing value is -999, I could sum them like this,
tot = 0 ;; cumulative sum of data values
npt = 0 ;; cumulative sum of number of good data values
for j = 0, NDAYS-1 do begin
mask = data[*,j] NE -999 ;; mask of good values only, 1=good
npt = npt + mask ;; add to number of good values
tot = tot + (data[*,j]*mask) ;; add good vals to cumulative data sum
endfor
;; Compute average
av = tot / npt
Craig
|
|
|
Re: Daily to monthly [message #89897 is a reply to message #89888] |
Fri, 19 December 2014 01:31  |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
On Wednesday, December 17, 2014 9:54:17 PM UTC+1, Craig Markwardt wrote:
> On Tuesday, December 16, 2014 1:21:46 PM UTC-5, mani...@gmail.com wrote:
>> Hi Craig,
>> I need Monthly means where missing values are taken care of
>
> Average = sum / n_points
>
> The only trick is that n_points could be different depending on missing data. So if I had an array of values DATA[*,*] where DATA[i,j] is the ith position on the jth day, and missing value is -999, I could sum them like this,
>
> tot = 0 ;; cumulative sum of data values
> npt = 0 ;; cumulative sum of number of good data values
> for j = 0, NDAYS-1 do begin
> mask = data[*,j] NE -999 ;; mask of good values only, 1=good
> npt = npt + mask ;; add to number of good values
> tot = tot + (data[*,j]*mask) ;; add good vals to cumulative data sum
> endfor
>
> ;; Compute average
> av = tot / npt
>
> Craig
Hi Craig,
Note that you might simply do:
mask = data ne -999
av = Total(data*mask, 2)/Total(mask, 2); daily average
av = Total(data*mask)/Total(mask); overall average
etc...
alx.
|
|
|