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: jmlarsen $
00022  * $Date: 2007/06/11 13:28:26 $
00023  * $Revision: 1.16 $
00024  * $Name: uves-3_3_1 $
00025  * $Log: uves_tflat_impl.c,v $
00026  * Revision 1.16  2007/06/11 13:28:26  jmlarsen
00027  * Changed recipe contact address to cpl at eso.org
00028  *
00029  * Revision 1.15  2007/06/08 13:06:16  jmlarsen
00030  * Send bug reports to Andrea
00031  *
00032  * Revision 1.14  2007/06/06 08:17:33  amodigli
00033  * replace tab with 4 spaces
00034  *
00035  * Revision 1.13  2007/05/14 08:09:48  amodigli
00036  * updated input frames and tag description in recipe man page
00037  *
00038  * Revision 1.12  2007/02/09 13:44:30  jmlarsen
00039  * Use defines for recipe id
00040  *
00041  * Revision 1.11  2007/02/09 09:00:06  jmlarsen
00042  * Use defines rather than hard-coded recipe names
00043  *
00044  * Revision 1.10  2006/11/15 15:02:15  jmlarsen
00045  * Implemented const safe workarounds for CPL functions
00046  *
00047  * Revision 1.8  2006/11/15 14:04:08  jmlarsen
00048  * Removed non-const version of parameterlist_get_first/last/next which is
00049  * already in CPL, added const-safe wrapper, unwrapper and deallocator functions
00050  *
00051  * Revision 1.7  2006/11/13 12:48:35  jmlarsen
00052  * Changed interface of uves_reduce_mflat to support FLAMES
00053  *
00054  * Revision 1.6  2006/11/06 15:19:42  jmlarsen
00055  * Removed unused include directives
00056  *
00057  * Revision 1.5  2006/10/17 12:33:02  jmlarsen
00058  * Added semicolon at UVES_RECIPE_DEFINE invocation
00059  *
00060  * Revision 1.4  2006/10/09 13:01:13  jmlarsen
00061  * Use macro to define recipe interface functions
00062  *
00063  * Revision 1.3  2006/10/02 08:33:36  jmlarsen
00064  * Re-tag MASTER_TFLAT as product after the science reduction
00065  *
00066  * Revision 1.2  2006/09/27 15:08:45  jmlarsen
00067  * Fixed doc. bug
00068  *
00069  * Revision 1.1  2006/09/27 13:23:38  jmlarsen
00070  * Added tflat recipe
00071  *
00072  */
00073 #ifdef HAVE_CONFIG_H
00074 #  include <config.h>
00075 #endif
00076 
00077 /*----------------------------------------------------------------------------*/
00083 /*----------------------------------------------------------------------------*/
00084 
00085 /*-----------------------------------------------------------------------------
00086                                 Includes
00087  -----------------------------------------------------------------------------*/
00088 
00089 #include <uves_reduce_mflat.h>
00090 #include <uves_reduce_scired.h>
00091 #include <uves_parameters.h>
00092 #include <uves_utils_wrappers.h>
00093 #include <uves_dfs.h>
00094 #include <uves_recipe.h>
00095 #include <uves.h>
00096 #include <uves_error.h>
00097 #include <uves_msg.h>
00098 
00099 #include <irplib_access.h>
00100 #include <cpl.h>
00101 
00102 /*-----------------------------------------------------------------------------
00103                             Functions prototypes
00104  -----------------------------------------------------------------------------*/
00105 static int
00106 uves_tflat_define_parameters(cpl_parameterlist *parameters);
00107 
00108 /*-----------------------------------------------------------------------------
00109                             Recipe standard code
00110  -----------------------------------------------------------------------------*/
00111 #define cpl_plugin_get_info uves_tflat_get_info
00112 UVES_RECIPE_DEFINE(
00113     UVES_TFLAT_ID, UVES_TFLAT_DOM, uves_tflat_define_parameters,
00114     "Jonas M. Larsen", "cpl@eso.org",
00115     "Reduces a TFLAT frame",
00116     "This recipe reduces a TFLAT_xxx frame (xxx = BLUE,RED). This is\n"
00117     "achieved by\n"
00118     "1) combining all provided TFLAT frames to a MASTER_TFLAT frame, then\n"
00119     "2) doing a normal science reduction on the first input TFLAT frame\n"
00120     "Input frames are raw TFLAT_xxx  frames, and: \n"
00121     "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
00122     "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
00123     "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n");
00124 
00126 /*-----------------------------------------------------------------------------
00127                               Functions code
00128  -----------------------------------------------------------------------------*/
00129 /*----------------------------------------------------------------------------*/
00135 /*----------------------------------------------------------------------------*/
00136 static int
00137 uves_tflat_define_parameters(cpl_parameterlist *parameters)
00138 {
00139     /*****************
00140      *    General    *
00141      *****************/
00142     if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
00143         {
00144             return -1;
00145         }
00146 
00147     /***********************************
00148      *  Spline back.sub. (master flat) *
00149      ***********************************/
00150     
00151     if (uves_propagate_parameters_step(UVES_BACKSUB_ID, parameters, 
00152                        make_str(UVES_TFLAT_ID), NULL) != 0)
00153     {
00154         return -1;
00155     }
00156 
00157     /*******************
00158      *  Reduce.        *
00159      ******************/
00160     if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
00161                                        make_str(UVES_TFLAT_ID), NULL) != 0)
00162         {
00163             return -1;
00164         }
00165 
00166     /* For TFLAT reduction: average extraction, no sky subtraction */
00167     {
00168     const char *param = "average";
00169     bool bool_param;
00170 
00171     if (uves_set_parameter_default(parameters, 
00172                        make_str(UVES_TFLAT_ID), "reduce.extract.method",
00173                        CPL_TYPE_STRING, &param) != CPL_ERROR_NONE)
00174         {
00175         return -1;
00176         }
00177 
00178     bool_param = false;
00179     if (uves_set_parameter_default(parameters, 
00180                        make_str(UVES_TFLAT_ID), "reduce.skysub",
00181                        CPL_TYPE_BOOL, &bool_param) != CPL_ERROR_NONE)
00182         {
00183         return -1;
00184         }
00185     }
00186     
00187     return (cpl_error_get_code() != CPL_ERROR_NONE);
00188 }
00189 
00190 /*----------------------------------------------------------------------------*/
00197 /*----------------------------------------------------------------------------*/
00198 static void
00199 IRPLIB_CONCAT2X(UVES_TFLAT_ID,exe)(cpl_frameset *frames,
00200                    const cpl_parameterlist *parameters, 
00201                    const char *starttime)
00202 {
00203     uves_msg("Creating master tflat");
00204     check_nomsg( uves_mflat_exe_body(frames, parameters, 
00205                      starttime,
00206                      make_str(UVES_TFLAT_ID)) );
00207 
00208     uves_msg("Reducing first raw tflat");
00209     check_nomsg( uves_reduce_scired(frames, parameters, make_str(UVES_TFLAT_ID), starttime) );
00210 
00211     /* The MASTER_TFLAT was reclassified as CALIB by the reduction step.
00212        But it is actually a product of this recipe, so retag it */
00213     {
00214     enum uves_chip chip;
00215     int blue;
00216 
00217     /* Loop over all possible MASTER_TFLATs */
00218     for (blue = 0; blue <= 1; blue++)
00219         {
00220         for (chip = uves_chip_get_first(blue);
00221              chip != UVES_CHIP_INVALID;
00222              chip = uves_chip_get_next(chip))
00223             {
00224             cpl_frame *f = irplib_frameset_find(frames, UVES_MASTER_TFLAT(chip));
00225             if (f != NULL)
00226                 {
00227                 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00228                 }
00229             
00230             f = irplib_frameset_find(frames, UVES_BKG_FLAT(chip));
00231             if (f != NULL)
00232                 {
00233                 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00234                 }
00235             }
00236         }
00237     }
00238 
00239   cleanup:
00240     return;
00241 }
00242 

Generated on Tue Jun 19 14:39:17 2007 for UVES Pipeline Reference Manual by  doxygen 1.4.6