The visir_util_repack recipe
===============================================================

.. data:: visir_util_repack

Synopsis
--------

Conversion of raw CUBE2 or BURST images to on- and off-cubes

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

The files listed in the Set Of Frames (sof-file) must be tagged:
VISIR-CUBE2-raw-file.fits CUBE2
or
VISIR-BURST-raw-file.fits BURST
VISIR-BURST-bpm-file.fits STATIC_MASK
For BURST data it will remove planes where the chopper switched from on <-> off based on the timestamps in the header.

The product(s) will have a FITS card
'HIERARCH ESO PRO CATG' with a value of one of:
IMG_REPACKED_A_ON (NodPos: A, ChopPos: on)
IMG_REPACKED_A_OFF (NodPos: A, ChopPos: off)
IMG_REPACKED_B_ON (NodPos: B, ChopPos: on)
IMG_REPACKED_B_OFF (NodPos: B, ChopPos: off)
For CUBE2, the recipe will produce a static bad-pixel map, it will have a FITS card
'HIERARCH ESO PRO CATG' with a value of:
STATIC_MASK

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

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

   Create an object for the recipe visir_util_repack.

::

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

Parameters
----------

.. py:attribute:: visir_util_repack.param.planestart

    Plane number to start repacking from, earlier planes are skipped.  (long; default: 0) [default=0].
.. py:attribute:: visir_util_repack.param.ncycles

    Number of full on-off cycles to repack. <= 0 for all. (long; default:  -1) [default=-1].
.. py:attribute:: visir_util_repack.param.trimlow

    Burst data only. Number of additional planes to cut from before each  plane with chopper movement. (long; default: 0) [default=0].
.. py:attribute:: visir_util_repack.param.trimhigh

    Burst data only. Number of additional planes to cut from after each  plane with chopper movement.  A value of -1 does not skip the plane of  the movement. (long; default: 0) [default=0].
.. py:attribute:: visir_util_repack.param.bkgcorrect

    Output background corrected planes by subtracting chop (on/off) and  nod (A/B) planes  Options:  none: no correction  chop: on - off  chopnod: (Aon - Aoff) - (Bon - Boff) (str; default: 'none') [default="none"].
.. py:attribute:: visir_util_repack.param.normalize

    Normalize planes by DIT (bool; default: True) [default=True].
.. py:attribute:: visir_util_repack.param.compress

    Apply lossless compression on outputfiles. Can only be done for  integer  type results. (bool; default: False) [default=False].


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

::

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

   visir_util_repack.param.planestart = 0
   visir_util_repack.param.ncycles = -1
   visir_util_repack.param.trimlow = 0
   visir_util_repack.param.trimhigh = 0
   visir_util_repack.param.bkgcorrect = "none"
   visir_util_repack.param.normalize = True
   visir_util_repack.param.compress = False


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_repack = cpl.Recipe("visir_util_repack")
   [...]
   res = visir_util_repack( ..., param = {"planestart":0, "ncycles":-1})


.. 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>
