The sinfo_rec_pupil recipe
===============================================================

.. data:: sinfo_rec_pupil

Synopsis
--------

Pupil data reduction

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

This recipe performs science data reduction.

The input files are science object and sky frames 
with tags OBJECT_NODDING and SKY_NODDING
Master calibration frames:
A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP
A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP
A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP
A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS
A corresponding (band) distortion table with tag DISTORTION
A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE
The output is an image resulting from the IMA1 op IMA2 where op indicates
A reference table with the position of the 1st column with tag FIRST_COLUMN
Relevant outputs are:
combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)
reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)
An average along Z of the reconstructed cube 
(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)
The bad pixel map associated to the cube 
(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)


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

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

   Create an object for the recipe sinfo_rec_pupil.

::

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

Parameters
----------

.. py:attribute:: sinfo_rec_pupil.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_pupil.param.stack_lo_rej

    lower rejection (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_pupil.param.stack_hi_rej

    higher rejection (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_pupil.param.stack_flat_ind

    Flat Index:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.stack_mflat_norm_smooth

    Normalize master flat to its smoothed value (to remove lamp response  curve). 0 (no smooth). 1 (apply fft filter along y).2 (apply running  median filter along y). (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.stack_mflat_smooth_rad

    Normalization smoothing radii  (long; default: 16) [default=16].
.. py:attribute:: sinfo_rec_pupil.param.stack_mask_ind

    BP Mask Interpolation Switch: indicates if the bad pixel mask should  be applied (1) or not (0)  (long; default: 1) [default=1].
.. py:attribute:: sinfo_rec_pupil.param.stack_ind_ind

    indicates if the bad pixels should be indicated (yes) or interpolated  (no) (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_pupil.param.stack_mask_rad

    Max distance bad-good pix:  (long; default: 4) [default=4].
.. py:attribute:: sinfo_rec_pupil.param.stack_gauss_ind

    Gaussian Convolution Switch:  (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_pupil.param.stack_khw

    Kernel Half Width (long; default: 2) [default=2].
.. py:attribute:: sinfo_rec_pupil.param.stack_warpfix_ind

    Warp Fix Index:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.stack_warpfix_kernel

    Warpfix kernel:  (str; default: 'tanh') [default="tanh"].
.. py:attribute:: sinfo_rec_pupil.param.stack_qc_thresh_min

    qc_thresh_min (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.stack_qc_thresh_max

    qc_thresh_max (long; default: 49000) [default=49000].
.. py:attribute:: sinfo_rec_pupil.param.stack_sub_raw_sky

    indicates if the raw sky frame should be subtracted (TRUE) or (FALSE)  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_aj_method

    Method to reduce autojitter template frames Raw frames are object only  exposures. object-fake_sky pairs are generated. 0: no sky for all  objects  (long; default: 1) [default=1].
.. py:attribute:: sinfo_rec_pupil.param.objnod_scales_sky

    Spatial median (sky) subtraction from cube: (If  autojitter_method==1),indicates if the spatial median of each plane  should be subtracted (TRUE) or not (FALSE) from each cube plane (bool;  default: False) [default=False].
.. py:attribute:: sinfo_rec_pupil.param.objnod_ks_clip

    Kappa-sigma clipping of coadded cube: indicates if a kappa-sigma  clipping should be performed (TRUE) or not (FALSE) on each plane of  the coadded cube (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_kappa

    kappa value for kappa-sigma clipping of coadded cube (float; default:  2.0) [default=2.0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_size_x

    Cube x size: x-pixel size of the final combined data cube,must lie  between 64 and 128. If 0 it is computed automatically (long; default:  0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_size_y

    Cube y size: y-pixel size of the final combined data cube,must lie  between 64 and 128.If 0 it is computed automatically (long; default:  0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_no_coeffs

    number of coefficients for the polynomial interpolation  (long;  default: 3) [default=3].
.. py:attribute:: sinfo_rec_pupil.param.objnod_ns_ind

    Nord South Index Switch: indicates if the slitlet distances are  determined by a north-south-test (TRUE) or slitlet edge fits (FALSE)  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_fine_tune_mtd

    Fine Tuning Method: indicator for the shifting method to use (P:  polynomial interpolation,  S: cubic spline interpolation) (str;  default: 'P') [default="P"].
.. py:attribute:: sinfo_rec_pupil.param.objnod_order

    Fine Tuning polynomial order: order of the polynomial if the  polynomial interpolation shifting method is used. (long; default: 2) [default=2].
.. py:attribute:: sinfo_rec_pupil.param.objnod_lo_rej

    lower rejection: percentage of rejected low value pixels for averaging  the sky spectra (float; default: 10.0) [default=10.0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_hi_rej

    higher rejection: percentage of rejected high value pixels for  averaging the sky spectra (float; default: 10.0) [default=10.0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_tol

    Tolerance: pixel tolerance, this distance tolerance to the diagonal  dividing line is not considered for the sky extraction to be sure to  have a clean sky due to positioning tolerance and crossing through  pixels (long; default: 2) [default=2].
.. py:attribute:: sinfo_rec_pupil.param.objnod_jit_ind

    Jitter Index: jitter mode indicator: TRUE: Auto-Jitter, FALSE: user  defined jitterThe size_x size_y kernel_type parameters are only used  if jitterInd is set to yes, that means in auto-jittering mode! (bool;  default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_kernel_typ

    Kernel Type:the name of the interpolation kernel to shift the single  cubes  to the correct places inside the big combined cube (str;  default: 'tanh') [default="tanh"].
.. py:attribute:: sinfo_rec_pupil.param.objnod_vllx

    Vignetting on llx: pixels vignetted from lower left corner X  coordinate of contributing cubes before coaddition  (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_vlly

    Vignetting on lly: pixels vignetted from lower left corner Y  coordinate of contributing cubes before coaddition  (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_vurx

    Vignetting on urx: pixels vignetted from upper right corner X  coordinate of contributing cubes before coaddition  (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_vury

    Vignetting on ury: pixels vignetted from upper right corner Y  coordinate of contributing cubes before coaddition  (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_fcol

    First column offset:  (float; default: 0.0) [default=0.0].
.. py:attribute:: sinfo_rec_pupil.param.objnod_sky_cor

    Sky residuals correction:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_flux_cor

    Apply flux correction after rebinning:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_pupil.param.objnod_mosaic_max_size

    Maximum allowed size for cubes mosaic is 100*mosaic_max_size  (long;  default: 14196) [default=14196].


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

::

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

   sinfo_rec_pupil.param.product_density = 2
   sinfo_rec_pupil.param.stack_lo_rej = 0.1
   sinfo_rec_pupil.param.stack_hi_rej = 0.1
   sinfo_rec_pupil.param.stack_flat_ind = True
   sinfo_rec_pupil.param.stack_mflat_norm_smooth = 0
   sinfo_rec_pupil.param.stack_mflat_smooth_rad = 16
   sinfo_rec_pupil.param.stack_mask_ind = 1
   sinfo_rec_pupil.param.stack_ind_ind = False
   sinfo_rec_pupil.param.stack_mask_rad = 4
   sinfo_rec_pupil.param.stack_gauss_ind = False
   sinfo_rec_pupil.param.stack_khw = 2
   sinfo_rec_pupil.param.stack_warpfix_ind = True
   sinfo_rec_pupil.param.stack_warpfix_kernel = "tanh"
   sinfo_rec_pupil.param.stack_qc_thresh_min = 0
   sinfo_rec_pupil.param.stack_qc_thresh_max = 49000
   sinfo_rec_pupil.param.stack_sub_raw_sky = True
   sinfo_rec_pupil.param.objnod_aj_method = 1
   sinfo_rec_pupil.param.objnod_scales_sky = False
   sinfo_rec_pupil.param.objnod_ks_clip = True
   sinfo_rec_pupil.param.objnod_kappa = 2.0
   sinfo_rec_pupil.param.objnod_size_x = 0
   sinfo_rec_pupil.param.objnod_size_y = 0
   sinfo_rec_pupil.param.objnod_no_coeffs = 3
   sinfo_rec_pupil.param.objnod_ns_ind = True
   sinfo_rec_pupil.param.objnod_fine_tune_mtd = "P"
   sinfo_rec_pupil.param.objnod_order = 2
   sinfo_rec_pupil.param.objnod_lo_rej = 10.0
   sinfo_rec_pupil.param.objnod_hi_rej = 10.0
   sinfo_rec_pupil.param.objnod_tol = 2
   sinfo_rec_pupil.param.objnod_jit_ind = True
   sinfo_rec_pupil.param.objnod_kernel_typ = "tanh"
   sinfo_rec_pupil.param.objnod_vllx = 0
   sinfo_rec_pupil.param.objnod_vlly = 0
   sinfo_rec_pupil.param.objnod_vurx = 0
   sinfo_rec_pupil.param.objnod_vury = 0
   sinfo_rec_pupil.param.objnod_fcol = 0.0
   sinfo_rec_pupil.param.objnod_sky_cor = True
   sinfo_rec_pupil.param.objnod_flux_cor = True
   sinfo_rec_pupil.param.objnod_mosaic_max_size = 14196


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_pupil = cpl.Recipe("sinfo_rec_pupil")
   [...]
   res = sinfo_rec_pupil( ..., param = {"product_density":2, "stack_lo_rej":0.1})


.. 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>
