The giwavecalibration recipe
===============================================================

.. data:: giwavecalibration

Synopsis
--------

Compute dispersion solution from an arc-lamp spectrum.

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

For detailed information please refer to the GIRAFFE pipeline user manual.

It is available at http://www.eso.org/pipelines.


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

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

   Create an object for the recipe giwavecalibration.

::

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

Parameters
----------

.. py:attribute:: giwavecalibration.param.remove_bias

    Enable bias removal (bool; default: True) [default=True].
.. py:attribute:: giwavecalibration.param.bsremove_method

    Bias removal method (str; default: 'PROFILE') [default="PROFILE"].
.. py:attribute:: giwavecalibration.param.bsremove_areas

    Bias areas to use (Xl0:Xr0:Yl0:Yr0, ... ,Xln:Xrn:Yln:Yrn) (str;  default: '5:40:0:4095') [default="5:40:0:4095"].
.. py:attribute:: giwavecalibration.param.bsremove_sigma

    Sigma Clipping: sigma threshold factor (float; default: 2.5) [default=2.5].
.. py:attribute:: giwavecalibration.param.bsremove_niter

    Sigma Clipping: maximum number of iterations (long; default: 5) [default=5].
.. py:attribute:: giwavecalibration.param.bsremove_mfrac

    Sigma Clipping: minimum fraction of points accepted/total [0.0..1.0]  (float; default: 0.8) [default=0.8].
.. py:attribute:: giwavecalibration.param.bsremove_xorder

    Order of X polynomial fit (CURVE method only) (long; default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.bsremove_yorder

    Order of Y polynomial fit (CURVE method only) (long; default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.bsremove_xstep

    Sampling step along X (CURVE method only) (long; default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.bsremove_ystep

    Sampling step along Y (CURVE method only) (long; default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.extr_method

    Extraction method: 'SUM', 'HORNE' or 'OPTIMAL' (str; default: 'SUM') [default="SUM"].
.. py:attribute:: giwavecalibration.param.extr_ron

    New bias sigma (RON) value for bias and dark corrected image (float;  default: -1.0) [default=-1.0].
.. py:attribute:: giwavecalibration.param.extr_psfmodel

    PSF profile model: `psfexp', `psfexp2' (str; default: 'psfexp2') [default="psfexp2"].
.. py:attribute:: giwavecalibration.param.extr_psfsigma

    Sigma clippging threshold used for rejecting data points during PSF  fitting (Horne's sigma). It is used to reject bad pixels and cosmics.  (float; default: 7.0) [default=7.0].
.. py:attribute:: giwavecalibration.param.extr_psfniter

    Maximum number of iterations used for fitting the PSF profile. (long;  default: 2) [default=2].
.. py:attribute:: giwavecalibration.param.extr_hewidth

    Horne extraction method: Number of extra pixels added to the fiber  half-width. (long; default: 2) [default=2].
.. py:attribute:: giwavecalibration.param.extr_hmingood

    Horne extraction method: Minimum number of points used for the profile  fit. It sets the lower limit of data points for the pixel rejection.  (long; default: 3) [default=3].
.. py:attribute:: giwavecalibration.param.extr_omfrac

    Optimal extraction method: Minimum fraction of the data points used  for fitting the fiber profiles. It sets the lower limit for the pixel  rejection. (float; default: 0.9) [default=0.9].
.. py:attribute:: giwavecalibration.param.extr_owfactor

    Optimal extraction method: Factor by which the fiber PSF half width is  multiplied. Adjacent spectra within this area are assumed to affect  the spectrum being extracted. (float; default: 3.0) [default=3.0].
.. py:attribute:: giwavecalibration.param.extr_obkgorder

    Optimal extraction method: Order of the polynomial background model,  which is fitted for each wavelength bin along the spatial direction.  (long; default: 2) [default=2].
.. py:attribute:: giwavecalibration.param.wcal_lswidth

    List of window widths [pxl] used for line detection and fit (e.g.  '60,40,15'). (str; default: '10,10,10,10,10') [default="10,10,10,10,10"].
.. py:attribute:: giwavecalibration.param.wcal_lssep

    Factor used to compute the minimum line separation from the window  width. (float; default: 0.9) [default=0.9].
.. py:attribute:: giwavecalibration.param.wcal_lsfxratio

    Selects only lines whose neighbours have a relative intensity less  than 1. / fluxratio. (float; default: 50.0) [default=50.0].
.. py:attribute:: giwavecalibration.param.wcal_lsbright

    Selects lines having an intensity greater or equal to the given  intensity. (float; default: 0.0) [default=0.0].
.. py:attribute:: giwavecalibration.param.wcal_lscount

    Sets the minimum number of lines to select; selected are lines with  the highest nominal intensity. A value of 0 turns this selection off.  If the value is less than 0 the selection is skipped if the line list  does not contain enough lines. (long; default: -80) [default=-80].
.. py:attribute:: giwavecalibration.param.wcal_lswrange

    Selects only lines within the given wavelength range [nm]. (str;  default: '0.,0.') [default="0.,0."].
.. py:attribute:: giwavecalibration.param.wcal_lfmodel

    Line profile model. (str; default: 'psfexp') [default="psfexp"].
.. py:attribute:: giwavecalibration.param.wcal_lfres

    Use optical model residuals for line detection. (str; default: 'auto') [default="auto"].
.. py:attribute:: giwavecalibration.param.wcal_lfthreshold

    Line detection threshold during the line fitting (multiple of bias  sigma) (float; default: 1.0) [default=1.0].
.. py:attribute:: giwavecalibration.param.wcal_lfoffset

    Maximum allowed difference between the fitted and raw line peak  position. (float; default: 10.0) [default=10.0].
.. py:attribute:: giwavecalibration.param.wcal_lfniter

    Line detection fit maximum number of iterations. (long; default: 50) [default=50].
.. py:attribute:: giwavecalibration.param.wcal_lfntest

    Line detection fit maximum number of tests. (long; default: 7) [default=7].
.. py:attribute:: giwavecalibration.param.wcal_lfdchisq

    Line detection fit minimum chi-square difference. (float; default:  0.0001) [default=0.0001].
.. py:attribute:: giwavecalibration.param.wcal_lfreswid

    Line width/resolution width factor. (float; default: 0.5) [default=0.5].
.. py:attribute:: giwavecalibration.param.wcal_lfexpwid

    Exponential line profile exponent; it will not be fitted if it is  larger than 0. (float; default: -3.0) [default=-3.0].
.. py:attribute:: giwavecalibration.param.wcal_soffset

    Initial slit position offsets along the x and y direction and rotation  angle. (str; default: 'setup') [default="setup"].
.. py:attribute:: giwavecalibration.param.wcal_ommodel

    Optical model. (str; default: 'xoptmod2') [default="xoptmod2"].
.. py:attribute:: giwavecalibration.param.wcal_omdir

    Dispersion direction flag. (long; default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.wcal_omsol

    Controls optical model parameter fitting. (bool; default: True) [default=True].
.. py:attribute:: giwavecalibration.param.wcal_omflags

    List of flags defining the set of free parameters used for fitting the  optical model. Possible values are: fcoll, gcam, theta, sdx, sdy, sphi  (str; default: 'sdx,sdy,sphi') [default="sdx,sdy,sphi"].
.. py:attribute:: giwavecalibration.param.wcal_omsslits

    Controls subslit geometry usage in the optical model fit; subslits are  used if set to `true'. (bool; default: False) [default=False].
.. py:attribute:: giwavecalibration.param.wcal_omniter

    Optical model fit maximum number of iterations. (long; default: 50) [default=50].
.. py:attribute:: giwavecalibration.param.wcal_omntest

    Optical model fit maximum number of tests (long; default: 7) [default=7].
.. py:attribute:: giwavecalibration.param.wcal_omdchisq

    Optical model fit minimum chi-square difference. (float; default:  0.0001) [default=0.0001].
.. py:attribute:: giwavecalibration.param.wcal_xwsigma

    PSF width fit sigma clipping factor. (float; default: 1.25) [default=1.25].
.. py:attribute:: giwavecalibration.param.wcal_xwniter

    PSF width fit sigma clipping maximum number of iterations. (long;  default: 10) [default=10].
.. py:attribute:: giwavecalibration.param.wcal_xwmfrac

    PSF width fit sigma clipping minimum fraction of points  accepted/total. (float; default: 0.9) [default=0.9].
.. py:attribute:: giwavecalibration.param.wcal_xworder

    X and Y polynomial orders for PSF x-width Chebyshev fit. (str;  default: '2,2') [default="2,2"].
.. py:attribute:: giwavecalibration.param.wcal_wssigma

    Chebyshev correction sigma clipping factor. (float; default: 150.0) [default=150.0].
.. py:attribute:: giwavecalibration.param.wcal_wsniter

    Chebyshev correction sigma clipping maximum number of iterations  (long; default: 10) [default=10].
.. py:attribute:: giwavecalibration.param.wcal_wsmfrac

    Chebyshev correction sigma clipping minimum fraction of points  accepted/total. (float; default: 0.9) [default=0.9].
.. py:attribute:: giwavecalibration.param.wcal_wsorder

    X and Y polynomial orders for the wavelength solution Chebyshev  correction. (str; default: '6,4') [default="6,4"].
.. py:attribute:: giwavecalibration.param.wcal_rebin

    Rebin extracted arc-lamp spectra. (bool; default: True) [default=True].
.. py:attribute:: giwavecalibration.param.rbin_method

    Method to use : `linear' or `spline' (str; default: 'linear') [default="linear"].
.. py:attribute:: giwavecalibration.param.rbin_xresid

    Use x residuals during rebinning? `true'/`false' (bool; default: True) [default=True].
.. py:attribute:: giwavecalibration.param.rbin_lstep

    Lambda step size, only used if scaling method is 'linear' (float;  default: 0.005) [default=0.005].
.. py:attribute:: giwavecalibration.param.rbin_scmethod

    Scaling method: `log' or `linear' (str; default: 'linear') [default="linear"].
.. py:attribute:: giwavecalibration.param.rbin_size

    Size of output rebinned spectra, 0 means calculate size based on  wavelength range and lambda stepsize (long; default: 0) [default=0].
.. py:attribute:: giwavecalibration.param.rbin_range

    Rebinning range: `setup' or `common' (str; default: 'setup') [default="setup"].
.. py:attribute:: giwavecalibration.param.wcal_slit

    Controls the slit geometry calibration. (bool; default: False) [default=False].
.. py:attribute:: giwavecalibration.param.scal_cniter

    Slit geometry calibration maximum number of iterations. (long;  default: 1) [default=1].
.. py:attribute:: giwavecalibration.param.scal_zmax

    Maximum allowed pixel value. To be effective it must be larger than 0.  (float; default: 10000.0) [default=10000.0].
.. py:attribute:: giwavecalibration.param.scal_cstep

    Cross-correlation step. (float; default: -0.005) [default=-0.005].
.. py:attribute:: giwavecalibration.param.scal_cdomain

    Restricts the cross-correlation to the given domain. (str; default:  '0.,0.') [default="0.,0."].
.. py:attribute:: giwavecalibration.param.scal_rvlimits

    Delta RV limits of the cross-correlation window in km/s. (str;  default: '-200.,200.') [default="-200.,200."].
.. py:attribute:: giwavecalibration.param.scal_rvniter

    Maximum number of iterations used for the RV determination. (long;  default: 3) [default=3].
.. py:attribute:: giwavecalibration.param.scal_rvwfactor

    Data window width factor. The FWHM times this value determines the  window width. (float; default: 1.5) [default=1.5].
.. py:attribute:: giwavecalibration.param.scal_pfniter

    Peak model fit maximum number of iterations. (long; default: 50) [default=50].
.. py:attribute:: giwavecalibration.param.scal_pfntest

    Cross-correlation peak fit maximum number of tests (long; default: 7) [default=7].
.. py:attribute:: giwavecalibration.param.scal_pfdchisq

    Cross-correlation peak fit minimum chi-square difference. (float;  default: 0.0001) [default=0.0001].


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

::

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

   giwavecalibration.param.remove_bias = True
   giwavecalibration.param.bsremove_method = "PROFILE"
   giwavecalibration.param.bsremove_areas = "5:40:0:4095"
   giwavecalibration.param.bsremove_sigma = 2.5
   giwavecalibration.param.bsremove_niter = 5
   giwavecalibration.param.bsremove_mfrac = 0.8
   giwavecalibration.param.bsremove_xorder = 1
   giwavecalibration.param.bsremove_yorder = 1
   giwavecalibration.param.bsremove_xstep = 1
   giwavecalibration.param.bsremove_ystep = 1
   giwavecalibration.param.extr_method = "SUM"
   giwavecalibration.param.extr_ron = -1.0
   giwavecalibration.param.extr_psfmodel = "psfexp2"
   giwavecalibration.param.extr_psfsigma = 7.0
   giwavecalibration.param.extr_psfniter = 2
   giwavecalibration.param.extr_hewidth = 2
   giwavecalibration.param.extr_hmingood = 3
   giwavecalibration.param.extr_omfrac = 0.9
   giwavecalibration.param.extr_owfactor = 3.0
   giwavecalibration.param.extr_obkgorder = 2
   giwavecalibration.param.wcal_lswidth = "10,10,10,10,10"
   giwavecalibration.param.wcal_lssep = 0.9
   giwavecalibration.param.wcal_lsfxratio = 50.0
   giwavecalibration.param.wcal_lsbright = 0.0
   giwavecalibration.param.wcal_lscount = -80
   giwavecalibration.param.wcal_lswrange = "0.,0."
   giwavecalibration.param.wcal_lfmodel = "psfexp"
   giwavecalibration.param.wcal_lfres = "auto"
   giwavecalibration.param.wcal_lfthreshold = 1.0
   giwavecalibration.param.wcal_lfoffset = 10.0
   giwavecalibration.param.wcal_lfniter = 50
   giwavecalibration.param.wcal_lfntest = 7
   giwavecalibration.param.wcal_lfdchisq = 0.0001
   giwavecalibration.param.wcal_lfreswid = 0.5
   giwavecalibration.param.wcal_lfexpwid = -3.0
   giwavecalibration.param.wcal_soffset = "setup"
   giwavecalibration.param.wcal_ommodel = "xoptmod2"
   giwavecalibration.param.wcal_omdir = 1
   giwavecalibration.param.wcal_omsol = True
   giwavecalibration.param.wcal_omflags = "sdx,sdy,sphi"
   giwavecalibration.param.wcal_omsslits = False
   giwavecalibration.param.wcal_omniter = 50
   giwavecalibration.param.wcal_omntest = 7
   giwavecalibration.param.wcal_omdchisq = 0.0001
   giwavecalibration.param.wcal_xwsigma = 1.25
   giwavecalibration.param.wcal_xwniter = 10
   giwavecalibration.param.wcal_xwmfrac = 0.9
   giwavecalibration.param.wcal_xworder = "2,2"
   giwavecalibration.param.wcal_wssigma = 150.0
   giwavecalibration.param.wcal_wsniter = 10
   giwavecalibration.param.wcal_wsmfrac = 0.9
   giwavecalibration.param.wcal_wsorder = "6,4"
   giwavecalibration.param.wcal_rebin = True
   giwavecalibration.param.rbin_method = "linear"
   giwavecalibration.param.rbin_xresid = True
   giwavecalibration.param.rbin_lstep = 0.005
   giwavecalibration.param.rbin_scmethod = "linear"
   giwavecalibration.param.rbin_size = 0
   giwavecalibration.param.rbin_range = "setup"
   giwavecalibration.param.wcal_slit = False
   giwavecalibration.param.scal_cniter = 1
   giwavecalibration.param.scal_zmax = 10000.0
   giwavecalibration.param.scal_cstep = -0.005
   giwavecalibration.param.scal_cdomain = "0.,0."
   giwavecalibration.param.scal_rvlimits = "-200.,200."
   giwavecalibration.param.scal_rvniter = 3
   giwavecalibration.param.scal_rvwfactor = 1.5
   giwavecalibration.param.scal_pfniter = 50
   giwavecalibration.param.scal_pfntest = 7
   giwavecalibration.param.scal_pfdchisq = 0.0001


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

::

   import cpl
   giwavecalibration = cpl.Recipe("giwavecalibration")
   [...]
   res = giwavecalibration( ..., param = {"remove_bias":True, "bsremove_method":"PROFILE"})


.. 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 `Giraffe Pipeline <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 GIRAFFE Instrument Pipeline
 Copyright (C) 2002-2006 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

.. codeauthor:: Giraffe Pipeline <usd-help@eso.org>
