[idvusers] Formula to calculate a moving average at each grid point

I know there must be a straightforward way to combine some of the existing Jython time series functions to do this, but I can't seem to figure it out: I have a time series of monthly temperature anomaly readings (over a global 2-D grid) in the parameter TREFHT and want to derive from this a new parameter TREFAVG that contains (at each point on the grid) the 12-month moving average. For example, if the temp anomaly over Chicago was
Jan     1
Feb     -1
Mar     2
Apr     0
May 3
Jun     -2
Jul     0
Aug     2
Sep     1
Oct     2
Nov     -4
Dec     0
then I need TREFAVG for the grid cell over Chicago in December to contain 0.33 (=sum(Jan-Dec)/12)). That same cell for Jan would contain sum(Feb-Jan)/12, etc.

I'm guessing the general strategy should be to define a new Jython function that calculates the average of the current value plus the preceding 11, then to use the applyToRange function to run it on the entire data series. But despite combing through the User's Guide section on the Jython Library and searching for relevant code examples, I can't seem to figure out the right syntax.

Any pointers would be most appreciated!

Wayt Gibbs
Intellectual Ventures