The sinfo_rec_jitter recipe
===============================================================

.. data:: sinfo_rec_jitter

Synopsis
--------

Object or STD star or PSF star 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 or
Telluric standard star frames and sky frames with tags STD and SKY_STD or
PSF standard star and sky frames with tags 
PSF_CALIBRATOR and SKY_PSF_CALIBRATOR
and 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 first 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_jitter")
   :noindex:

   Create an object for the recipe sinfo_rec_jitter.

::

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

Parameters
----------

.. py:attribute:: sinfo_rec_jitter.param.gen_overpar

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

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

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

    Filtering radii applied during median filter. Should be small (long;  default: 3) [default=3].
.. py:attribute:: sinfo_rec_jitter.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_jitter.param.stack_lo_rej

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

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

    Flat Index:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_jitter.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_jitter.param.stack_mflat_smooth_rad

    Normalization smoothing radii  (long; default: 16) [default=16].
.. py:attribute:: sinfo_rec_jitter.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_jitter.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_jitter.param.stack_mask_rad

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

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

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

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

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

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

    qc_thresh_max (long; default: 49000) [default=49000].
.. py:attribute:: sinfo_rec_jitter.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_jitter.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_jitter.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_jitter.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_jitter.param.objnod_kappa

    kappa value for kappa-sigma clipping of coadded cube (float; default:  2.0) [default=2.0].
.. py:attribute:: sinfo_rec_jitter.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_jitter.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_jitter.param.objnod_no_coeffs

    number of coefficients for the polynomial interpolation  (long;  default: 3) [default=3].
.. py:attribute:: sinfo_rec_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.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_jitter.param.objnod_fcol

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

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

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

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

    Starting wavelength for object-sky cross correlation (float; default:  1.4) [default=1.4].
.. py:attribute:: sinfo_rec_jitter.param.skycor_mask_we

    End wavelength for object-sky cross correlation (float; default: 2.5) [default=2.5].
.. py:attribute:: sinfo_rec_jitter.param.skycor_min_frac

    Threshold value for fraction of spatial pixels to be sky (float;  default: 0.8) [default=0.8].
.. py:attribute:: sinfo_rec_jitter.param.skycor_sky_bkg_filter_width

    Width of sky-thermal background pre filter (to remove emission lines  before fitting a Black Body). (long; default: 12) [default=12].
.. py:attribute:: sinfo_rec_jitter.param.skycor_line_hw

    Threshold value for full width in pixels of unresolved emission line.  Lines with FWHM smaller than this value are not considered in the  object-sky cross correlation and in computation of the optimal sky  lines scaling factor (float; default: 4.0) [default=4.0].
.. py:attribute:: sinfo_rec_jitter.param.skycor_scale_method

    Optimal sky lines scaling factor computation method: amoeba fit (0),  maximum likelihood (1)  (long; default: 1) [default=1].
.. py:attribute:: sinfo_rec_jitter.param.skycor_rot_cor

    Computes scaling factor correction due to rotational levels  transitions (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_jitter.param.skycor_fit_obj_noise

    Do Gaussian fit of object noise (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_jitter.param.skycor_niter

    Number of iterations of background fit (long; default: 10) [default=10].
.. py:attribute:: sinfo_rec_jitter.param.skycor_pshift

    Sky spectrum shift towar object (float; default: 0.0) [default=0.0].
.. py:attribute:: sinfo_rec_jitter.param.skycor_llx

    Lower left X defining object spectrum location (long; default: 1) [default=1].
.. py:attribute:: sinfo_rec_jitter.param.skycor_lly

    Lower left Y defining object spectrum location (long; default: 1) [default=1].
.. py:attribute:: sinfo_rec_jitter.param.skycor_urx

    Upper right X defining object spectrum location (long; default: 64) [default=64].
.. py:attribute:: sinfo_rec_jitter.param.skycor_ury

    Upper right Y defining object spectrum location (long; default: 64) [default=64].
.. py:attribute:: sinfo_rec_jitter.param.skycor_sub_thr_bkg_from_obj

    Subtract thermal background contribute from object spectra. Set it to  TRUE if stack-sub_raw_sky is set to FALSE (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_jitter.param.std_star_switch

    Switch to activate spectrum extraction (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_jitter.param.std_star_lo_rej

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

    high rejection (float; default: 0.1) [default=0.1].
.. py:attribute:: sinfo_rec_jitter.param.std_star_fwhm_fct

    Factor to find 2D-Gauss FWHM. The extraction box is:  halfbox_x=halfbox_y=fwhm_factor*(fwhm_x+fwhm_y)*0.5 (float; default:  5.0) [default=5.0].
.. py:attribute:: sinfo_rec_jitter.param.std_star_conv_ind

    Intensity Conversion Index:  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_jitter.param.std_star_compute_eff

    Compute efficiency: TRUE/FALSE (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_jitter.param.std_star_extract

    Extraction Method: simple/optimal (str; default: 'simple') [default="simple"].
.. py:attribute:: sinfo_rec_jitter.param.std_star_pfm

    Object Mask Post Filtering Method: erosion/dilation/closing (str;  default: 'erosion') [default="erosion"].
.. py:attribute:: sinfo_rec_jitter.param.std_star_pfx

    X Size of the post filtering kernel. (long; default: 3) [default=3].
.. py:attribute:: sinfo_rec_jitter.param.std_star_pfy

    Y Size of the post filtering kernel. (long; default: 3) [default=3].
.. py:attribute:: sinfo_rec_jitter.param.psf_switch

    Switch to activate PSF-related (Strehl/Encircled energy) computation  (bool; default: True) [default=True].


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

::

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

   sinfo_rec_jitter.param.gen_overpar = True
   sinfo_rec_jitter.param.lc_sw = False
   sinfo_rec_jitter.param.lc_kappa = 18
   sinfo_rec_jitter.param.lc_filt_rad = 3
   sinfo_rec_jitter.param.product_density = 2
   sinfo_rec_jitter.param.stack_lo_rej = 0.1
   sinfo_rec_jitter.param.stack_hi_rej = 0.1
   sinfo_rec_jitter.param.stack_flat_ind = True
   sinfo_rec_jitter.param.stack_mflat_norm_smooth = 0
   sinfo_rec_jitter.param.stack_mflat_smooth_rad = 16
   sinfo_rec_jitter.param.stack_mask_ind = 1
   sinfo_rec_jitter.param.stack_ind_ind = False
   sinfo_rec_jitter.param.stack_mask_rad = 4
   sinfo_rec_jitter.param.stack_gauss_ind = False
   sinfo_rec_jitter.param.stack_khw = 2
   sinfo_rec_jitter.param.stack_warpfix_ind = True
   sinfo_rec_jitter.param.stack_warpfix_kernel = "tanh"
   sinfo_rec_jitter.param.stack_qc_thresh_min = 0
   sinfo_rec_jitter.param.stack_qc_thresh_max = 49000
   sinfo_rec_jitter.param.stack_sub_raw_sky = True
   sinfo_rec_jitter.param.objnod_aj_method = 1
   sinfo_rec_jitter.param.objnod_scales_sky = False
   sinfo_rec_jitter.param.objnod_ks_clip = True
   sinfo_rec_jitter.param.objnod_kappa = 2.0
   sinfo_rec_jitter.param.objnod_size_x = 0
   sinfo_rec_jitter.param.objnod_size_y = 0
   sinfo_rec_jitter.param.objnod_no_coeffs = 3
   sinfo_rec_jitter.param.objnod_ns_ind = True
   sinfo_rec_jitter.param.objnod_fine_tune_mtd = "P"
   sinfo_rec_jitter.param.objnod_order = 2
   sinfo_rec_jitter.param.objnod_lo_rej = 10.0
   sinfo_rec_jitter.param.objnod_hi_rej = 10.0
   sinfo_rec_jitter.param.objnod_tol = 2
   sinfo_rec_jitter.param.objnod_jit_ind = True
   sinfo_rec_jitter.param.objnod_kernel_typ = "tanh"
   sinfo_rec_jitter.param.objnod_vllx = 0
   sinfo_rec_jitter.param.objnod_vlly = 0
   sinfo_rec_jitter.param.objnod_vurx = 0
   sinfo_rec_jitter.param.objnod_vury = 0
   sinfo_rec_jitter.param.objnod_fcol = 0.0
   sinfo_rec_jitter.param.objnod_sky_cor = True
   sinfo_rec_jitter.param.objnod_flux_cor = True
   sinfo_rec_jitter.param.objnod_mosaic_max_size = 14196
   sinfo_rec_jitter.param.skycor_mask_ws = 1.4
   sinfo_rec_jitter.param.skycor_mask_we = 2.5
   sinfo_rec_jitter.param.skycor_min_frac = 0.8
   sinfo_rec_jitter.param.skycor_sky_bkg_filter_width = 12
   sinfo_rec_jitter.param.skycor_line_hw = 4.0
   sinfo_rec_jitter.param.skycor_scale_method = 1
   sinfo_rec_jitter.param.skycor_rot_cor = False
   sinfo_rec_jitter.param.skycor_fit_obj_noise = False
   sinfo_rec_jitter.param.skycor_niter = 10
   sinfo_rec_jitter.param.skycor_pshift = 0.0
   sinfo_rec_jitter.param.skycor_llx = 1
   sinfo_rec_jitter.param.skycor_lly = 1
   sinfo_rec_jitter.param.skycor_urx = 64
   sinfo_rec_jitter.param.skycor_ury = 64
   sinfo_rec_jitter.param.skycor_sub_thr_bkg_from_obj = False
   sinfo_rec_jitter.param.std_star_switch = True
   sinfo_rec_jitter.param.std_star_lo_rej = 0.1
   sinfo_rec_jitter.param.std_star_hi_rej = 0.1
   sinfo_rec_jitter.param.std_star_fwhm_fct = 5.0
   sinfo_rec_jitter.param.std_star_conv_ind = True
   sinfo_rec_jitter.param.std_star_compute_eff = True
   sinfo_rec_jitter.param.std_star_extract = "simple"
   sinfo_rec_jitter.param.std_star_pfm = "erosion"
   sinfo_rec_jitter.param.std_star_pfx = 3
   sinfo_rec_jitter.param.std_star_pfy = 3
   sinfo_rec_jitter.param.psf_switch = True


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_jitter = cpl.Recipe("sinfo_rec_jitter")
   [...]
   res = sinfo_rec_jitter( ..., 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.Mdigliani@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.Mdigliani@eso.org>
