[ncl-talk] Runave using only previous points
Dennis Shea
shea at ucar.edu
Thu Feb 2 18:58:17 MST 2017
re: runave
The answer is no. It uses centered values. For a 3 pt average"
x3 = (x(n-1) + x(n) + x(n+1))/3
To me, you want
x3 = (x(n-2) + x(n-1) +x(n))/3
or
x3 = (x(n-3) + x(n-2) +x(n-1))/3
which one?
===
I'm assuming 'x' is type float or double.
This is for a 1D time series
undef("jenny")
function jenny(x[*]:numeric, nsum[1]:integer)
local nx, xavg, nStrt, nLast
begin
nx = dimsizes(x)
xavg = x
xavg = x at _FillValue
nStrt = 0
nLast = nsum-1
do n=nLast,nx-1
xavg(n) = avg(x(nStrt:nLast))
print("n="+n+" nStrt="+nStrt+" nLast="+nLast+" xavg(n)="+xavg(n))
nStrt = nStrt+1
nLast = nLast+1
end do
return(xavg)
end
N = 100
x = conform_dims( N, 1.0, -1) ; all 1s
x at _FillValue = -999.0
k = 10
z = jenny(x,k)
print(z) all 1s
On Thu, Feb 2, 2017 at 4:11 PM, Andrea Jenney <andrea at atmos.colostate.edu>
wrote:
> Hi NCL Community,
>
> I am hoping you can provide me with some clarification on the
> documentation for the ‘runave’ function. I am trying to compute a running
> mean for a time series but using only points from previous (and not future)
> time steps to compute the mean for each point. Is this something I can do
> with the ‘runave’ function? If so, which option do I select?
>
> Example, for clarity:
> - x is my array of values
> - running average window of size 10
> - I would like an array, y, of size(x), at which every point, the value at
> y(i) is computed using the mean of x(i-9:i), but do not want to utilize
> cyclic conditions (runave opt -1)
>
> Thank you
> ---
> Andrea Jenney
> Graduate Research Assistant | Randall Group
> Colorado State University | Department of Atmospheric Science
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170202/b32193a5/attachment.html
More information about the ncl-talk
mailing list