si_utl_bp_mask_add.c

00001 /* $Id: si_utl_bp_mask_add.c,v 1.18 2005/10/14 14:40:15 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/14 14:40:15 $
00023  * $Revision: 1.18 $
00024  * $Name:  $
00025  */
00026 
00027  /****************************************************************
00028   *           Bad pixel search  (normal method)                  *
00029   ****************************************************************/
00030 
00031 /* --------------------------------------------------------------- 
00032                          INCLUDES
00033    --------------------------------------------------------------- */
00034 #ifdef HAVE_CONFIG_H
00035 #include <config.h>
00036 #endif
00037 #include <xmemory.h>
00038 
00039 /* std libraries */
00040 #include <strings.h>
00041 #include <string.h>
00042 #include <stdio.h>
00043 /*
00044 #include "../sinfoni/eclipse/eclipse.h"
00045 */
00046 
00047 /* cx */
00048 #include <cxmacros.h>
00049 #include <cxtypes.h>
00050 #include <cxmessages.h>     
00051 
00052 /* cpl */
00053 #include <cpl_memory.h>     
00054 #include <cpl_parameterlist.h>    
00055 #include <cpl_image.h>    
00056 #include <cpl_mask.h>    
00057 #include <cpl_msg.h>  
00058 #include <cpl_error.h>  
00059 
00060 #include <cpl_recipe.h>     
00061 #include <cpl_plugininfo.h> 
00062 #include <cpl_frameset.h>   
00063 
00064 
00065 /* sinfoni */
00066 #include <sinfoni_general_config.h>
00067 #include <sinfoni_bp_norm_config.h>
00068 #include <sinfoni_bp_lin_config.h>
00069 #include <sinfoni_bp_noise_config.h>
00070 #include <add_bp_map.h>
00071 #include <sinfoni_tpl_utils.h>
00072 #include <sinfoni_tpl_dfs.h>
00073 #include <sinfoni_memory.h>
00074 /* --------------------------------------------------------------- 
00075                          DEFINES
00076    --------------------------------------------------------------- */
00077 /* --------------------------------------------------------------- 
00078                          FUNCTIONS PROTOTYPES
00079    --------------------------------------------------------------- */
00080 
00081 const char * sinfoni_get_licence(void);
00082 static cxint si_utl_bp_mask_add_create(cpl_plugin *plugin);
00083 static cxint si_utl_bp_mask_add_exec(cpl_plugin *plugin);
00084 static cxint si_utl_bp_mask_add_destroy(cpl_plugin *plugin);
00085 static cxint si_utl_bp_mask_add(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_utl_bp_mask_add_description[] =
00094 "This recipe performs bad pixel map coaddition.\n"
00095 "The input files are several (at least 2)  bad pixel masks in the sof file\n"
00096 "Their tab should contain the string BP_MAP.\n"
00097 "The output is an image resulting from the logical operator OR applied to all the masks.\n"
00098 "Information on relevant parameters can be found with\n"
00099 "esorex --params si_utl_bp_mask_add\n"
00100 "esorex --help si_utl_bp_mask_add\n"
00101 "\n";
00102 
00103 
00104 /* --------------------------------------------------------------- 
00105                          FUNCTIONS CODE
00106    --------------------------------------------------------------- */
00107 
00108 
00109 /* --------------------------------------------------------------- */
00110 
00111 int
00112 cpl_plugin_get_info(cpl_pluginlist *list)
00113 {
00114 
00115   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00116   cpl_plugin *plugin = &recipe->interface;
00117 
00118 
00119   cpl_plugin_init(plugin,
00120           CPL_PLUGIN_API,
00121           SINFONI_BINARY_VERSION,
00122           CPL_PLUGIN_TYPE_RECIPE,
00123           "si_utl_bp_mask_add",
00124           "Add bad pixels masks",
00125           si_utl_bp_mask_add_description,
00126           "Andrea Modigliani",
00127           "Andrea.Modigliani@eso.org",
00128           sinfoni_get_license(),
00129           si_utl_bp_mask_add_create,
00130           si_utl_bp_mask_add_exec,
00131           si_utl_bp_mask_add_destroy);
00132 
00133   cpl_pluginlist_append(list, plugin);
00134 
00135   return 0;
00136 
00137 }
00138 
00139 /* --------------------------------------------------------------- */
00146 static cxint
00147 si_utl_bp_mask_add_create(cpl_plugin *plugin)
00148 {
00149 
00150   /*
00151    * We have to provide the option we accept to the application.
00152    * We need to setup our parameter list and hook it into the recipe
00153    * interface.
00154    */
00155   cpl_recipe *recipe = (cpl_recipe *)plugin;
00156   recipe->parameters = cpl_parameterlist_new();
00157   if(recipe->parameters == NULL) {
00158     return 1;
00159   }
00160 
00161   /*
00162    * Fill the parameter list.
00163    */
00164 
00165 
00166   return 0;
00167 
00168 }
00169 
00170 /* --------------------------------------------------------------- */
00176 static cxint
00177 si_utl_bp_mask_add_exec(cpl_plugin *plugin)
00178 {
00179  
00180 
00181   cpl_recipe *recipe = (cpl_recipe *) plugin;
00182   if(recipe->parameters == NULL ) {
00183     return 1;
00184   }
00185   if(recipe->frames == NULL) {
00186     return 1;
00187   }
00188   cpl_error_reset();
00189 
00190   return si_utl_bp_mask_add(recipe->parameters, recipe->frames);
00191 
00192 }
00193 
00194 /* --------------------------------------------------------------- */
00201 static cxint
00202 si_utl_bp_mask_add_destroy(cpl_plugin *plugin)
00203 {
00204   cpl_recipe *recipe = (cpl_recipe *) plugin;
00205   /*
00206    * We just destroy what was created during the plugin initializzation phase
00207    * i.e. the parameter list. The frame set is managed by the application which
00208    * called us, so that we must not touch it.
00209    */
00210 
00211   cpl_parameterlist_delete(recipe->parameters);
00212   return 0;
00213 
00214 }
00215 
00216 /*
00217  * The actual recipe actually start here.
00218  */
00219 
00220 
00221 /* --------------------------------------------------------------- */
00235 static cxint
00236 si_utl_bp_mask_add(cpl_parameterlist *config, cpl_frameset *sof)
00237 {
00238   const char* _id="si_utl_bp_mask_add";
00239    if(sinfoni_dfs_set_groups(sof)) {
00240        cpl_msg_error(_id, "Cannot indentify RAW and CALIB frames") ;
00241        return -1;
00242     }
00243    add_bp_map(_id,config,sof);
00244    sinfoni_memory_status();
00245    return 0 ;
00246 
00247 
00248 
00249 }
00250 

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