57static char gravity_biasmask_description[] =
GRAVI_UNOFFERED"The recipe creates a binary mask (BIASPIX) indentifying which pixels of the SC detector are not illuminated, and thus could be used as bias-pixels in further processing. The idea would be to input such a mask, as static calibration, in all reductions. However this is not yet implemented, nor demonstrated as necessary.\n"
59 "* Load the input files\n"
60 "* Identify the mask\n"
86 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe );
87 cpl_plugin * plugin = &recipe->interface;
89 if (cpl_plugin_init(plugin,
92 CPL_PLUGIN_TYPE_RECIPE,
96 "Nabih Azouaoui, Vincent Lapeyrere, JB. Le Bouquin",
102 cpl_msg_error(cpl_func,
"Plugin initialization failed");
103 (void)cpl_error_set_where(cpl_func);
107 if (cpl_pluginlist_append(list, plugin)) {
108 cpl_msg_error(cpl_func,
"Error adding plugin to list");
109 (void)cpl_error_set_where(cpl_func);
131 if (cpl_error_get_code() != CPL_ERROR_NONE) {
132 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
133 cpl_func, __LINE__, cpl_error_get_where());
134 return (
int)cpl_error_get_code();
137 if (plugin == NULL) {
138 cpl_msg_error(cpl_func,
"Null plugin");
139 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
143 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
144 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
145 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
149 recipe = (cpl_recipe *)plugin;
152 recipe->parameters = cpl_parameterlist_new();
153 if (recipe->parameters == NULL) {
154 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
155 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
178 cpl_errorstate initial_errorstate = cpl_errorstate_get();
181 if (cpl_error_get_code() != CPL_ERROR_NONE) {
182 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
183 cpl_func, __LINE__, cpl_error_get_where());
184 return (
int)cpl_error_get_code();
187 if (plugin == NULL) {
188 cpl_msg_error(cpl_func,
"Null plugin");
189 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
193 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
194 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
195 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
199 recipe = (cpl_recipe *)plugin;
202 if (recipe->parameters == NULL) {
203 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
204 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
206 if (recipe->frames == NULL) {
207 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
208 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
215 if (cpl_dfs_update_product_header(recipe->frames)) {
216 if (!recipe_status) recipe_status = (int)cpl_error_get_code();
219 if (!cpl_errorstate_is_equal(initial_errorstate)) {
222 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
225 return recipe_status;
239 if (plugin == NULL) {
240 cpl_msg_error(cpl_func,
"Null plugin");
241 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
245 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
246 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
247 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
251 recipe = (cpl_recipe *)plugin;
253 cpl_parameterlist_delete(recipe->parameters);
268 const cpl_parameterlist * parlist)
270 cpl_frameset * dark_frameset=NULL, * flat_frameset=NULL, * used_frameset=NULL;
272 cpl_frame * frame=NULL;
275 gravi_data ** raw_data=NULL, * biasmask_map=NULL;
277 int nb_frame_gain = 0;
287 used_frameset = cpl_frameset_new ();
297 if ( cpl_frameset_is_empty (dark_frameset) ||
298 cpl_frameset_get_size (dark_frameset) != 1 ||
299 cpl_frameset_is_empty (flat_frameset) ||
300 cpl_frameset_get_size (flat_frameset) != 4 ) {
301 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
302 "Need 1 DARK_RAW and 4 FLAT_RAW");
311 cpl_msg_info (cpl_func,
" ***** Compute DARK map ***** ");
314 frame = cpl_frameset_get_position (dark_frameset, 0);
331 nb_frame_gain = cpl_frameset_get_size (flat_frameset);
332 raw_data = cpl_calloc (nb_frame_gain,
sizeof(
gravi_data *));
335 for (
int i = 0; i < nb_frame_gain; i++) {
336 frame = cpl_frameset_get_position (flat_frameset, i);
345 cpl_msg_info (cpl_func,
" ***** Compute BIAS_MASK map ***** ");
347 nb_frame_gain, parlist);
355 frame = cpl_frameset_get_position (dark_frameset, 0);
357 NULL, frame,
"gravity_biasmask",
366 FREE (cpl_frameset_delete, dark_frameset);
370 FREE (cpl_frameset_delete, flat_frameset);
371 FREE (cpl_frameset_delete, used_frameset);
378 return (
int)cpl_error_get_code();
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
#define GRAVI_RECIPE_OUTPUT
#define GRAVI_RECIPE_FLOW
#define GRAVI_BIASMASK_MAP
#define GRAVI_RECIPE_INPUT
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
#define CPLCHECK_INT(msg)
#define CPLCHECK_CLEAN(msg)
#define gravi_msg_function_exit(flag)
#define FREE(function, variable)
#define gravi_msg_function_start(flag)
#define FREELOOP(function, variable, n)
static int gravity_biasmask_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int gravity_biasmask_create(cpl_plugin *)
Setup the recipe options
static char gravity_biasmask_description[]
static char gravity_biasmask_short[]
static int gravity_biasmask_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int gravity_biasmask(cpl_frameset *, const cpl_parameterlist *)
Compute the DARK, BAD, FLAT, WAVE, P2VM from a list of calibration set.
gravi_data * gravi_compute_dark(gravi_data *raw_data)
Compute the DARK calibration map.
gravi_data * gravi_compute_biasmask(gravi_data *dark_map, gravi_data **flats_data, int nflat, const cpl_parameterlist *params)
Create BIASMASK for SC from raw FLATs and raw DARK.
cpl_error_code gravi_data_detector_cleanup(gravi_data *data, const cpl_parameterlist *parlist)
Perform self-bias correction to the SC raw data.
gravi_data * gravi_data_load_rawframe(cpl_frame *frame, cpl_frameset *used_frameset)
Load a RAW FITS file and create a gravi_data.
cpl_error_code gravi_data_save_new(gravi_data *self, cpl_frameset *allframes, const char *filename, const char *suffix, const cpl_parameterlist *parlist, cpl_frameset *usedframes, cpl_frame *frame, const char *recipe, cpl_propertylist *applist, const char *proCatg)
Save a gravi data in a CPL-complian FITS file.
void gravi_data_delete(gravi_data *self)
Delete a gravi data.
cpl_parameter * gravi_parameter_add_static_name(cpl_parameterlist *self)
cpl_frameset * gravi_frameset_extract_flat_data(cpl_frameset *frameset)
cpl_error_code gravi_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
void gravity_print_banner(void)
cpl_frameset * gravi_frameset_extract_dark_data(cpl_frameset *frameset)
Extract DARK_RAW frame from the input frameset.
const char * gravi_get_license(void)
Get the pipeline copyright and license.