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 in each nod cycle,earlier planes  are skipped. (int; default: 0) [default=0].
.. py:attribute:: visir_util_repack.param.planelimit

    Limit number of processed inputplanes. It will repack until at least  this number of input images have been processed or the full dataset  has been repacked. Always full chop cycles need to be repacked so the  number is adjusted upward to the next multiple of images per chop  cycle.  <= 0 for no limit. (int; default: -1) [default=-1].
.. py:attribute:: visir_util_repack.param.ncycles

    Number of full on-off cycles to repack per nod cycles. <= 0 for all.  (int; 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. (int; 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. (int; 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 output files. Can only be done for  integer type results. (bool; default: False) [default=False].
.. py:attribute:: visir_util_repack.param.lincorrect

    Apply linearity correction. Should only be enabled on high flux  observations, may degrade results otherwise. (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.planelimit = -1
   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
   visir_util_repack.param.lincorrect = 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, "planelimit":-1})


.. seealso:: `cpl.Recipe <https://packages.python.org/python-cpl/recipe.html>`_
   for more information about the recipe object.

Bug reports
-----------

Please report any problems to `Lars Lundin <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 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 <usd-help@eso.org>
