sinfo_utl_bp_mask_add.c

00001 /* $Id: sinfo_utl_bp_mask_add.c,v 1.10 2006/12/19 17:01:36 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: 2006/12/19 17:01:36 $
00023  * $Revision: 1.10 $
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 
00038 /* std libraries */
00039 #include <strings.h>
00040 #include <string.h>
00041 #include <stdio.h>
00042 
00043 /* cpl */
00044 #include <cpl.h>     
00045 /* irplib */
00046 #include <irplib_utils.h>
00047 
00048 /* sinfoni */
00049 #include <sinfo_general_config.h>
00050 #include <sinfo_bp_norm_config.h>
00051 #include <sinfo_bp_lin_config.h>
00052 #include <sinfo_bp_noise_config.h>
00053 #include <sinfo_new_add_bp_map.h>
00054 #include <sinfo_tpl_utils.h>
00055 #include <sinfo_tpl_dfs.h>
00056 #include <sinfo_msg.h>
00057 /* --------------------------------------------------------------- 
00058                          DEFINES
00059    --------------------------------------------------------------- */
00060 /* --------------------------------------------------------------- 
00061                          FUNCTIONS PROTOTYPES
00062    --------------------------------------------------------------- */
00063 
00064 const char * sinfoni_get_licence(void);
00065 static int sinfo_utl_bp_mask_add_create(cpl_plugin *plugin);
00066 static int sinfo_utl_bp_mask_add_exec(cpl_plugin *plugin);
00067 static int sinfo_utl_bp_mask_add_destroy(cpl_plugin *plugin);
00068 static int sinfo_utl_bp_mask_add(cpl_parameterlist *, cpl_frameset *);
00069 
00070 /* --------------------------------------------------------------- 
00071                          STATIC VARIABLES
00072    --------------------------------------------------------------- */
00073 
00074 static char sinfo_utl_bp_mask_add_description[] =
00075 "This recipe performs bad pixel map coaddition.\n"
00076 "The input files are several (at least 2)  bad pixel masks in the sof file\n"
00077 "Their tab should contain the string BP_MAP.\n"
00078 "The output is an image resulting from the logical operator OR \n"
00079 "applied to all the masks.\n"
00080 "Information on relevant parameters can be found with\n"
00081 "esorex --params sinfo_utl_bp_mask_add\n"
00082 "esorex --help sinfo_utl_bp_mask_add\n"
00083 "\n";
00084 
00085 
00086 /* --------------------------------------------------------------- 
00087                          FUNCTIONS CODE
00088    --------------------------------------------------------------- */
00089 
00090 /*---------------------------------------------------------------------------*/
00094 /*---------------------------------------------------------------------------*/
00096 /* --------------------------------------------------------------- */
00097 
00098 int
00099 cpl_plugin_get_info(cpl_pluginlist *list)
00100 {
00101 
00102   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00103   cpl_plugin *plugin = &recipe->interface;
00104 
00105 
00106   cpl_plugin_init(plugin,
00107           CPL_PLUGIN_API,
00108           SINFONI_BINARY_VERSION,
00109           CPL_PLUGIN_TYPE_RECIPE,
00110           "sinfo_utl_bp_mask_add",
00111           "Add bad pixels masks",
00112           sinfo_utl_bp_mask_add_description,
00113           "Andrea Modigliani",
00114           "Andrea.Modigliani@eso.org",
00115           sinfo_get_license(),
00116           sinfo_utl_bp_mask_add_create,
00117           sinfo_utl_bp_mask_add_exec,
00118           sinfo_utl_bp_mask_add_destroy);
00119 
00120   cpl_pluginlist_append(list, plugin);
00121 
00122   return 0;
00123 
00124 }
00125 
00126 /* --------------------------------------------------------------- */
00133 static int
00134 sinfo_utl_bp_mask_add_create(cpl_plugin *plugin)
00135 {
00136 
00137   /*
00138    * We have to provide the option we accept to the application.
00139    * We need to setup our parameter list and hook it into the recipe
00140    * interface.
00141    */
00142   cpl_recipe *recipe = (cpl_recipe *)plugin;
00143   recipe->parameters = cpl_parameterlist_new();
00144   if(recipe->parameters == NULL) {
00145     return 1;
00146   }
00147   cpl_error_reset();
00148   irplib_reset();
00149 
00150   /*
00151    * Fill the parameter list.
00152    */
00153 
00154 
00155   return 0;
00156 
00157 }
00158 
00159 /* --------------------------------------------------------------- */
00165 static int
00166 sinfo_utl_bp_mask_add_exec(cpl_plugin *plugin)
00167 {
00168  
00169 
00170   cpl_recipe *recipe = (cpl_recipe *) plugin;
00171   if(recipe->parameters == NULL ) {
00172     return 1;
00173   }
00174   if(recipe->frames == NULL) {
00175     return 1;
00176   }
00177 
00178   return sinfo_utl_bp_mask_add(recipe->parameters, recipe->frames);
00179 
00180 }
00181 
00182 /* --------------------------------------------------------------- */
00189 static int
00190 sinfo_utl_bp_mask_add_destroy(cpl_plugin *plugin)
00191 {
00192   cpl_recipe *recipe = (cpl_recipe *) plugin;
00193   /*
00194    * We just destroy what was created during the plugin initializzation phase
00195    * i.e. the parameter list. The frame set is managed by the application which
00196    * called us, so that we must not touch it.
00197    */
00198 
00199   cpl_parameterlist_delete(recipe->parameters);
00200   return 0;
00201 
00202 }
00203 
00204 /*
00205  * The actual recipe actually start here.
00206  */
00207 
00208 
00209 /* --------------------------------------------------------------- */
00223 static int
00224 sinfo_utl_bp_mask_add(cpl_parameterlist *config, cpl_frameset *sof)
00225 {
00226 
00227   sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00228         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00229 
00230    if(sinfo_dfs_set_groups(sof)) {
00231        sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
00232        return -1;
00233     }
00234    sinfo_new_add_bp_map(cpl_func,config,sof);
00235    return 0 ;
00236 
00237 
00238 
00239 }

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