The sinfo_rec_wavecal recipe
===============================================================

.. data:: sinfo_rec_wavecal

Synopsis
--------

Wavelength calibration and slitpos determination

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

This recipe performs wavelength calibration.

The input files are on/off arc lamp frames with tag WAVE_LAMP
Master calibration frame input is:
A corresponding (band) reference line table with tag REF_LINE_ARC
A corresponding (band) distortion table with tag DISTORTION
A corresponding (band,preoptic) master flat with tag MASTER_FLAT_LAMP
A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP
If wcal-estimate_ind=TRUE, a corresponding (band,preoptics) slitlet position
guess table SLIT_POS_GUESS (for example a copy of the SLIT_POS product)
If wcal-calib_indicator=FALSE, a corresponding (band,preoptics) parabolic 
fit coefficients table WAVE_COEF_SLIT
If sinfoni.wavecal.slitpos_boostrap_switch=FALSE 
(wcal-calib-slitpos_bootstrap=0),
a corresponding (band,preoptics) slitlets position table with tag SLIT_POS
The main products are:
The master flat field corrected for distortions 
(PRO.CATG=MFLAT_STACKED_DIST)
The arc lamp frames stacked (PRO.CATG=WAVE_LAMP_STACKED)
The wavelength map (PRO.CATG=WAVE_MAP)
The slitlet position table (PRO.CATG=SLIT_POS)
A parabolic fit coefficients table (PRO.CATG=WAVE_COEF_SLIT)
Parameters relative to arc lamp line fit: (PRO.CATG=WAVE_FIT_PARAMS)
Information on relevant parameters can be found with
esorex --params sinfo_rec_wavecal
esorex --help sinfo_rec_wavecal


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

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

   Create an object for the recipe sinfo_rec_wavecal.

::

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

Parameters
----------

.. py:attribute:: sinfo_rec_wavecal.param.gen_overpar

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    qc_thresh_max (long; default: 49000) [default=49000].
.. py:attribute:: sinfo_rec_wavecal.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_wavecal.param.wcal_slitpos_bootstrap

    Switch to get a new slitpos without a reference:  (bool; default:  False) [default=False].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_calib_indicator

    Calib Indicator: FALSE: if the dispersion relation is already known,  the routine can jump to the sinfo_waveMap section TRUE: if the  dispersion relation must first be determined (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_min_diff

    Minimum Of Difference: minimum difference of mean and sinfo_median  column intensity to carry out the cross sinfo_correlation (float;  default: 1.0) [default=1.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_hw

    Half Width: half width of a box within which the line must be placed  (long; default: 7) [default=7].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_sigma

    Sigma: sigma of Gaussian which is convolved with the artificial  spectrum generated using the line list (float; default: 2.0) [default=2.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_fwhm

    FWHM: initial guess value for the fwhm of the Gaussian used for the  line fit (float; default: 2.83) [default=2.83].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_min_amplitude

    Minimum Of Amplitude: of the Gaussian to do the fit (float; default:  5.0) [default=5.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_max_residual

    Maximum Residuals value: beyond this value the fit is rejected (float;  default: 0.5) [default=0.5].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_n_a_coeffs

    Number of A coefficients: number of polynomial coefficients for the  dispersion relation (long; default: 4) [default=4].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_n_b_coeffs

    Number of B coefficients: number of polynomial coefficients for the  polynomial fit of the dispersion coefficients (long; default: 2) [default=2].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_sigma_factor

    Sigma Factor: Factor of the standard deviation of the polynomial  coefficients of the dispersion relation beyond which the coefficients  are not used for the fit (float; default: 1.5) [default=1.5].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_wcoeff_ind

    Write Coefficients Index: indicates if the coefficients should be  written into a file or not (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_par_ind

    Write Parameter Index: indicates if the fit parameters should be  written into a file or not  (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_pixel_dist

    Minimal Slitlets's Distance in spectral direction (long; default: 15) [default=15].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_pixel_tol

    Pixel Tolerance: allowed pixel position tolerance between estimated  and fitted line position (float; default: 5.0) [default=5.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_wave_map_ind

    Wavelength Map Indicator: indicates if the wavelength calibration map  should be generated (TRUE) or not (FALSE) (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_mag_factor

    Magnificator Factor: magnifying factor for the number of pixels in the  columns needed for FFT (long; default: 8) [default=8].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_slit_pos_ind

    Slit Position Indicator: indicates if the fits of the slitlet edge  positions should be carried through or not (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_fit_boltz_ind

    Fit Boltzmann Indicator: indicates if the fits of the slitlet edge  positions is carried trough by using a Boltzmann function as model  function (bool; default: True) [default=True].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_fit_edge_ind

    Fit Edge Indicator: indicates if the fits of the slitlet edge  positions is carried through by using a simple edge function as model  function (bool; default: False) [default=False].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_estimate_ind

    Estimate Indicator: indicates if the fits of the slitlet edge  positions is carried through by using a list of estimated guess  positions in a file (TRUE)or if the initial positions are calculated  automatically (FALSE). The estimation case is more stable (bool;  default: False) [default=False].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_box_len

    Box Length: pixel length of the row box within which the fit is  carried out (long; default: 32) [default=32].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_y_box

    Y Box: half width of a small box in spectral direction within which  the maximal intensity pixel is searched (float; default: 5.0) [default=5.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_diff_toll

    Difference Tolearance: maximal tolerable difference of the resulting  fit positions of the slitlet edges with respect to the expected  positions (float; default: 2.0) [default=2.0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_qc_thresh_min

    qc_thresh_min (long; default: 0) [default=0].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_qc_thresh_max

    qc_thresh_max (long; default: 49000) [default=49000].
.. py:attribute:: sinfo_rec_wavecal.param.wcal_no_coeffs

    number of coefficients for the polynomial interpolation  (long;  default: 3) [default=3].


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

::

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

   sinfo_rec_wavecal.param.gen_overpar = True
   sinfo_rec_wavecal.param.lc_sw = False
   sinfo_rec_wavecal.param.lc_kappa = 18
   sinfo_rec_wavecal.param.lc_filt_rad = 3
   sinfo_rec_wavecal.param.product_density = 2
   sinfo_rec_wavecal.param.stack_lo_rej = 0.1
   sinfo_rec_wavecal.param.stack_hi_rej = 0.1
   sinfo_rec_wavecal.param.stack_flat_ind = True
   sinfo_rec_wavecal.param.stack_mflat_norm_smooth = 0
   sinfo_rec_wavecal.param.stack_mflat_smooth_rad = 16
   sinfo_rec_wavecal.param.stack_mask_ind = 1
   sinfo_rec_wavecal.param.stack_ind_ind = False
   sinfo_rec_wavecal.param.stack_mask_rad = 4
   sinfo_rec_wavecal.param.stack_gauss_ind = False
   sinfo_rec_wavecal.param.stack_khw = 2
   sinfo_rec_wavecal.param.stack_warpfix_ind = True
   sinfo_rec_wavecal.param.stack_warpfix_kernel = "tanh"
   sinfo_rec_wavecal.param.stack_qc_thresh_min = 0
   sinfo_rec_wavecal.param.stack_qc_thresh_max = 49000
   sinfo_rec_wavecal.param.stack_sub_raw_sky = True
   sinfo_rec_wavecal.param.wcal_slitpos_bootstrap = False
   sinfo_rec_wavecal.param.wcal_calib_indicator = True
   sinfo_rec_wavecal.param.wcal_min_diff = 1.0
   sinfo_rec_wavecal.param.wcal_hw = 7
   sinfo_rec_wavecal.param.wcal_sigma = 2.0
   sinfo_rec_wavecal.param.wcal_fwhm = 2.83
   sinfo_rec_wavecal.param.wcal_min_amplitude = 5.0
   sinfo_rec_wavecal.param.wcal_max_residual = 0.5
   sinfo_rec_wavecal.param.wcal_n_a_coeffs = 4
   sinfo_rec_wavecal.param.wcal_n_b_coeffs = 2
   sinfo_rec_wavecal.param.wcal_sigma_factor = 1.5
   sinfo_rec_wavecal.param.wcal_wcoeff_ind = True
   sinfo_rec_wavecal.param.wcal_par_ind = True
   sinfo_rec_wavecal.param.wcal_pixel_dist = 15
   sinfo_rec_wavecal.param.wcal_pixel_tol = 5.0
   sinfo_rec_wavecal.param.wcal_wave_map_ind = False
   sinfo_rec_wavecal.param.wcal_mag_factor = 8
   sinfo_rec_wavecal.param.wcal_slit_pos_ind = True
   sinfo_rec_wavecal.param.wcal_fit_boltz_ind = True
   sinfo_rec_wavecal.param.wcal_fit_edge_ind = False
   sinfo_rec_wavecal.param.wcal_estimate_ind = False
   sinfo_rec_wavecal.param.wcal_box_len = 32
   sinfo_rec_wavecal.param.wcal_y_box = 5.0
   sinfo_rec_wavecal.param.wcal_diff_toll = 2.0
   sinfo_rec_wavecal.param.wcal_qc_thresh_min = 0
   sinfo_rec_wavecal.param.wcal_qc_thresh_max = 49000
   sinfo_rec_wavecal.param.wcal_no_coeffs = 3


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_wavecal = cpl.Recipe("sinfo_rec_wavecal")
   [...]
   res = sinfo_rec_wavecal( ..., 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>
