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 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035
00036
00037
00038
00039
00040 #include <strings.h>
00041 #include <string.h>
00042 #include <stdio.h>
00043
00044
00045 #include <cpl.h>
00046 #include <irplib_utils.h>
00047
00048 #include <sinfo_pro_types.h>
00049 #include <sinfo_bp_config.h>
00050 #include <sinfo_bp_norm_config.h>
00051 #include <sinfo_lamp_flats_config.h>
00052 #include <sinfo_bp_norm.h>
00053 #include <sinfo_new_lamp_flats.h>
00054 #include <sinfo_functions.h>
00055 #include <sinfo_new_add_bp_map.h>
00056 #include <sinfo_tpl_utils.h>
00057 #include <sinfo_tpl_dfs.h>
00058 #include <sinfo_msg.h>
00059 #include <sinfo_error.h>
00060 #include <sinfo_utils_wrappers.h>
00061
00062
00063
00064
00065 static int sinfo_rec_mflat_create(cpl_plugin *);
00066 static int sinfo_rec_mflat_exec(cpl_plugin *);
00067 static int sinfo_rec_mflat_destroy(cpl_plugin *);
00068 static int sinfo_rec_mflat(cpl_parameterlist *, cpl_frameset *);
00069
00070
00071
00072
00073
00074
00075 static char sinfo_rec_mflat_description[] =
00076 "This recipe reduce normal raw flat fields.\n"
00077 "The input files are a set of flat fields with tag FLAT_LAMP\n"
00078 "optionally one may have in input also several bad pixel maps to be coadded.\n"
00079 "The main products are a master flat field (PRO.CATG=MASTER_FLAT_LAMP) image\n"
00080 "a bad pixel map (PRO.CATG=BP_MAP_NO), "
00081 "a master bad pixel map (PRO.CATG=MASTER_BP_MAP) resulting by the coaddition\n"
00082 "of all bad pixel maps.\n"
00083 "Information on relevant parameters can be found with\n"
00084 "esorex --params sinfo_rec_mflat\n"
00085 "esorex --help sinfo_rec_mflat\n"
00086 "\n";
00087
00088
00089
00090
00091
00092
00093
00097
00099
00108
00109
00110 int cpl_plugin_get_info(cpl_pluginlist *list)
00111 {
00112
00113 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00114 cpl_plugin *plugin = &recipe->interface;
00115
00116
00117 cpl_plugin_init(plugin,
00118 CPL_PLUGIN_API,
00119 SINFONI_BINARY_VERSION,
00120 CPL_PLUGIN_TYPE_RECIPE,
00121 "sinfo_rec_mflat",
00122 "Master flat determination",
00123 sinfo_rec_mflat_description,
00124 "Andrea Modigliani",
00125 "Andrea.Modigliani@eso.org",
00126 sinfo_get_license(),
00127 sinfo_rec_mflat_create,
00128 sinfo_rec_mflat_exec,
00129 sinfo_rec_mflat_destroy);
00130
00131 cpl_pluginlist_append(list, plugin);
00132
00133 return 0;
00134
00135 }
00136
00137
00138
00146
00147
00148 static int sinfo_rec_mflat_create(cpl_plugin *plugin)
00149 {
00150
00151 cpl_recipe * recipe ;
00152
00153
00154 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00155 recipe = (cpl_recipe *)plugin ;
00156 else return -1 ;
00157
00158
00159 recipe->parameters = cpl_parameterlist_new() ;
00160
00161
00162
00163
00164 sinfo_bp_norm_config_add(recipe->parameters);
00165 sinfo_lamp_flats_config_add(recipe->parameters);
00166
00167 return 0;
00168
00169 }
00170
00176
00177 static int sinfo_rec_mflat_exec(cpl_plugin *plugin)
00178 {
00179 cpl_recipe * recipe ;
00180
00181
00182 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00183 recipe = (cpl_recipe *)plugin ;
00184 else return -1 ;
00185 cpl_error_reset();
00186 irplib_reset();
00187
00188 return sinfo_rec_mflat(recipe->parameters, recipe->frames);
00189
00190 }
00191
00197
00198 static int sinfo_rec_mflat_destroy(cpl_plugin *plugin)
00199 {
00200
00201 cpl_recipe *recipe = (cpl_recipe *) plugin;
00202
00203
00204 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00205 recipe = (cpl_recipe *)plugin ;
00206 else return -1 ;
00207
00208 cpl_parameterlist_delete(recipe->parameters);
00209 return 0;
00210
00211 }
00212
00213
00220
00221
00222
00223
00224
00225
00226 static int
00227 sinfo_rec_mflat(cpl_parameterlist *config, cpl_frameset *set)
00228 {
00229
00230 cpl_parameter* p;
00231
00232 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00233 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00234 ck0(sinfo_dfs_set_groups(set),"Cannot indentify RAW and CALIB frames") ;
00235
00236 sinfo_bp_config_add(config);
00237 check_nomsg(p = cpl_parameterlist_find(config,"sinfoni.bp.method"));
00238 check_nomsg(cpl_parameter_set_string(p,"Normal"));
00239
00240
00241
00242
00243
00244
00245 sinfo_msg("-------------------------------------------");
00246 sinfo_msg("MASTER FLAT DETERMINATION ");
00247 sinfo_msg("-------------------------------------------");
00248
00249 ck0(sinfo_new_lamp_flats(cpl_func,config,set),"MASTER FLAT DETERMINATION FAILED");
00250 sinfo_msg("MASTER FLAT DETERMINATION SUCCESS") ;
00251
00252 sinfo_msg("-------------------------------------------");
00253 sinfo_msg("BP_MAP_NO BAD PIXEL MAP DETERMINATION ");
00254 sinfo_msg("-------------------------------------------");
00255
00256
00257
00258
00259
00260
00261 check_nomsg(p = cpl_parameterlist_find(config,"sinfoni.bp.method"));
00262 check_nomsg(cpl_parameter_set_string(p,"Normal"));
00263 ck0(sinfo_new_bp_search_normal(cpl_func,config,set,PRO_BP_MAP_NO),
00264 "BP_MAP_NO BAD PIXEL MAP DETERMINATION FAILED") ;
00265
00266 sinfo_msg("------------------------------------------");
00267 sinfo_msg("MASTER_BP_MAP BAD PIXEL MAP DETERMINATION ");
00268 sinfo_msg("------------------------------------------");
00269 ck0(sinfo_new_add_bp_map(cpl_func,config, set),
00270 "MASTER_BP_MAP BAD PIXEL MAP FAILED") ;
00271 sinfo_msg("MASTER_BP_MAP BAD PIXEL MAP DETERMINATION SUCCESS");
00272
00273 return 0 ;
00274 cleanup:
00275 irplib_error_dump(CPL_MSG_ERROR,CPL_MSG_ERROR);
00276 return -1;
00277
00278 }
00279