@BeginModule
@NewPage
@Name      = Hourpctl
@Title     = Hourly percentile values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile1 ifile2 ifile3 ofile
@Operators = hourpctl

@BeginDescription
This module computes percentiles over all time steps in @file{ifile1}
of the same hour.
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
hourmin and hourmax operations, respectively.
The date information for a time step in @file{ofile} is the date of the
last contributing time step in @file{ifile1}.
@EndDescription
@EndModule


@BeginOperator_hourpctl
@Title     = Hourly percentiles
@Parameter = p

@BeginDescription
@IfMan
For every adjacent sequence t_1, ...,t_n of time steps of the same hour, it is

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


@BeginParameter
@Item = p
INTEGER  Percentile number in {1, ..., 99}
@EndParameter


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


@BeginExample
To compute the hourly 90th percentile of a time series, use:
@BeginVerbatim
   cdo hourmin ifile minfile
   cdo hourmax ifile maxfile
   cdo hourpctl,90 ifile minfile maxfile ofile
@EndVerbatim
Or shorter using operator piping:
@BeginVerbatim
   cdo hourpctl,90 ifile -hourmin ifile -hourmax ifile ofile
@EndVerbatim
@EndExample
