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
00030
00033
00034
00035
00036
00037
00038
00039
00040 #ifdef HAVE_CONFIG_H
00041 #include <config.h>
00042 #endif
00043
00044
00045
00046
00047
00048
00049 #include <strings.h>
00050 #include <string.h>
00051 #include <stdio.h>
00052
00053
00054 #include <cxmacros.h>
00055 #include <cxtypes.h>
00056 #include <cxmessages.h>
00057
00058
00059 #include <xmemory.h>
00060
00061
00062 #include <cpl.h>
00063
00064
00065
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
00076
00077
00078
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
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
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
00168
00169
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
00179
00180
00181
00182
00183
00184
00185
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
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
00229 cpl_recipe *recipe = (cpl_recipe *) plugin;
00230
00231
00232
00233
00234
00235
00236 cpl_parameterlist_delete(recipe->parameters);
00237
00238 return 0;
00239
00240 }
00241
00242
00243
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
00277
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