Description
===========
At its basic level this step flat-fields an input science data set by dividing
by a flat-field reference image. In particular, the SCI array from the
flat-field reference file is divided into both the SCI and ERR arrays of the
science data set, and the flat-field DQ array is combined with the science DQ
array using a bitwise OR operation.

Upon completion of the step, the step status keyword "S_FLAT" gets set
to "COMPLETE" in the output science data.

Imaging Data
------------
Imaging data use a straight-forward approach that involves applying a single
flat-field reference file to the science image. The processing steps are:

- Find pixels that have a value of NaN or zero in the FLAT reference file
  SCI array and set their DQ values to "NO_FLAT_FIELD."

- Reset the values of pixels in the flat that have DQ="NO_FLAT_FIELD" to
  1.0, so that they have no effect when applied to the science data.

- Apply the flat by dividing it into the science exposure SCI and ERR arrays.

- Propagate the FLAT reference file DQ values into the science exposure
  DQ array using a bitwise OR operation.

Error Propagation
-----------------
The VAR_POISSON and VAR_RNOISE variance arrays of the science exposure
are divided by the square of the flat-field value for each pixel.
A flat-field variance array, VAR_FLAT, is created from the science exposure
and flat-field reference file data using the following formula:

.. math::
   VAR\_FLAT = ( SCI_{science}^{2} / SCI_{flat}^{2} ) * ERR_{flat}^{2}

The total ERR array in the science exposure is updated as the square root
of the quadratic sum of VAR_POISSON, VAR_RNOISE, and VAR_FLAT.