uves_tflat_impl.c

00001 /*                                                                              *
00002  *   This file is part of the ESO UVES Pipeline                                 *
00003  *   Copyright (C) 2004,2005 European Southern Observatory                      *
00004  *                                                                              *
00005  *   This library is free software; you can redistribute it and/or modify       *
00006  *   it under the terms of the GNU General Public License as published by       *
00007  *   the Free Software Foundation; either version 2 of the License, or          *
00008  *   (at your option) any later version.                                        *
00009  *                                                                              *
00010  *   This program is distributed in the hope that it will be useful,            *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
00013  *   GNU General Public License for more details.                               *
00014  *                                                                              *
00015  *   You should have received a copy of the GNU General Public License          *
00016  *   along with this program; if not, write to the Free Software                *
00017  *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA       *
00018  *                                                                              */
00019  
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2010/04/08 10:47:27 $
00023  * $Revision: 1.26 $
00024  * $Name: uves-5_0_0 $
00025  */
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 
00030 /*----------------------------------------------------------------------------*/
00036 /*----------------------------------------------------------------------------*/
00037 
00038 /*-----------------------------------------------------------------------------
00039                                 Includes
00040  -----------------------------------------------------------------------------*/
00041 
00042 #include <uves_reduce_mflat.h>
00043 #include <uves_reduce_scired.h>
00044 #include <uves_parameters.h>
00045 #include <uves_utils_wrappers.h>
00046 #include <uves_dfs.h>
00047 #include <uves_recipe.h>
00048 #include <uves.h>
00049 #include <uves_error.h>
00050 #include <uves_msg.h>
00051 
00052 #include <cpl.h>
00053 #include <string.h>
00054 /*-----------------------------------------------------------------------------
00055                             Functions prototypes
00056  -----------------------------------------------------------------------------*/
00057 static int
00058 uves_tflat_define_parameters(cpl_parameterlist *parameters);
00059 
00060 /*-----------------------------------------------------------------------------
00061                             Recipe standard code
00062  -----------------------------------------------------------------------------*/
00063 #define cpl_plugin_get_info uves_tflat_get_info
00064 UVES_RECIPE_DEFINE(
00065     UVES_TFLAT_ID, UVES_TFLAT_DOM, uves_tflat_define_parameters,
00066     "Jonas M. Larsen", "cpl@eso.org",
00067     "Reduces a TFLAT frame",
00068     "This recipe reduces a TFLAT_xxx frame (xxx = BLUE,RED). This is\n"
00069     "achieved by\n"
00070     "1) combining all provided TFLAT frames to a MASTER_TFLAT frame, then\n"
00071     "2) doing a normal science reduction on the first input TFLAT frame\n"
00072     "Input frames are raw TFLAT_xxx  frames, and: \n"
00073     "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
00074     "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
00075     "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n");
00076 
00078 /*-----------------------------------------------------------------------------
00079                               Functions code
00080  -----------------------------------------------------------------------------*/
00081 /*----------------------------------------------------------------------------*/
00087 /*----------------------------------------------------------------------------*/
00088 static int
00089 uves_tflat_define_parameters(cpl_parameterlist *parameters)
00090 {
00091 
00092    int res=0;
00093    res=uves_mflat_define_parameters_body(parameters,"uves_cal_tflat" );
00094 
00095     /*******************
00096      *  Reduce.        *
00097      ******************/
00098     if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
00099                                        make_str(UVES_TFLAT_ID), NULL) != 0)
00100         {
00101             return -1;
00102         }
00103 
00104     /* For TFLAT reduction: average extraction, no sky subtraction */
00105     {
00106     const char *param = "average";
00107     bool bool_param;
00108 
00109     if (uves_set_parameter_default(parameters, 
00110                        make_str(UVES_TFLAT_ID), "reduce.extract.method",
00111                        CPL_TYPE_STRING, &param) != CPL_ERROR_NONE)
00112         {
00113         return -1;
00114         }
00115 
00116     bool_param = false;
00117     if (uves_set_parameter_default(parameters, 
00118                        make_str(UVES_TFLAT_ID), "reduce.skysub",
00119                        CPL_TYPE_BOOL, &bool_param) != CPL_ERROR_NONE)
00120         {
00121         return -1;
00122         }
00123     }
00124     
00125     return (cpl_error_get_code() != CPL_ERROR_NONE);
00126 }
00127 
00128 /*----------------------------------------------------------------------------*/
00135 /*----------------------------------------------------------------------------*/
00136 static void
00137 UVES_CONCAT2X(UVES_TFLAT_ID,exe)(cpl_frameset *frames,
00138                    const cpl_parameterlist *parameters, 
00139                    const char *starttime)
00140 {
00141     uves_msg("Creating master tflat");
00142     check_nomsg( uves_mflat_exe_body(frames, parameters, 
00143                      starttime,
00144                      make_str(UVES_TFLAT_ID)) );
00145 
00146     uves_msg("Reducing first raw tflat");
00147     check_nomsg( uves_reduce_scired(frames, parameters, make_str(UVES_TFLAT_ID), starttime) );
00148 
00149     /* The MASTER_TFLAT was reclassified as CALIB by the reduction step.
00150        But it is actually a product of this recipe, so retag it */
00151     {
00152       enum uves_chip chip;
00153       int blue;
00154       const char* PROCESS_CHIP=NULL;
00155       cpl_frame *f = NULL;
00156       check( uves_get_parameter(parameters, NULL, "uves", "process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
00157          "Could not read parameter");
00158     uves_string_toupper((char*)PROCESS_CHIP);
00159 
00160       /* Loop over all possible MASTER_TFLATs */
00161       for (blue = 0; blue <= 1; blue++)
00162         {
00163       for (chip = uves_chip_get_first(blue);
00164            chip != UVES_CHIP_INVALID;
00165            chip = uves_chip_get_next(chip))
00166             {
00167 
00168           if(strcmp(PROCESS_CHIP,"REDU") == 0) {
00169         chip = uves_chip_get_next(chip);
00170           }
00171 
00172           f = cpl_frameset_find(frames, UVES_MASTER_TFLAT(chip));
00173           if (f != NULL)
00174                 {
00175           cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00176                 }
00177             
00178           f = cpl_frameset_find(frames, UVES_BKG_FLAT(chip));
00179           if (f != NULL)
00180                 {
00181           cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00182                 }
00183             }
00184 
00185       if(strcmp(PROCESS_CHIP,"REDL") == 0) {
00186         chip = uves_chip_get_next(chip);
00187       }
00188 
00189         }
00190     }
00191 
00192   cleanup:
00193     return;
00194 }
00195 

Generated on 9 Mar 2012 for UVES Pipeline Reference Manual by  doxygen 1.6.1