@BeginModule
@NewPage
@Name      = Selpctl
@Title     = Time range percentile values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile1 ifile2 ifile3 ofile
@Operators = selpctl

@BeginDescription
This module computes percentile values over a selected number of time
steps 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 100. The default can be overridden by setting the
environment variable CDO_PCTL_NBINS to a different value. The files
@file{ifile2} and @file{ifile3} must be the result of corresponding
selmin and selmax operations, respectively.
The date information for a time step in @file{ofile} is the date of the last 
contributing time step in @file{ifile}.
@EndDescription
@EndModule


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

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

o(t,x) = pth percentile {i(t',x), t1 < t' <= tn}
@EndifMan
@IfDoc
For every adjacent sequence \begin{math}t_1, ...,t_n\end{math} of timesteps of the same 
selected time range, it is: \\
@BeginMath
o(t,x) = \mbox{\bf pth percentile} \{i(t',x), t_1 < t' \le t_n\}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = p
INTEGER  Percentile number in {1, ..., 99}
@Item = nsets
INTEGER  Number of input time steps for each output time step
@Item = noffset
INTEGER  Number of input time steps skipped before the first time step range (optional)
@Item = nskip
INTEGER  Number of input time steps skipped between time step ranges (optional)
@EndParameter


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