46#include <xsh_irplib_utils.h>
61#define RECIPE_ID "xsh_util_bpmap_coadd"
62#define RECIPE_AUTHOR "A.Modigliani"
63#define RECIPE_CONTACT "amodigli@eso.org"
80"This recipe performs bad pixel maps combination via bitwise OR.\n"
81"The input files are several (at least 2) bad pixel masks in the sof file\n"
82"Their tab should contain the string BP_MAP.\n"
83"The output is an image resulting from the logical operator OR \n"
84"applied to all the masks.\n"
85"Information on relevant parameters can be found with\n"
86"esorex --params xsh_util_bpmap_coadd\n"
87"esorex --help xsh_util_bpmap_coadd\n"
108 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
109 cpl_plugin *plugin = &recipe->interface;
112 cpl_plugin_init(plugin,
115 CPL_PLUGIN_TYPE_RECIPE,
116 "xsh_util_bpmap_coadd",
120 "Andrea.Modigliani@eso.org",
126 cpl_pluginlist_append(list, plugin);
142 cpl_recipe* recipe=NULL;
154 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin");
157 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
158 CPL_ERROR_TYPE_MISMATCH,
159 "Plugin is not a recipe");
161 recipe = (cpl_recipe *)plugin;
163 recipe->parameters = cpl_parameterlist_new();
164 if(recipe->parameters == NULL) {
177 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
198 cpl_recipe *recipe = (cpl_recipe *) plugin;
199 cpl_errorstate initial_errorstate = cpl_errorstate_get();
202 if(recipe->parameters == NULL ) {
205 if(recipe->frames == NULL) {
211 if (!cpl_errorstate_is_equal(initial_errorstate)) {
214 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
232 cpl_recipe *recipe = (cpl_recipe *) plugin;
239 cpl_parameterlist_delete(recipe->parameters);
266 const char* recipe_tags[1] = {
"xsh_util_bpmap_coadd"};
267 int recipe_tags_size = 1;
268 cpl_frameset* bpf_set=NULL;
271 cpl_frame* frm_tmp=NULL;
274 const char* tag=NULL;
275 const char* filename=NULL;
279 cpl_frameset* calib=0;
280 cpl_frameset* raws=0;
281 cpl_frame* msk_frm=NULL;
282 cpl_propertylist* plist=NULL;
285 xsh_msg(
"Welcome to Shooter Pipeline release %d.%d.%d",
286 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
289 recipe_tags, recipe_tags_size,
RECIPE_ID,
297 n=cpl_frameset_get_size(calib);
302 bpf_set=cpl_frameset_new();
305 frm=cpl_frameset_get_frame(calib,i);
306 tag=cpl_frame_get_tag(frm);
340 cpl_frameset_insert(bpf_set,cpl_frame_duplicate(frm));
343 n=cpl_frameset_get_size(bpf_set);
346 frm=cpl_frameset_get_frame(bpf_set,i);
348 frm_tmp=cpl_frameset_get_frame(bpf_set,i);
349 xsh_msg(
"combine %s with %s via bitwise OR",
350 cpl_frame_get_tag(frm),cpl_frame_get_tag(frm_tmp));
358 sprintf(name,
"%s.fits",tag_pro);
359 filename=cpl_frame_get_filename(frm);
360 ima=cpl_image_load(filename,CPL_TYPE_FLOAT,0,0);
361 plist=cpl_propertylist_load(filename,0);
366 CPL_FRAME_GROUP_PRODUCT,
367 CPL_FRAME_LEVEL_FINAL));
377 if (cpl_error_get_code() != CPL_ERROR_NONE) {
static xsh_instrument * instrument
cpl_error_code xsh_badpixelmap_coadd(cpl_frame *self, const cpl_frame *right, const int mode)
#define assure(CONDITION, ERROR_CODE,...)
#define xsh_error_dump(level)
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
#define xsh_msg_warning(...)
Print an warning message.
#define xsh_msg_error(...)
Print an error message.
#define xsh_msg(...)
Print a message on info level.
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
static int xsh_util_bpmap_coadd_create(cpl_plugin *plugin)
Set up the recipe options.
int cpl_plugin_get_info(cpl_pluginlist *list)
static int xsh_util_bpmap_coadd(cpl_parameterlist *, cpl_frameset *)
Do bad pixel search. Monitor parameters. Do something.
static int xsh_util_bpmap_coadd_destroy(cpl_plugin *plugin)
Destroy what has been created by the 'create' function.
static int xsh_util_bpmap_coadd_exec(cpl_plugin *plugin)
Executes the plugin instance given by the interface.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
const char * xsh_get_license(void)
Get the pipeline copyright and license.
void xsh_init(void)
Reset library state.
cpl_error_code xsh_begin(cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
Recipe initialization.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_add_product_image(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.
#define XSH_MASTER_BP_MAP_BIAS
#define XSH_MASTER_BP_MAP_NLIN
#define XSH_MASTER_BP_MAP
#define XSH_MASTER_BP_MAP_FLAT
#define XSH_MASTER_BP_MAP_DARK
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
static char xsh_util_bpmap_coadd_description_short[]
static char xsh_util_bpmap_coadd_description[]
const char * xsh_get_licence(void)