00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifdef HAVE_CONFIG_H
00035 #include <config.h>
00036 #endif
00037
00038
00039 #include <strings.h>
00040 #include <string.h>
00041 #include <stdio.h>
00042
00043
00044 #include <cpl.h>
00045
00046 #include <irplib_utils.h>
00047
00048
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 #include <sinfo_error.h>
00058 #include <sinfo_utils_wrappers.h>
00059
00060
00061
00062
00063
00064
00065
00066
00067 const char * sinfoni_get_licence(void);
00068 static int sinfo_utl_bp_mask_add_create(cpl_plugin *plugin);
00069 static int sinfo_utl_bp_mask_add_exec(cpl_plugin *plugin);
00070 static int sinfo_utl_bp_mask_add_destroy(cpl_plugin *plugin);
00071 static int sinfo_utl_bp_mask_add(cpl_parameterlist *, cpl_frameset *);
00072
00073
00074
00075
00076
00077 static char sinfo_utl_bp_mask_add_description[] =
00078 "This recipe performs bad pixel map coaddition.\n"
00079 "The input files are several (at least 2) bad pixel masks in the sof file\n"
00080 "Their tab should contain the string BP_MAP.\n"
00081 "The output is an image resulting from the logical operator OR \n"
00082 "applied to all the masks.\n"
00083 "Information on relevant parameters can be found with\n"
00084 "esorex --params sinfo_utl_bp_mask_add\n"
00085 "esorex --help sinfo_utl_bp_mask_add\n"
00086 "\n";
00087
00088
00089
00090
00091
00092
00093
00097
00099
00100
00101 int
00102 cpl_plugin_get_info(cpl_pluginlist *list)
00103 {
00104
00105 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00106 cpl_plugin *plugin = &recipe->interface;
00107
00108
00109 cpl_plugin_init(plugin,
00110 CPL_PLUGIN_API,
00111 SINFONI_BINARY_VERSION,
00112 CPL_PLUGIN_TYPE_RECIPE,
00113 "sinfo_utl_bp_mask_add",
00114 "Add bad pixels masks",
00115 sinfo_utl_bp_mask_add_description,
00116 "Andrea Modigliani",
00117 "Andrea.Modigliani@eso.org",
00118 sinfo_get_license(),
00119 sinfo_utl_bp_mask_add_create,
00120 sinfo_utl_bp_mask_add_exec,
00121 sinfo_utl_bp_mask_add_destroy);
00122
00123 cpl_pluginlist_append(list, plugin);
00124
00125 return 0;
00126
00127 }
00128
00129
00136 static int
00137 sinfo_utl_bp_mask_add_create(cpl_plugin *plugin)
00138 {
00139
00140
00141
00142
00143
00144
00145 cpl_recipe *recipe = (cpl_recipe *)plugin;
00146 recipe->parameters = cpl_parameterlist_new();
00147 if(recipe->parameters == NULL) {
00148 return 1;
00149 }
00150 cpl_error_reset();
00151 irplib_reset();
00152
00153
00154
00155
00156
00157
00158 return 0;
00159
00160 }
00161
00162
00168 static int
00169 sinfo_utl_bp_mask_add_exec(cpl_plugin *plugin)
00170 {
00171
00172
00173 cpl_recipe *recipe = (cpl_recipe *) plugin;
00174 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00175 int code=0;
00176
00177 if(recipe->parameters == NULL ) {
00178 return 1;
00179 }
00180 if(recipe->frames == NULL) {
00181 return 1;
00182 }
00183
00184 check_nomsg(code=sinfo_utl_bp_mask_add(recipe->parameters, recipe->frames));
00185
00186 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00187
00188
00189 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00190 }
00191 cleanup:
00192
00193 return code;
00194
00195 }
00196
00197
00204 static int
00205 sinfo_utl_bp_mask_add_destroy(cpl_plugin *plugin)
00206 {
00207 cpl_recipe *recipe = (cpl_recipe *) plugin;
00208
00209
00210
00211
00212
00213
00214 cpl_parameterlist_delete(recipe->parameters);
00215 return 0;
00216
00217 }
00218
00219
00220
00221
00222
00223
00224
00238 static int
00239 sinfo_utl_bp_mask_add(cpl_parameterlist *config, cpl_frameset *sof)
00240 {
00241 cpl_frameset* ref_set=NULL;
00242 int n=0;
00243
00244 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00245 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00246
00247 if(sinfo_dfs_set_groups(sof)) {
00248 sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
00249 }
00250
00251 n=cpl_frameset_get_size(sof);
00252 if(n<1) {
00253 sinfo_msg_error("Empty input frame list!");
00254 goto cleanup ;
00255 }
00256
00257 check_nomsg(ref_set=cpl_frameset_duplicate(sof));
00258 ck0_nomsg(sinfo_new_add_bp_map(cpl_func,config,sof,ref_set));
00259
00260 cleanup:
00261 sinfo_free_frameset(&ref_set);
00262 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00263 return -1;
00264 } else {
00265 return 0;
00266 }
00267
00268
00269
00270 }