The kmo_wave_cal recipe
===============================================================

.. data:: kmo_wave_cal

Synopsis
--------

Create a calibration frame encoding the spectral position (i.e. wavelength) of each pixel on the detector.

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

This recipe creates the wavelength calibration frame needed for all three
detectors. It must be called after the kmo_flat recipe, which generates the
two spatial calibration frames needed in this recipe. As input a lamp-on frame,
a lamp-off frame, the spatial calibration frames and the list with the
reference arclines are required.An additional output frame is the resampled image of the reconstructed arc
frame. All slitlets of all IFUs are aligned one next to the other. This frame
serves for quality control. One can immediately see if the calibration was
successful.

The lists of reference arclines are supposed to contain the lines for both
available calibration arc-lamps, i.e. Argon and Neon. The list is supposed to
be a F2L KMOS FITS file with three columns:
1. Reference wavelength
2. Relative strength
3. String either containing “Ar” or “Ne”
The recipe extracts, based on the header keywords, either the applying argon
and/or neon emission lines. Below are the plots of the emission lines for both
argon and neon. The marked lines are the ones used for wavelength calibration.


Furthermore frames can be provided for several rotator angles. In this case
the resulting calibration frames for each detector are repeatedly saved as 
extension for every angle.


Input files
^^^^^^^^^^^^
::

   DO                    KMOS                                                  
   category              Type   Explanation                    Required #Frames
   --------              -----  -----------                    -------- -------
   ARC_ON                RAW    Arclamp-on exposure                Y        >=1
   ARC_OFF               RAW    Arclamp-off exposure               Y          1
   XCAL                  F2D    x calibration frame                Y          1
   YCAL                  F2D    y calibration frame                Y          1
   ARC_LIST              F2L    List of arclines                   Y          1
   FLAT_EDGE             F2L    Fitted edge parameters             Y          1
   REF_LINES             F2L    Reference line table               Y          1
   WAVE_BAND             F2L    Table with start-/end-wavelengths  Y          1

Output files
^^^^^^^^^^^^
::

   DO                    KMOS
   category              Type   Explanation
   --------              -----  -----------
   LCAL                  F2D    Wavelength calibration frame
                                (3 Extensions)
   DET_IMG_WAVE          F2D    reconstructed arclamp-on exposure
                                (4 extensions: 3 detector images + 
                                the arclines list table)


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

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

   Create an object for the recipe kmo_wave_cal.

::

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

Parameters
----------

.. py:attribute:: kmo_wave_cal.param.order

    The polynomial order to use for the fit of the wavelength solution. 0:  (default) The appropriate order is chosen automatically depending on  the waveband. Otherwise an order of 6 is recommended, except for IZ-  band, there order 4 should be used (long; default: 0) [default=0].
.. py:attribute:: kmo_wave_cal.param.dev_flip

    Set this parameter to TRUE if the wavelengths are ascending on the  detector from top to bottom. (bool; default: False) [default=False].
.. py:attribute:: kmo_wave_cal.param.dev_disp

    The expected dispersion of the wavelength in microns/pixel. If the  default isn't changed it will automatically be selected upon header  keywords. (float; default: -1.0) [default=-1.0].
.. py:attribute:: kmo_wave_cal.param.suppress_extension

    Suppress arbitrary filename extension.(TRUE (apply) or FALSE (don't  apply) (bool; default: False) [default=False].
.. py:attribute:: kmo_wave_cal.param.b_samples

    The number of samples in wavelength for the reconstructed cube (long;  default: 2048) [default=2048].
.. py:attribute:: kmo_wave_cal.param.b_start

    The lowest wavelength [um] to take into account when reconstructing  (default of -1 sets the proper value for the actual band  automatically) (float; default: -1.0) [default=-1.0].
.. py:attribute:: kmo_wave_cal.param.b_end

    The highest wavelength [um] to take into account when reconstructing  (default of -1 sets the proper value for the actual band  automatically) (float; default: -1.0) [default=-1.0].


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

::

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

   kmo_wave_cal.param.order = 0
   kmo_wave_cal.param.dev_flip = False
   kmo_wave_cal.param.dev_disp = -1.0
   kmo_wave_cal.param.suppress_extension = False
   kmo_wave_cal.param.b_samples = 2048
   kmo_wave_cal.param.b_start = -1.0
   kmo_wave_cal.param.b_end = -1.0


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

::

   import cpl
   kmo_wave_cal = cpl.Recipe("kmo_wave_cal")
   [...]
   res = kmo_wave_cal( ..., param = {"order":0, "dev_flip":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 `Alex Agudo Berbel <kmos-spark@mpe.mpg.de>`_. Alternatively, you may 
send a report to the `ESO User Support Department <usd-help@eso.org>`_.

Copyright
---------

This file is part of the KMOS 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, 51 Franklin Street, Suite 500, Boston, MA  02110-1335  USA

.. codeauthor:: Alex Agudo Berbel <kmos-spark@mpe.mpg.de>
