@BeginModule
@NewPage
@Name      = Compc
@Title     = Comparison of a field with a constant
@Section   = Comparison
@Class     = Comparison
@Arguments = ifile ofile
@Operators = eqc nec lec ltc gec gtc

@BeginDescription
This module compares all fields of a dataset with a constant. The resulting
field is a mask containing 1 if the comparison is true and 0 if not.
The type of comparison depends on the actual operator.
@EndDescription
@EndModule


@BeginOperator_eqc
@Title     = Equal constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) EQ c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) NE c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) = \mbox{c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}      \\
  0   & \mbox{if} \;\; i(t,x) \neq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_nec
@Title     = Not equal constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) NE c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) EQ c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) \neq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
  0   & \mbox{if} \;\; i(t,x) = \mbox{\sl c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_lec
@Title     = Less equal constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) LE c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) GT c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) \leq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
  0   & \mbox{if} \;\; i(t,x) > \mbox{\sl c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_ltc
@Title     = Less than constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) LT c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) GE c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) < \mbox{\sl c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
  0   & \mbox{if} \;\; i(t,x) \geq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_gec
@Title     = Greater equal constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) GE c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) LT c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) \geq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
  0   & \mbox{if} \;\; i(t,x) < \mbox{\sl c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_gtc
@Title     = Greater than constant
@Parameter = c

@BeginDescription
@IfMan
          /   1   if i(t,x) GT c     AND  i(t,x),c NE miss
o(t,x) = <    0   if i(t,x) LE c     AND  i(t,x),c NE miss
          \  miss if i(t,x) EQ miss  OR   c EQ miss
@EndifMan
@IfDoc
@BeginMath
o(t,x) = \left\{
\begin{array}{cll}
  1   & \mbox{if} \;\; i(t,x) > \mbox{\sl c}    & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
  0   & \mbox{if} \;\; i(t,x) \leq \mbox{\sl c} & \wedge \;\; i(t,x), \mbox{\sl c} \neq \mbox{miss}  \\
 \mbox{miss} & \mbox{if} \;\; i(t,x) = \mbox{miss} & \vee   \;\; \mbox{\sl c} = \mbox{miss}          \\
\end{array}   \right.
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = c
FLOAT  Constant
@EndParameter


@BeginExample
To create a mask containing 1 if the field element is greater than 273.15 and 0 if not use:
@BeginVerbatim
   cdo gtc,273.15 ifile ofile
@EndVerbatim
@EndExample
