@BeginModule
@NewPage
@Name      = Runstat
@Title     = Running statistical values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile ofile
@Operators = runmin runmax runsum runmean runavg runstd runstd1 runvar runvar1

@BeginDescription
This module computes running statistical values over a selected number of timesteps. Depending on 
the chosen operator the minimum, maximum, sum, average, variance or standard deviation of a selected 
number of consecutive timesteps read from @file{ifile} is written to @file{ofile}. 
The date information in @file{ofile} is the date of the middle contributing timestep in @file{ifile}.
@EndDescription
@EndModule


@BeginOperator_runmin
@Title     = Running minimum
@Parameter = nts

@BeginDescription
@IfMan
o(t+(nts-1)/2,x) = min{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf min}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runmax
@Title     = Running maximum
@Parameter = nts

@BeginDescription
@IfMan
o(t+(nts-1)/2,x) = max{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf max}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runsum
@Title     = Running sum
@Parameter = nts

@BeginDescription
@IfMan
o(t+(nts-1)/2,x) = sum{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf sum}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runmean
@Title     = Running mean
@Parameter = nts

@BeginDescription
@IfMan
o(t+(nts-1)/2,x) = mean{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf mean}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runavg
@Title     = Running average
@Parameter = nts

@BeginDescription
@IfMan
o(t+(nts-1)/2,x) = avg{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf avg}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runvar
@Title     = Running variance
@Parameter = nts

@BeginDescription
Divisor is n. 

@IfMan
o(t+(nts-1)/2,x) = var{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf var}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runvar1
@Title     = Running variance
@Parameter = nts

@BeginDescription
Divisor is (n-1). 

@IfMan
o(t+(nts-1)/2,x) = var1{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf var1}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runstd
@Title     = Running standard deviation
@Parameter = nts

@BeginDescription
Divisor is n. 

@IfMan
o(t+(nts-1)/2,x) = std{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf std}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_runstd1
@Title     = Running standard deviation
@Parameter = nts

@BeginDescription
Divisor is (n-1). 

@IfMan
o(t+(nts-1)/2,x) = std1{i(t,x), i(t+1,x), ..., i(t+nts-1,x)}
@EndifMan
@IfDoc
@BeginMath
o(t+(nts-1)/2,x) = \mbox{\bf std1}\{i(t,x), i(t+1,x), ..., i(t+nts-1,x)\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = nts
INTEGER  Number of timesteps
@EndParameter


@BeginEnvironment
@Item = RUNSTAT_DATE
Sets the date information in ofile to the "first", "last" or "middle" contributing
timestep in ifile.
@EndEnvironment


@BeginExample
To compute the running mean over 9 timesteps use:
@BeginVerbatim
   cdo runmean,9 ifile ofile
@EndVerbatim
@EndExample
