The sinfo_rec_mflat recipe
===============================================================

.. data:: sinfo_rec_mflat

Synopsis
--------

Master flat determination

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

This recipe reduce normal raw flat fields.

The input files are a set of flat fields with tag FLAT_LAMP
optionally one may have in input also several bad pixel maps to be coadded.

The main products are a master flat field (PRO.CATG=MASTER_FLAT_LAMP) image
a bad pixel map (PRO.CATG=BP_MAP_NO), a master bad pixel map (PRO.CATG=MASTER_BP_MAP) resulting by the coaddition
of all bad pixel maps.



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

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

   Create an object for the recipe sinfo_rec_mflat.

::

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

Parameters
----------

.. py:attribute:: sinfo_rec_mflat.param.gen_overpar

    Overwrite DRS ini parameters:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_mflat.param.lc_sw

    Correct for bad lines introduced by instrument software:  (bool;  default: False) [default=False].
.. py:attribute:: sinfo_rec_mflat.param.lc_kappa

    Kappa sigma value (long; default: 18) [default=18].
.. py:attribute:: sinfo_rec_mflat.param.lc_filt_rad

    Filtering radii applied during median filter. Should be small (long;  default: 3) [default=3].
.. py:attribute:: sinfo_rec_mflat.param.product_density

    Density of pipeline products: 0 (low), 1 (low+skycor), 2 (med-QC), 3  (high-debug+skycor) (long; default: 2) [default=2].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_s_factor

    Threshold Sigma Factor: to remove the column intensity tilt only  pixels which lie within a defined noiselimit are used to fit a  straight line (float; default: 5.0) [default=5.0].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_method_ind

    Bad pixel Method Index1: median of nearest neighbors,2: absolute  distances check, 3: mean of nearest spectral neighbors (long; default:  1) [default=1].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_fct

    Factor: if |pixel - median| > factor * standard deviation -> then the  pixel value is replaced by the median of the 8 nearest neighbors  (float; default: 10.0) [default=10.0].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_it

    Iterations: number of iterations to of median filtering to find bad  pixel clusters (long; default: 8) [default=8].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_lo_rej

    low_rejection: percentage of rejected low intensity pixels before  averaging (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_hi_rej

    high_rejection: percentage of rejected high intensity pixels before  averaging (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_llx

    llx: to compute image statistics on a rectangularzone of the image the  coordinates of the rectangle are needed:lower left x coordinate (long;  default: 270) [default=270].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_lly

    lly: to compute image statistics on a rectangularzone of the image the  coordinates of the rectangle are needed:lower left y coordinate (long;  default: 1000) [default=1000].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_urx

    urx: to compute image statistics on a rectangularzone of the image the  coordinates of the rectangle are needed:upper right x coordinate  (long; default: 310) [default=310].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_ury

    ury: to compute image statistics on a rectangularzone of the image the  coordinates of the rectangle are needed:upper right y coordinate  (long; default: 1200) [default=1200].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_thr_ind

    Threshold Index: indicator that indicates if the values beyond a  threshold deviation from the mean are flagged as bad pixels (bool;  default: True) [default=True].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_mean_fct

    Mean Factor: factor to the clean standard deviation to define the  threshold deviation from the clean mean (float; default: 100.0) [default=100.0].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_min_cut

    the minimum value of real data (float; default: 0.0) [default=0.0].
.. py:attribute:: sinfo_rec_mflat.param.bp_norm_max_cut

    the minimum value of real data (float; default: 50000.0) [default=50000.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_lo_rej

    lower rejection: percentage of rejected low intensity pixels before  averaging (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_hi_rej

    high rejection: percentage of rejected high intensity pixels before  averaging (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_interpol_index

    Interpolation index switch: indicator if the bad pixels of the  flatfield should be interpolated (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_max_rad

    Max Rad: maximal pixel distance from bad pixel to take valid pixels  (long; default: 4) [default=4].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_bad_ind

    indicator if a bad pixel mask should be generated or not (bool;  default: False) [default=False].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_sigma_factor

    Sigma Factor: factor of the sigma noise limit; to remove the column  intensity tilt only pixels which lie within a defined noise limit are  used to fit a straight line (float; default: 5.0) [default=5.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_factor

    Factor: if |pixel - median| > factor * standard deviation -> then the  pixel value is replaced by the median of the 8 nearest neighbors  (float; default: 3.0) [default=3.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_iterations

    Iterations: number of iterations to of median filtering to find bad  pixel clusters (long; default: 8) [default=8].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_bad_lo_rej

    low rejection: Percentage for bad pixel low rejection (float; default:  10.0) [default=10.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_bad_hi_rej

    high rejection: Percentage for bad pixel high rejection (float;  default: 10.0) [default=10.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_llx

    Lower Lext X corner (long; default: 1350) [default=1350].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_lly

    Lower Lext Y corner (long; default: 1000) [default=1000].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_rrx

    Upper right X corner (long; default: 1390) [default=1390].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_ury

    Upper right Y corner (long; default: 1200) [default=1200].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_tresh_ind

    Treshold index:  (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_mean_factor

    Mean Factor: factor to the clean standard deviation to define the  threshold deviation from the clean mean (float; default: 10.0) [default=10.0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmin1

    qc_fpn_xmin1 (long; default: 512) [default=512].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmax1

    qc_fpn_xmax1 (long; default: 1536) [default=1536].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymin1

    qc_fpn_ymin1 (long; default: 512) [default=512].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymax1

    qc_fpn_ymax1 (long; default: 1536) [default=1536].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmin2

    qc_fpn_xmin2 (long; default: 1350) [default=1350].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmax2

    qc_fpn_xmax2 (long; default: 1390) [default=1390].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymin2

    qc_fpn_ymin2 (long; default: 1000) [default=1000].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymax2

    qc_fpn_ymax2 (long; default: 1200) [default=1200].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_thresh_min

    qc_thresh_min (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_mflat.param.lamp_flats_qc_thresh_max

    qc_thresh_max (long; default: 49000) [default=49000].


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

::

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

   sinfo_rec_mflat.param.gen_overpar = True
   sinfo_rec_mflat.param.lc_sw = False
   sinfo_rec_mflat.param.lc_kappa = 18
   sinfo_rec_mflat.param.lc_filt_rad = 3
   sinfo_rec_mflat.param.product_density = 2
   sinfo_rec_mflat.param.bp_norm_s_factor = 5.0
   sinfo_rec_mflat.param.bp_norm_method_ind = 1
   sinfo_rec_mflat.param.bp_norm_fct = 10.0
   sinfo_rec_mflat.param.bp_norm_it = 8
   sinfo_rec_mflat.param.bp_norm_lo_rej = 0.1
   sinfo_rec_mflat.param.bp_norm_hi_rej = 0.1
   sinfo_rec_mflat.param.bp_norm_llx = 270
   sinfo_rec_mflat.param.bp_norm_lly = 1000
   sinfo_rec_mflat.param.bp_norm_urx = 310
   sinfo_rec_mflat.param.bp_norm_ury = 1200
   sinfo_rec_mflat.param.bp_norm_thr_ind = True
   sinfo_rec_mflat.param.bp_norm_mean_fct = 100.0
   sinfo_rec_mflat.param.bp_norm_min_cut = 0.0
   sinfo_rec_mflat.param.bp_norm_max_cut = 50000.0
   sinfo_rec_mflat.param.lamp_flats_lo_rej = 0.1
   sinfo_rec_mflat.param.lamp_flats_hi_rej = 0.1
   sinfo_rec_mflat.param.lamp_flats_interpol_index = False
   sinfo_rec_mflat.param.lamp_flats_max_rad = 4
   sinfo_rec_mflat.param.lamp_flats_bad_ind = False
   sinfo_rec_mflat.param.lamp_flats_sigma_factor = 5.0
   sinfo_rec_mflat.param.lamp_flats_factor = 3.0
   sinfo_rec_mflat.param.lamp_flats_iterations = 8
   sinfo_rec_mflat.param.lamp_flats_bad_lo_rej = 10.0
   sinfo_rec_mflat.param.lamp_flats_bad_hi_rej = 10.0
   sinfo_rec_mflat.param.lamp_flats_llx = 1350
   sinfo_rec_mflat.param.lamp_flats_lly = 1000
   sinfo_rec_mflat.param.lamp_flats_rrx = 1390
   sinfo_rec_mflat.param.lamp_flats_ury = 1200
   sinfo_rec_mflat.param.lamp_flats_tresh_ind = False
   sinfo_rec_mflat.param.lamp_flats_mean_factor = 10.0
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmin1 = 512
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmax1 = 1536
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymin1 = 512
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymax1 = 1536
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmin2 = 1350
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_xmax2 = 1390
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymin2 = 1000
   sinfo_rec_mflat.param.lamp_flats_qc_fpn_ymax2 = 1200
   sinfo_rec_mflat.param.lamp_flats_qc_thresh_min = 0
   sinfo_rec_mflat.param.lamp_flats_qc_thresh_max = 49000


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

::

   import cpl
   sinfo_rec_mflat = cpl.Recipe("sinfo_rec_mflat")
   [...]
   res = sinfo_rec_mflat( ..., param = {"gen_overpar":True, "lc_sw":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 `Andrea Modigliani <Andrea.Modigliani@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 SINFONI Instrument Pipeline
Copyright (C) 2002,2003 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:: Andrea Modigliani <Andrea.Modigliani@eso.org>
