* +-======-+
* Copyright (c) 2003-2007 United States Government as represented by
* the Admistrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,
* REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN
* COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS
* REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY").
* THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN
* INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR
* REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES,
* DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED
* HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE
* RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT.
*
* Government Agency: National Aeronautics and Space Administration
* Government Agency Original Software Designation: GSC-15354-1
* Government Agency Original Software Title: GEOS-5 GCM Modeling Software
* User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov
* Government Agency Point of Contact for Original Software:
* Dale Hithon, SRA Assistant, (301) 286-2691
*
* +-======-+
***************************************************************************************
* $Id: rmean.gs,v 1.2 2013/05/09 18:16:58 ltakacs Exp $
* Copyright (C) 2004 Bin Guan.
* Distributed under GNU/GPL.
***************************************************************************************
function rmean(arg)
*
* Calculate running mean of a time series.
*
* NOTE: Any value for arg5 will disable running mean
***************************************************************************************
arg5=subwrd(arg,5)
input=subwrd(arg,1)
arg2 =subwrd(arg,2)
if(arg5 = '')
arg2 =subwrd(arg,2)
else
arg2 = -0
endif
if(arg2 = '')
usage()
return
endif
if(arg5 = '')
arg3=subwrd(arg,3)
else
arg3 = 0
endif
if(!valnum(arg3))
window=arg2
tminus=math_int(window/2)
tplus=window-tminus-1
output=arg3
else
tminus=-arg2
tplus=arg3
output=subwrd(arg,4)
endif
if(output = '')
output=display
endif
tt=tminus+tplus+1
'rmntmp='input
if(output='display'|output='DISPLAY')
'd tloop(ave(rmntmp,t-'tminus',t+'tplus'))'
else
'define 'output' = tloop(ave(rmntmp,t-'tminus',t+'tplus'))'
endif
'undefine rmntmp'
return
***************************************************************************************
function usage()
*
* Print usage information.
*
say ' Running mean of a time series.'
say ''
say ' USAGE 1: rmean [