si_rec_detlin.c

00001 /* $Id: si_rec_detlin.c,v 1.21 2005/10/08 10:34:50 amodigli Exp $
00002  *
00003  * This file is part of the CPL (Common Pipeline Library)
00004  * Copyright (C) 2002 European Southern Observatory
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library 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 GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2005/10/08 10:34:50 $
00023  * $Revision: 1.21 $
00024  * $Name:  $
00025  */
00026 
00030 /*---------------------------------------------------------------------------*/
00033  /****************************************************************
00034   *           Bad pixel search  (normal method)                  *
00035   ****************************************************************/
00036 
00037 /* --------------------------------------------------------------- 
00038                          INCLUDES
00039    --------------------------------------------------------------- */
00040 #ifdef HAVE_CONFIG_H
00041 #include <config.h>
00042 #endif
00043 
00044 /*-----------------------------------------------------------------------------
00045                                 Includes
00046  -----------------------------------------------------------------------------*/
00047 
00048 /* std libraries */
00049 #include <strings.h>
00050 #include <string.h>
00051 #include <stdio.h>
00052 
00053 /* cx */
00054 #include <cxmacros.h>
00055 #include <cxtypes.h>
00056 #include <cxmessages.h>     
00057 
00058 /* qfits */
00059 #include <xmemory.h>  
00060  
00061 /* cpl */
00062 #include <cpl.h>
00063 
00064 
00065 /* sinfoni */
00066 #include <sinfoni_memory.h>
00067 #include <sinfoni_bp_lin_config.h>
00068 #include <sinfoni_bp_config.h>
00069 
00070 #include <bp_lin.h> 
00071 #include <sinfoni_tpl_utils.h>
00072 #include <sinfoni_functions.h>
00073 #include <sinfoni_tpl_dfs.h>
00074 /* --------------------------------------------------------------- 
00075                          DEFINES
00076    --------------------------------------------------------------- */
00077 /* --------------------------------------------------------------- 
00078                          FUNCTIONS PROTOTYPES
00079    --------------------------------------------------------------- */
00080 
00081 
00082 static cxint si_rec_detlin_create(cpl_plugin *plugin);
00083 static cxint si_rec_detlin_exec(cpl_plugin *plugin);
00084 static cxint si_rec_detlin_destroy(cpl_plugin *plugin);
00085 static cxint si_rec_detlin(cpl_parameterlist *, cpl_frameset *);
00086 int cpl_plugin_get_info(cpl_pluginlist *list);
00087 
00088 
00089 /* --------------------------------------------------------------- 
00090                          STATIC VARIABLES
00091    --------------------------------------------------------------- */
00092 
00093 static char si_rec_detlin_description[] =
00094 "This recipe computes detector non linearities and a bad pixel map.\n"
00095 "The input files are increasing intensity raw flats\n"
00096 "their associated tags should be LINEARITY_LAMP.\n"
00097 "The output are \n"
00098 "A table (PRO.CATG=LIN_DET_INFO) with information on the detector non linearities\n"
00099 "A table (PRO.CATG=GAIN_INFO) with information on the detector gain\n"
00100 "A cube (PRO.CATG=BP_COEFF) with the polynomial fit parameters 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 si_rec_detlin\n"
00104 "esorex --help si_rec_detlin\n"
00105 "\n";
00106 
00107 
00108 /* --------------------------------------------------------------- 
00109                          FUNCTIONS CODE
00110    --------------------------------------------------------------- */
00111 
00112 
00113 /* --------------------------------------------------------------- */
00114 /*--------------------------------------------------------------------------*/
00123 /*-------------------------------------------------------------------------*/
00124 
00125 int
00126 cpl_plugin_get_info(cpl_pluginlist *list)
00127 {
00128 
00129   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00130   cpl_plugin *plugin = &recipe->interface;
00131 
00132 
00133   cpl_plugin_init(plugin,
00134           CPL_PLUGIN_API,
00135           SINFONI_BINARY_VERSION,
00136           CPL_PLUGIN_TYPE_RECIPE,
00137           "si_rec_detlin",
00138           "Detector's linearity and non linear bad pixel map determination.",
00139           si_rec_detlin_description,
00140           "Andrea Modigliani",
00141           "Andrea.Modigliani@eso.org",
00142           sinfoni_get_license(),
00143           si_rec_detlin_create,
00144           si_rec_detlin_exec,
00145           si_rec_detlin_destroy);
00146 
00147   cpl_pluginlist_append(list, plugin);
00148 
00149   return 0;
00150 
00151 }
00152 /*--------------------------------------------------------------------------*/
00160 /*--------------------------------------------------------------------------*/
00161 
00162 static cxint
00163 si_rec_detlin_create(cpl_plugin *plugin)
00164 {
00165 
00166   /*
00167    * We have to provide the option we accept to the application.
00168    * We need to setup our parameter list and hook it into the recipe
00169    * interface.
00170    */
00171   cpl_recipe *recipe = (cpl_recipe *)plugin;
00172   recipe->parameters = cpl_parameterlist_new();
00173   if(recipe->parameters == NULL) {
00174     return 1;
00175   }
00176 
00177   /*
00178    * Fill the parameter list.
00179    */
00180 
00181   /* General parameters */
00182   /* Bad pixel parameters */
00183   /* printf("config\n"); */
00184   /*
00185   sinfoni_general_config_add(recipe->parameters); 
00186   */
00187   sinfoni_bp_lin_config_add(recipe->parameters); 
00188   
00189   return 0;
00190 
00191 }
00192 
00193 /*--------------------------------------------------------------------------*/
00199 /*--------------------------------------------------------------------------*/
00200 
00201 static cxint
00202 si_rec_detlin_exec(cpl_plugin *plugin)
00203 {
00204  
00205   cpl_recipe *recipe = (cpl_recipe *) plugin;
00206   if(recipe->parameters == NULL ) {
00207     return 1;
00208   }
00209   if(recipe->frames == NULL) {
00210     return 1;
00211   }
00212   /* printf("exec\n"); */
00213   cpl_error_reset();
00214   return si_rec_detlin(recipe->parameters, recipe->frames);
00215 
00216 }
00217 /*--------------------------------------------------------------------------*/
00223 /*--------------------------------------------------------------------------*/
00224 
00225 static cxint
00226 si_rec_detlin_destroy(cpl_plugin *plugin)
00227 {
00228   /* printf("destroy\n"); */
00229   cpl_recipe *recipe = (cpl_recipe *) plugin;
00230   /*
00231    * We just destroy what was created during the plugin initializzation phase
00232    * i.e. the parameter list. The frame set is managed by the application which
00233    * called us, so that we must not touch it.
00234    */
00235 
00236   cpl_parameterlist_delete(recipe->parameters);
00237 
00238   return 0;
00239 
00240 }
00241 
00242 /*
00243  * The actual recipe actually start here.
00244  */
00245 /*---------------------------------------------------------------------------*/
00266 /*--------------------------------------------------------------------------*/
00267 
00268 static cxint
00269 si_rec_detlin(cpl_parameterlist *config, cpl_frameset *set)
00270 {
00271   int  ind =0;
00272   const cxchar *_id = "si_rec_detlin";
00273   cpl_parameter *p;          
00274 
00275 
00276   /* Hidden parameters */
00277   /* name of the data cube storing the found polynomial coefficients */
00278   sinfoni_bp_config_add(config);  
00279   p = cpl_parameterlist_find(config,"sinfoni.bp.method");
00280   cpl_parameter_set_string(p,"Linear");   
00281 
00282    if(sinfoni_dfs_set_groups(set)) {
00283 
00284        cpl_msg_error(_id, "Cannot indentify RAW and CALIB frames") ;
00285        return -1;
00286 
00287 
00288     }
00289 
00290   cpl_msg_info(_id,"---------------------------------------");
00291   cpl_msg_info(_id,"BP_MAP_NL BAD PIXEL MAP DETERMINATION  ");
00292   cpl_msg_info(_id,"---------------------------------------");
00293 
00294   {
00295      if ( -1 == (ind = badSearchLin(_id,config, set ) ) )
00296        {
00297       cpl_msg_error(_id,"badSearchLin(), no: %d\n", ind) ;
00298       sinfoni_memory_status();
00299       return -1 ;
00300        }
00301      cpl_msg_info (_id,"BP_MAP_NL BAD PIXEL MAP DETERMINATION SUCCESS") ;
00302   }    
00303   sinfoni_memory_status();
00304   return 0 ;
00305 
00306 
00307 
00308 }
00309 
00310 
00311 
00312 
00313 
00314 
00315 

Generated on Wed Oct 26 13:08:54 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001