@BeginModule
@NewPage
@Name      = Ydaypctl
@Title     = Multi-year daily percentile values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile1 ifile2 ifile3 ofile
@Operators = ydaypctl

@BeginDescription
This operator writes a certain percentile of each day of year in @file{ifile1} to @file{ofile}.
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{ydaymin} and @mod{ydaymax} operations, respectively.
The date information in an output field is the date of the last
contributing input field.
@EndModule


@BeginOperator_ydaypctl
@Title     = Multi-year daily percentiles
@Parameter = p

@BeginDescription
@IfMan

o(001,x) = pth percentile {i(t,x), day(i(t)) = 001}
                 ...
o(366,x) = pth percentile {i(t,x), day(i(t)) = 366}
@EndifMan
@IfDoc
\vspace*{3mm}

@BeginMath
\begin{array}{c}
o(\mbox{001},x) = \mbox{\bf pth percentile} \{i(t,x), \mbox{day}(i(t)) = \mbox{001}\} \\
\vdots \\
o(\mbox{366},x) = \mbox{\bf pth percentile} \{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
\end{array}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = p
FLOAT  Percentile number in {0, ..., 100}
@EndParameter


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


@BeginExample
To compute the daily 90th percentile over all input years use:
@BeginVerbatim
   cdo ydaymin ifile minfile
   cdo ydaymax ifile maxfile
   cdo ydaypctl,90 ifile minfile maxfile ofile
@EndVerbatim
Or shorter using operator piping:
@BeginVerbatim
   cdo ydaypctl,90 ifile -ydaymin ifile -ydaymax ifile ofile
@EndVerbatim
@EndExample
