The hawki_cal_flat recipe
===============================================================

.. data:: hawki_cal_flat

Synopsis
--------

Twillight flat recipe

Description
-----------

hawki_cal_flat -- HAWKĪI imaging flat-field creation from twillight images.

The input of the recipe files listed in the Set Of Frames (sof-file)
must be tagged as:
raw-file.fits FLAT or
Optional inputs are:
bpmdark-file.fits BPM_HOT
dark-file.fits DARK_IM
dark_err-file.fits DARK_ERR
The recipe creates as an output:
hawki_cal_flat_setxx.fits (FLAT_IM): Master flat for filter xx
hawki_cal_flat_err_setxx.fits (FLAT_ERRMAP): Master flat residuals
hawki_cal_flat_bpmflat_setxx.fits (BPM_COLD): BPM from the flat
hawki_cal_flat_stats_setxx.fits (FLAT_STATS): Stats of the individual flats
Optionally it also creates:
hawki_cal_flat_bpm_setxx.fits (BPM): Bad pixel mask combining bpm from dark and flat
hawki_cal_flat_stats_ec_setxx.fits (FLAT_STATS_EVEN_COL): Stats of the individual flats for even columns
hawki_cal_flat_stats_oc_setxx.fits (FLAT_STATS_ODD_COL): Stats of the individual flats for odd columns
hawki_cal_flat_stats_er_setxx.fits (FLAT_STATS_EVEN_ROW): Stats of the individual flats for even rows
hawki_cal_flat_stats_or_setxx.fits (FLAT_STATS_ODD_ROW): Stats of the individual flats for odd rows
Return code:
esorex exits with an error code of 0 if the recipe completes successfully
or 1 otherwise

Constructor
-----------

.. method:: cpl.Recipe("hawki_cal_flat")
   :noindex:

   Create an object for the recipe hawki_cal_flat.

::

   import cpl
   hawki_cal_flat = cpl.Recipe("hawki_cal_flat")

Parameters
----------

.. py:attribute:: hawki_cal_flat.param.zone

    Stats zone (str; default: '1,1,2048,2048') [default="1,1,2048,2048"].
.. py:attribute:: hawki_cal_flat.param.normalise

    Flag to apply the normalisation (bool; default: False) [default=False].
.. py:attribute:: hawki_cal_flat.param.second_pass

    Flag to apply a second pass computation (bool; default: True) [default=True].
.. py:attribute:: hawki_cal_flat.param.sigma_badres

    sigma for detection of bad flat results (float; default: 1.0) [default=1.0].
.. py:attribute:: hawki_cal_flat.param.sigma_bpm

    sigma for detection of bad pixels (float; default: 10.0) [default=10.0].
.. py:attribute:: hawki_cal_flat.param.lowval_bpm

    values of the flat below this will be included in the bpm. In units of  final flat (normalised if normalise is on) (float; default: 0.1) [default=0.1].
.. py:attribute:: hawki_cal_flat.param.highval_bpm

    values of the flat above this will be included in the bpm. In units of  final flat (normalized if normalise is on) (float; default: 10.0) [default=10.0].
.. py:attribute:: hawki_cal_flat.param.select_auto

    Flag to automatically select the good input frames (bool; default:  True) [default=True].
.. py:attribute:: hawki_cal_flat.param.select_auto_max_bins

    Maximum number of frames requested (long; default: 10) [default=10].
.. py:attribute:: hawki_cal_flat.param.select_min_level

    Minimum ADU level for frames selection (str; default: '-1.0') [default="-1.0"].
.. py:attribute:: hawki_cal_flat.param.select_max_level

    Maximum ADU level for frames selection (str; default: '25000') [default="25000"].
.. py:attribute:: hawki_cal_flat.param.select_max_rms

    Maximum RMS for frames selection (str; default: '4000') [default="4000"].
.. py:attribute:: hawki_cal_flat.param.select_min_nframes

    Minimum number of frames requested (long; default: 3) [default=3].
.. py:attribute:: hawki_cal_flat.param.extra_stats

    Request for even/odd column/rows statistics (bool; default: False) [default=False].


The following code snippet shows the default settings for the available 
parameters.

::

   import cpl
   hawki_cal_flat = cpl.Recipe("hawki_cal_flat")

   hawki_cal_flat.param.zone = "1,1,2048,2048"
   hawki_cal_flat.param.normalise = False
   hawki_cal_flat.param.second_pass = True
   hawki_cal_flat.param.sigma_badres = 1.0
   hawki_cal_flat.param.sigma_bpm = 10.0
   hawki_cal_flat.param.lowval_bpm = 0.1
   hawki_cal_flat.param.highval_bpm = 10.0
   hawki_cal_flat.param.select_auto = True
   hawki_cal_flat.param.select_auto_max_bins = 10
   hawki_cal_flat.param.select_min_level = "-1.0"
   hawki_cal_flat.param.select_max_level = "25000"
   hawki_cal_flat.param.select_max_rms = "4000"
   hawki_cal_flat.param.select_min_nframes = 3
   hawki_cal_flat.param.extra_stats = False


You may also set or overwrite some or all parameters by the recipe 
parameter `param`, as shown in the following example:

::

   import cpl
   hawki_cal_flat = cpl.Recipe("hawki_cal_flat")
   [...]
   res = hawki_cal_flat( ..., param = {"zone":"1,1,2048,2048", "normalise":False})


.. seealso:: `cpl.Recipe <http://packages.python.org/python-cpl/recipe.html>`_
   for more information about the recipe object.

Bug reports
-----------

Please report any problems to `Cesar Enrique Garcia Dabo <usd-help@eso.org>`_. Alternatively, you may 
send a report to the `ESO User Support Department <usd-help@eso.org>`_.

Copyright
---------

This file is part of the HAWKI Instrument Pipeline
Copyright (C) 2002,2011 European Southern Observatory

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
MA  02111-1307  USA

.. codeauthor:: Cesar Enrique Garcia Dabo <usd-help@eso.org>
