sinfo_rec_detlin.c

00001 /* $Id: sinfo_rec_detlin.c,v 1.21 2008/02/04 17:23:02 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: 2008/02/04 17:23:02 $
00024  * $Revision: 1.21 $
00025  * $Name: HEAD $
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_utilities.h>
00063 #include <sinfo_general_config.h>
00064 #include <sinfo_bp_lin_config.h>
00065 #include <sinfo_bp_config.h>
00066 #include <sinfo_bp_lin.h>
00067 #include <sinfo_product_config.h>
00068 
00069 #include <sinfo_bp_lin.h> 
00070 #include <sinfo_tpl_utils.h>
00071 #include <sinfo_functions.h>
00072 #include <sinfo_tpl_dfs.h>
00073 #include <sinfo_msg.h>
00074 #include <sinfo_error.h>
00075 #include <sinfo_utils_wrappers.h>
00076 
00077 /*---------------------------------------------------------------------------
00078                             Functions prototypes
00079  ---------------------------------------------------------------------------*/
00080 
00081 
00082 static int sinfo_rec_detlin_create(cpl_plugin *plugin);
00083 static int sinfo_rec_detlin_exec(cpl_plugin *plugin);
00084 static int sinfo_rec_detlin_destroy(cpl_plugin *plugin);
00085 static int sinfo_rec_detlin(cpl_parameterlist *, cpl_frameset *);
00086 
00087 /*----------------------------------------------------------------------------
00088                             Static variables
00089  ----------------------------------------------------------------------------*/
00090 
00091 static char sinfo_rec_detlin_description[] =
00092 "This recipe computes detector non linearities and a bad pixel map.\n"
00093 "The input files are increasing intensity raw flats\n"
00094 "their associated tags should be LINEARITY_LAMP.\n"
00095 "The output are: \n"
00096 "A table (PRO.CATG=LIN_DET_INFO) with information \n"
00097 "on the detector non linearities\n"
00098 "A table (PRO.CATG=GAIN_INFO) with information on the detector gain\n"
00099 "A cube (PRO.CATG=BP_COEFF) with the polynomial fit parameters \n"
00100 "of the detector non linearities\n"
00101 "A bad pixel map (PRO.CATG=BP_MAP_NL)\n"
00102 "Information on relevant parameters can be found with\n"
00103 "esorex --params sinfo_rec_detlin\n"
00104 "esorex --help sinfo_rec_detlin\n"
00105 "\n";
00106 /*---------------------------------------------------------------------------
00107                                 Functions code
00108  ---------------------------------------------------------------------------*/
00109 /*--------------------------------------------------------------------------*/
00118 /*--------------------------------------------------------------------------*/
00119 
00120 
00121 int cpl_plugin_get_info(cpl_pluginlist *list)
00122 {
00123 
00124   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00125   cpl_plugin *plugin = &recipe->interface;
00126 
00127 
00128   cpl_plugin_init(plugin,
00129           CPL_PLUGIN_API,
00130           SINFONI_BINARY_VERSION,
00131           CPL_PLUGIN_TYPE_RECIPE,
00132           "sinfo_rec_detlin",
00133           "Detector's linearity & non linear bad pixels determination.",
00134           sinfo_rec_detlin_description,
00135           "Andrea Modigliani",
00136           "Andrea.Modigliani@eso.org",
00137           sinfo_get_license(),
00138           sinfo_rec_detlin_create,
00139           sinfo_rec_detlin_exec,
00140           sinfo_rec_detlin_destroy);
00141 
00142   cpl_pluginlist_append(list, plugin);
00143 
00144   return 0;
00145 
00146 }
00147 
00148 /*--------------------------------------------------------------------------*/
00156 /*--------------------------------------------------------------------------*/
00157 static int sinfo_rec_detlin_create(cpl_plugin *plugin)
00158 {
00159 
00160   /*
00161    * We have to provide the option we accept to the application.
00162    * We need to setup our parameter list and hook it into the recipe
00163    * interface.
00164    */
00165 
00166 
00167     cpl_recipe      * recipe ;
00168 
00169     /* Check that the plugin is part of a valid recipe */
00170     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00171         recipe = (cpl_recipe *)plugin ;
00172     else return -1 ;
00173 
00174     cpl_error_reset();
00175     irplib_reset();
00176     /* Create the parameters list in the cpl_recipe object */
00177     recipe->parameters = cpl_parameterlist_new() ; 
00178 
00179     sinfo_general_config_add(recipe->parameters);
00180     sinfo_product_config_add(recipe->parameters);
00181     sinfo_bp_lin_config_add(recipe->parameters); 
00182   
00183     return 0;
00184 
00185 }
00186 
00187 /*--------------------------------------------------------------------------*/
00193 /*--------------------------------------------------------------------------*/
00194 
00195 static int sinfo_rec_detlin_exec(cpl_plugin *plugin)
00196 {
00197      cpl_recipe  *   recipe ;
00198     
00199     /* Get the recipe out of the plugin */
00200     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00201 
00202     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00203         recipe = (cpl_recipe *)plugin ;
00204     else return -1 ;
00205   
00206     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00207         /* Dump the error history since recipe execution start.                
00208            At this point the recipe cannot recover from the error */           
00209         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00210     } 
00211 
00212   return sinfo_rec_detlin(recipe->parameters, recipe->frames);
00213 
00214 }
00215 /*--------------------------------------------------------------------------*/
00221 /*--------------------------------------------------------------------------*/
00222 
00223 static int sinfo_rec_detlin_destroy(cpl_plugin *plugin)
00224 {
00225      cpl_recipe  *   recipe ;
00226     
00227     /* Get the recipe out of the plugin */
00228     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00229         recipe = (cpl_recipe *)plugin ;
00230     else return -1 ;
00231 
00232     cpl_parameterlist_delete(recipe->parameters) ; 
00233 
00234   return 0;
00235 
00236 }
00237 
00238 /*
00239  * The actual recipe actually start here.
00240  */
00241 /*---------------------------------------------------------------------------*/
00262 /*--------------------------------------------------------------------------*/
00263 
00264 static int sinfo_rec_detlin(cpl_parameterlist *config, cpl_frameset *set)
00265 {
00266   cpl_parameter *p=NULL;          
00267   int line_cor=0;
00268 
00269   sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00270         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00271   /* Hidden parameters */
00272   /* name of the data cube storing the found polynomial coefficients */
00273   sinfo_bp_config_add(config);  
00274   check_nomsg(p = cpl_parameterlist_find(config,"sinfoni.bp.method"));
00275   check_nomsg(cpl_parameter_set_string(p,"Linear"));   
00276 
00277   ck0(sinfo_dfs_set_groups(set),"Cannot indentify RAW and CALIB frames") ;
00278 
00279   check_nomsg(p=cpl_parameterlist_find(config, "sinfoni.general.lc_sw"));
00280   check_nomsg(line_cor=cpl_parameter_get_bool(p));
00281   if(line_cor==1) {
00282      check_nomsg(sinfo_ima_line_cor(config,set));
00283   }
00284 
00285 
00286   sinfo_msg("---------------------------------------");
00287   sinfo_msg("BP_MAP_NL BAD PIXEL MAP DETERMINATION  ");
00288   sinfo_msg("---------------------------------------");
00289   ck0(sinfo_new_bp_search_lin(cpl_func,config,set),
00290     "BP_MAP_NL BAD PIXEL MAP DETERMINATION FAILED") ;
00291   sinfo_msg("BP_MAP_NL BAD PIXEL MAP DETERMINATION SUCCESS") ;
00292 
00293  cleanup:
00294 
00295   if (cpl_error_get_code() != CPL_ERROR_NONE) {
00296     return -1;
00297   } else {
00298     return 0;
00299   }
00300 
00301 }
00302 

Generated on 3 Mar 2013 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1