sinfo_rec_detlin.c

00001 /* $Id: sinfo_rec_detlin.c,v 1.14 2006/12/19 17:01:36 amodigli Exp $
00002  *
00003  * This file is part of the SINFONI Pipeline
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: amodigli $
00023  * $Date: 2006/12/19 17:01:36 $
00024  * $Revision: 1.14 $
00025  * $Name:  $
00026  */
00027 
00031 /*---------------------------------------------------------------------------*/
00034  /****************************************************************
00035   *           Bad pixel search  (normal method)                  *
00036   ****************************************************************/
00037 
00038 /* --------------------------------------------------------------- 
00039                          INCLUDES
00040    --------------------------------------------------------------- */
00041 #ifdef HAVE_CONFIG_H
00042 #include <config.h>
00043 #endif
00044 
00045 /*----------------------------------------------------------------------------
00046                                 Includes
00047  ----------------------------------------------------------------------------*/
00048 
00049 /* std libraries */
00050 #include <strings.h>
00051 #include <string.h>
00052 #include <stdio.h>
00053 
00054 /* cpl */
00055 #include <cpl.h>
00056 
00057 /* irplib */
00058 #include <irplib_utils.h>
00059 
00060 
00061 /* sinfoni */
00062 #include <sinfo_bp_lin_config.h>
00063 #include <sinfo_bp_config.h>
00064 #include <sinfo_bp_lin.h>
00065 
00066 #include <sinfo_bp_lin.h> 
00067 #include <sinfo_tpl_utils.h>
00068 #include <sinfo_functions.h>
00069 #include <sinfo_tpl_dfs.h>
00070 #include <sinfo_msg.h>
00071 #include <sinfo_error.h>
00072 #include <sinfo_utils_wrappers.h>
00073 
00074 /*---------------------------------------------------------------------------
00075                             Functions prototypes
00076  ---------------------------------------------------------------------------*/
00077 
00078 
00079 static int sinfo_rec_detlin_create(cpl_plugin *plugin);
00080 static int sinfo_rec_detlin_exec(cpl_plugin *plugin);
00081 static int sinfo_rec_detlin_destroy(cpl_plugin *plugin);
00082 static int sinfo_rec_detlin(cpl_parameterlist *, cpl_frameset *);
00083 
00084 /*----------------------------------------------------------------------------
00085                             Static variables
00086  ----------------------------------------------------------------------------*/
00087 
00088 static char sinfo_rec_detlin_description[] =
00089 "This recipe computes detector non linearities and a bad pixel map.\n"
00090 "The input files are increasing intensity raw flats\n"
00091 "their associated tags should be LINEARITY_LAMP.\n"
00092 "The output are: \n"
00093 "A table (PRO.CATG=LIN_DET_INFO) with information \n"
00094 "on the detector non linearities\n"
00095 "A table (PRO.CATG=GAIN_INFO) with information on the detector gain\n"
00096 "A cube (PRO.CATG=BP_COEFF) with the polynomial fit parameters \n"
00097 "of the detector non linearities\n"
00098 "A bad pixel map (PRO.CATG=BP_MAP_NL)\n"
00099 "Information on relevant parameters can be found with\n"
00100 "esorex --params sinfo_rec_detlin\n"
00101 "esorex --help sinfo_rec_detlin\n"
00102 "\n";
00103 /*---------------------------------------------------------------------------
00104                                 Functions code
00105  ---------------------------------------------------------------------------*/
00106 /*--------------------------------------------------------------------------*/
00115 /*--------------------------------------------------------------------------*/
00116 
00117 
00118 int cpl_plugin_get_info(cpl_pluginlist *list)
00119 {
00120 
00121   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00122   cpl_plugin *plugin = &recipe->interface;
00123 
00124 
00125   cpl_plugin_init(plugin,
00126           CPL_PLUGIN_API,
00127           SINFONI_BINARY_VERSION,
00128           CPL_PLUGIN_TYPE_RECIPE,
00129           "sinfo_rec_detlin",
00130           "Detector's linearity & non linear bad pixels determination.",
00131           sinfo_rec_detlin_description,
00132           "Andrea Modigliani",
00133           "Andrea.Modigliani@eso.org",
00134           sinfo_get_license(),
00135           sinfo_rec_detlin_create,
00136           sinfo_rec_detlin_exec,
00137           sinfo_rec_detlin_destroy);
00138 
00139   cpl_pluginlist_append(list, plugin);
00140 
00141   return 0;
00142 
00143 }
00144 
00145 /*--------------------------------------------------------------------------*/
00153 /*--------------------------------------------------------------------------*/
00154 static int sinfo_rec_detlin_create(cpl_plugin *plugin)
00155 {
00156 
00157   /*
00158    * We have to provide the option we accept to the application.
00159    * We need to setup our parameter list and hook it into the recipe
00160    * interface.
00161    */
00162 
00163 
00164     cpl_recipe      * recipe ;
00165 
00166     /* Check that the plugin is part of a valid recipe */
00167     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00168         recipe = (cpl_recipe *)plugin ;
00169     else return -1 ;
00170 
00171     cpl_error_reset();
00172     irplib_reset();
00173     /* Create the parameters list in the cpl_recipe object */
00174     recipe->parameters = cpl_parameterlist_new() ; 
00175 
00176 
00177     sinfo_bp_lin_config_add(recipe->parameters); 
00178   
00179     return 0;
00180 
00181 }
00182 
00183 /*--------------------------------------------------------------------------*/
00189 /*--------------------------------------------------------------------------*/
00190 
00191 static int sinfo_rec_detlin_exec(cpl_plugin *plugin)
00192 {
00193      cpl_recipe  *   recipe ;
00194     
00195     /* Get the recipe out of the plugin */
00196     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00197         recipe = (cpl_recipe *)plugin ;
00198     else return -1 ;
00199 
00200   return sinfo_rec_detlin(recipe->parameters, recipe->frames);
00201 
00202 }
00203 /*--------------------------------------------------------------------------*/
00209 /*--------------------------------------------------------------------------*/
00210 
00211 static int sinfo_rec_detlin_destroy(cpl_plugin *plugin)
00212 {
00213      cpl_recipe  *   recipe ;
00214     
00215     /* Get the recipe out of the plugin */
00216     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00217         recipe = (cpl_recipe *)plugin ;
00218     else return -1 ;
00219 
00220     cpl_parameterlist_delete(recipe->parameters) ; 
00221 
00222   return 0;
00223 
00224 }
00225 
00226 /*
00227  * The actual recipe actually start here.
00228  */
00229 /*---------------------------------------------------------------------------*/
00250 /*--------------------------------------------------------------------------*/
00251 
00252 static int sinfo_rec_detlin(cpl_parameterlist *config, cpl_frameset *set)
00253 {
00254   cpl_parameter *p=NULL;          
00255 
00256 
00257   sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00258         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00259   /* Hidden parameters */
00260   /* name of the data cube storing the found polynomial coefficients */
00261   sinfo_bp_config_add(config);  
00262   check_nomsg(p = cpl_parameterlist_find(config,"sinfoni.bp.method"));
00263   check_nomsg(cpl_parameter_set_string(p,"Linear"));   
00264 
00265   ck0(sinfo_dfs_set_groups(set),"Cannot indentify RAW and CALIB frames") ;
00266 
00267   sinfo_msg("---------------------------------------");
00268   sinfo_msg("BP_MAP_NL BAD PIXEL MAP DETERMINATION  ");
00269   sinfo_msg("---------------------------------------");
00270   ck0(sinfo_new_bp_search_lin(cpl_func,config,set),
00271     "BP_MAP_NL BAD PIXEL MAP DETERMINATION FAILED") ;
00272   sinfo_msg("BP_MAP_NL BAD PIXEL MAP DETERMINATION SUCCESS") ;
00273      
00274    return 0 ;
00275  cleanup:
00276    irplib_error_dump(CPL_MSG_ERROR,CPL_MSG_ERROR);
00277    return -1;
00278 
00279 
00280 }
00281 

Generated on Wed Jan 17 08:33:43 2007 for SINFONI Pipeline Reference Manual by  doxygen 1.4.4