The flames_obs_scired recipe
===============================================================

.. data:: flames_obs_scired

Synopsis
--------

Reduces a FLAMES science image

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

Fibre & order position determination procedure:

You should feed the recipe with:

- science fibre images (FIB_SCI_RED, FIB_SCI_SIM_RED, FIB_SCI_SIM_RED)
- single fibre images, FIB_ORDEF_(REDL|REDU)
- master bias frames, MASTER_BIAS_(REDL|REDU)
- Fibre order table, FIB_ORDEF_TABLE_(REDL|REDU)
- Slit flatfield common, SLIT_FF_COM_(REDL|REDU)
- Slit flatfield norm, SLIT_FF_NOR_(REDL|REDU)
- Slit flatfield data, SLIT_FF_DTC_(REDL|REDU)
- Slit flatfield sigma, SLIT_FF_SGC_(REDL|REDU)
- Slit flatfield bad pixel, SLIT_FF_BPC_(REDL|REDU)
- Slit flatfield boundary, SLIT_FF_BNC_(REDL|REDU)
- Fibre flatfield common, FIB_FF_COM_(REDL|REDU)
- Fibre flatfield norm, FIB_FF_NOR_(REDL|REDU)
- Fibre flatfield norm sigma, FIB_FF_NSG_(REDL|REDU)

Products are:

- Science fibre info table (FIB_SCI_INFO_TAB)
-   XB_SCI_RAW_(REDL|REDU)
-   ERR_XB_SCI_RAW_(REDL|REDU)
-   WXB_SCI_RAW_(REDL|REDU)
-   ERR_WXB_SCI_RAW_(REDL|REDU)
-   MWXB_SCI_RAW_(REDL|REDU)
-   ERR_MWXB_SCI_RAW_(REDL|REDU)
-   XB_SCI_(REDL|REDU)
-   ERR_XB_SCI_(REDL|REDU)
-   WXB_SCI_(REDL|REDU)
-   ERR_WXB_SCI_(REDL|REDU)
-   MWXB_SCI_(REDL|REDU)
-   ERR_MWXB_SCI_(REDL|REDU)

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

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

   Create an object for the recipe flames_obs_scired.

::

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

Parameters
----------

.. py:attribute:: flames_obs_scired.param.bias_method

    Bias subtraction method (str; default: 'M') [default="M"].
.. py:attribute:: flames_obs_scired.param.bias_value

    Bias value (only if bias_method = V) (int; default: 200) [default=200].
.. py:attribute:: flames_obs_scired.param.bkg_max_io_win

    Background window number in each full inter order (int; default: 500) [default=500].
.. py:attribute:: flames_obs_scired.param.bkg_xy_win_sz_x

    x maximum size of each background window:  (int; default: 6) [default=6].
.. py:attribute:: flames_obs_scired.param.bkg_xy_win_sz_y

    y maximum size of each background window:  (int; default: 2) [default=2].
.. py:attribute:: flames_obs_scired.param.clean_tmp_products

    Input data format (bool; default: False) [default=False].
.. py:attribute:: flames_obs_scired.param.cor_def_off

    Correlation center offset? (float; default: 0.0) [default=0.0].
.. py:attribute:: flames_obs_scired.param.cor_def_pnt

    Correlation sampling points? (int; default: 25) [default=25].
.. py:attribute:: flames_obs_scired.param.cor_def_rng

    Correlation range size? (float; default: 6.0) [default=6.0].
.. py:attribute:: flames_obs_scired.param.cor_max_fnd

    Find correlation maximum? (str; default: 'Y') [default="Y"].
.. py:attribute:: flames_obs_scired.param.corvel_iter

    Velocity correlation iteration number (SimCal) (int; default: 1) [default=1].
.. py:attribute:: flames_obs_scired.param.cubify_sw

    Cubify switch (str; default: 'N') [default="N"].
.. py:attribute:: flames_obs_scired.param.debug

    Whether or not to save intermediate results to local directory (bool;  default: False) [default=False].
.. py:attribute:: flames_obs_scired.param.drs_base_name

    Base name for science products (str; default: 'fxb') [default="fxb"].
.. py:attribute:: flames_obs_scired.param.drs_ext_w_siz

    Integration window size good: 10 (if fibre deconvolution works fine)  (float; default: 10.0) [default=10.0].
.. py:attribute:: flames_obs_scired.param.drs_k_s_thre

    Kappa sigma threshold (float; default: 10.0) [default=10.0].
.. py:attribute:: flames_obs_scired.param.drs_maxyshift

    Half width of the interval to scan for correlation, when determining y  shift (float; default: 3.0) [default=3.0].
.. py:attribute:: flames_obs_scired.param.ext_method

    Extraction method (str; default: 'opt') [default="opt"].
.. py:attribute:: flames_obs_scired.param.filt_sw

    Filter switch (str; default: 'none') [default="none"].
.. py:attribute:: flames_obs_scired.param.merge

    Order merging method. If 'optimal', the flux in the overlapping region  is set to the (optimally computed, using the uncertainties) average of  single order spectra. If 'sum', the flux in the overlapping region is  computed as the sum of the single order spectra. If flat-fielding is  done, method 'optimal' is recommended, otherwise 'sum'. (str; default:  'optimal') [default="optimal"].
.. py:attribute:: flames_obs_scired.param.merge_delt1

    Order merging left hand (short wavelength) cut. To reduce the amount  of order overlapping regions we allow to cut short and long wavelength  ranges. This may reduce the ripple possibly introduced by the order  merging. Suggested values are: 10 (W<=390), 12 (390<W<=437,  520<W<=564), 14 (437<W<=520, 564<W<860), 4 (W>=860)  (float; default:  -1.0) [default=-1.0].
.. py:attribute:: flames_obs_scired.param.merge_delt2

    Order merging right hand (long wavelength) cut. To reduce the amount  of order overlapping regions we allow to cut short and long wavelength  ranges. This may reduce the ripple possibly introduced by the order  merging. Suggested values is 4 for W<860, else 0 (float; default:  -1.0) [default=-1.0].
.. py:attribute:: flames_obs_scired.param.pixel_thresh_max

    Pixel saturation threshold max (int; default: 55000) [default=55000].
.. py:attribute:: flames_obs_scired.param.pixel_thresh_min

    Pixel saturation threshold min (int; default: -20) [default=-20].
.. py:attribute:: flames_obs_scired.param.plotter

    Any plots produced by the recipe are redirected to the command  specified by this parameter. The plotting command must contain the  substring 'gnuplot' and must be able to parse gnuplot syntax on its  standard input. Valid examples of such a command may include 'gnuplot  -persist' and 'cat > mygnuplot$$.gp'. A finer control of the plotting  options can be obtained by writing an executable script, e.g.  my_gnuplot.pl, that executes gnuplot after setting the desired gnuplot  options (e.g. set terminal pslatex color). To turn off plotting, set  this parameter to 'no' (str; default: 'no') [default="no"].
.. py:attribute:: flames_obs_scired.param.process_chip

    For RED arm data process the redl, redu, or both chip(s) (str;  default: 'both') [default="both"].
.. py:attribute:: flames_obs_scired.param.rebin.scale

    Whether or not to multiply by the factor dx/dlambda (pixels per  wavelength) during the rebinning to conserve the flux. This option is  disabled as default because applying the flat field correction already  ensures flux conservation. Therefore this parameter should be TRUE  (for response and science data) only if reduce.ffmethd = no. (bool;  default: False) [default=False].
.. py:attribute:: flames_obs_scired.param.rebin.wavestep

    The bin size used for BLUE/REDL data (in w.l.u.) in wavelength space.  If negative, a step size of 2/3 * ( average pixel size ) is used.  (float; default: -1.0) [default=-1.0].
.. py:attribute:: flames_obs_scired.param.rebin.wavestep_redu

    The bin size used for REDU data (in w.l.u.) in wavelength space. If  negative, a step size of 2/3 * ( average pixel size ) is used. (float;  default: -1.0) [default=-1.0].


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

::

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

   flames_obs_scired.param.bias_method = "M"
   flames_obs_scired.param.bias_value = 200
   flames_obs_scired.param.bkg_max_io_win = 500
   flames_obs_scired.param.bkg_xy_win_sz_x = 6
   flames_obs_scired.param.bkg_xy_win_sz_y = 2
   flames_obs_scired.param.clean_tmp_products = False
   flames_obs_scired.param.cor_def_off = 0.0
   flames_obs_scired.param.cor_def_pnt = 25
   flames_obs_scired.param.cor_def_rng = 6.0
   flames_obs_scired.param.cor_max_fnd = "Y"
   flames_obs_scired.param.corvel_iter = 1
   flames_obs_scired.param.cubify_sw = "N"
   flames_obs_scired.param.debug = False
   flames_obs_scired.param.drs_base_name = "fxb"
   flames_obs_scired.param.drs_ext_w_siz = 10.0
   flames_obs_scired.param.drs_k_s_thre = 10.0
   flames_obs_scired.param.drs_maxyshift = 3.0
   flames_obs_scired.param.ext_method = "opt"
   flames_obs_scired.param.filt_sw = "none"
   flames_obs_scired.param.merge = "optimal"
   flames_obs_scired.param.merge_delt1 = -1.0
   flames_obs_scired.param.merge_delt2 = -1.0
   flames_obs_scired.param.pixel_thresh_max = 55000
   flames_obs_scired.param.pixel_thresh_min = -20
   flames_obs_scired.param.plotter = "no"
   flames_obs_scired.param.process_chip = "both"
   flames_obs_scired.param.rebin.scale = False
   flames_obs_scired.param.rebin.wavestep = -1.0
   flames_obs_scired.param.rebin.wavestep_redu = -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
   flames_obs_scired = cpl.Recipe("flames_obs_scired")
   [...]
   res = flames_obs_scired( ..., param = {"bias_method":"M", "bias_value":200})


.. 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 `Andrea Modigliani <cpl@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 FLAMES/UVES Pipeline
Copyright (C) 2004, 2005, 2006, 2007 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:: Andrea Modigliani <cpl@eso.org>
