@BeginModule
@Name      = Timselpctl
@Title     = Time range percentile values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile1 ifile2 ifile3 ofile
@Operators = timselpctl

@BeginDescription
This operator computes percentile values over a selected number of timesteps in @file{ifile1}.
The algorithm uses histograms with minimum and maximum bounds given in @file{ifile2} and @file{ifile3},
respectively. The default number of histogram bins is 101. The default can be overridden by setting the
environment variable @env{CDO_PCTL_NBINS} to a different value. The files @file{ifile2} and @file{ifile3} 
should be the result of corresponding @mod{timselmin} and @mod{timselmax} operations, respectively.
The time stamp in @file{ofile} is from the middle contributing timestep of @file{ifile1}.
@EndDescription
@EndModule


@BeginOperator_timselpctl
@Title     = Time range percentiles
@Parameter = p nsets [noffset] [nskip]

@BeginDescription
@IfMan
For every adjacent sequence t1, ...., tn of timesteps of the same 
selected time range it is

o(t,x) = pth percentile {i(t',x), t1 < t' <= tn}
@EndifMan
@IfDoc
\vspace*{1mm}
For every adjacent sequence \begin{math}t_1, ...,t_n\end{math} of timesteps of the same 
selected time range it is: \\
\vspace*{1mm}

@BeginMath
o(t,x) = \mbox{\bf pth percentile} \{i(t',x), t_1 < t' \le t_n\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = p
FLOAT    Percentile number in {0, ..., 100}
@Item = nsets
INTEGER  Number of input timesteps for each output timestep 
@Item = noffset
INTEGER  Number of input timesteps skipped before the first timestep range (optional)
@Item = nskip
INTEGER  Number of input timesteps skipped between timestep ranges (optional)
@EndParameter


@BeginEnvironment
@Item = CDO_PCTL_NBINS
Sets the number of histogram bins. The default number is 101.
@EndEnvironment
