The visir_util_undistort recipe
===============================================================

.. data:: visir_util_undistort

Synopsis
--------

Correct the distortion in spectral data

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

The files listed in the Set Of Frames (sof-file) must be tagged:
VISIR-chopnod-corrected-file.fits CHOPNOD_CORRECTED
Optionally, a bad pixel map may be provided:
VISIR-bpm-file.fits STATIC_MASK

The product(s) will have a FITS card
'HIERARCH ESO PRO CATG' with a value of:
UNDISTORTED
The recipe default values for the transformation are only valid for spectral data taken in Low resolution mode

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

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

   Create an object for the recipe visir_util_undistort.

::

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

Parameters
----------

.. py:attribute:: visir_util_undistort.param.bkgcorrect

    Cho-nod correct the data (bool; default: True) [default=True].
.. py:attribute:: visir_util_undistort.param.xl

    Coordinate in spatial direction. Together with yl it defines the lower  point of a rectangle containing only skylines for the wavelength shift  detection (long; default: 117) [default=117].
.. py:attribute:: visir_util_undistort.param.yl

    Coordinate in wavelength direction. See xl (long; default: 110) [default=110].
.. py:attribute:: visir_util_undistort.param.xh

    Coordinate in spatial direction. Together with yl it defines the  higher point of a rectangle containing only skylines for the  wavelength shift detection (long; default: 125) [default=125].
.. py:attribute:: visir_util_undistort.param.yh

    Coordinate in wavelength direction. See xh (long; default: 150) [default=150].
.. py:attribute:: visir_util_undistort.param.slit_skew

    Distortion correction: Skew of slit (degrees) (clockwise) (float;  default: 0.52) [default=0.52].
.. py:attribute:: visir_util_undistort.param.spectrum_skew

    Distortion correction: LMR Skew of spectrum (degrees) (counter-  clockwise). Not used in High Resolution (float; default: 1.73) [default=1.73].
.. py:attribute:: visir_util_undistort.param.vert_arc

    Distortion correction: LR Detector vertical curvature (pixel). Reduced  by a factor 4 in MR. Not used in HR A-side. Increased by a factor  115/52 in HR B-side (float; default: -0.8) [default=-0.8].
.. py:attribute:: visir_util_undistort.param.hori_arc

    Distortion correction: LMR Detector horizontal curvature (pixel).  Increased by a factor 1.5 in HR A-side. Reduced by a factor 2 in HR  B-side (float; default: 0.0) [default=0.0].


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

::

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

   visir_util_undistort.param.bkgcorrect = True
   visir_util_undistort.param.xl = 117
   visir_util_undistort.param.yl = 110
   visir_util_undistort.param.xh = 125
   visir_util_undistort.param.yh = 150
   visir_util_undistort.param.slit_skew = 0.52
   visir_util_undistort.param.spectrum_skew = 1.73
   visir_util_undistort.param.vert_arc = -0.8
   visir_util_undistort.param.hori_arc = 0.0


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

::

   import cpl
   visir_util_undistort = cpl.Recipe("visir_util_undistort")
   [...]
   res = visir_util_undistort( ..., param = {"bkgcorrect":True, "xl":117})


.. 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 `Lars Lundin <llundin@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 VISIR Instrument Pipeline
Copyright (C) 2011 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  02111-1307  USA

.. codeauthor:: Lars Lundin <llundin@eso.org>
