55static int gravity_dark(cpl_frameset *,
const cpl_parameterlist *);
63 "This recipe computes the DARK calibration for the SC, the FT and the ACQ detectors. The SC detector is first debiased using the biaspixels, before computing the dark mean and rms. For detectors, the mean dark level of each pixel and the stdev of each pixel are saved in the output product.\n"
65 "* Loop on input dark files and concatenate them\n"
66 "* Compute the median and rms of these concatenated files\n"
67 "* Save the product (FT, SC, ACQ camera into same product)\n"
91 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe );
92 cpl_plugin * plugin = &recipe->interface;
94 if (cpl_plugin_init(plugin,
97 CPL_PLUGIN_TYPE_RECIPE,
101 "Nabih Azouaoui, Vincent Lapeyrere, JB. Le Bouquin",
107 cpl_msg_error(cpl_func,
"Plugin initialization failed");
108 (void)cpl_error_set_where(cpl_func);
112 if (cpl_pluginlist_append(list, plugin)) {
113 cpl_msg_error(cpl_func,
"Error adding plugin to list");
114 (void)cpl_error_set_where(cpl_func);
136 if (cpl_error_get_code() != CPL_ERROR_NONE) {
137 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
138 cpl_func, __LINE__, cpl_error_get_where());
139 return (
int)cpl_error_get_code();
142 if (plugin == NULL) {
143 cpl_msg_error(cpl_func,
"Null plugin");
144 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
148 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
149 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
150 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
154 recipe = (cpl_recipe *)plugin;
157 recipe->parameters = cpl_parameterlist_new();
158 if (recipe->parameters == NULL) {
159 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
160 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
185 cpl_errorstate initial_errorstate = cpl_errorstate_get();
188 if (cpl_error_get_code() != CPL_ERROR_NONE) {
189 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
190 cpl_func, __LINE__, cpl_error_get_where());
191 return (
int)cpl_error_get_code();
194 if (plugin == NULL) {
195 cpl_msg_error(cpl_func,
"Null plugin");
196 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
200 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
201 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
202 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
206 recipe = (cpl_recipe *)plugin;
209 if (recipe->parameters == NULL) {
210 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
211 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
213 if (recipe->frames == NULL) {
214 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
215 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
219 recipe_status =
gravity_dark(recipe->frames, recipe->parameters);
222 if (cpl_dfs_update_product_header(recipe->frames)) {
223 if (!recipe_status) recipe_status = (int)cpl_error_get_code();
226 if (!cpl_errorstate_is_equal(initial_errorstate)) {
229 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
232 return recipe_status;
246 if (plugin == NULL) {
247 cpl_msg_error(cpl_func,
"Null plugin");
248 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
252 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
253 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
254 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
258 recipe = (cpl_recipe *)plugin;
260 cpl_parameterlist_delete(recipe->parameters);
275 const cpl_parameterlist * parlist)
277 cpl_frameset * dark_frameset = NULL, * used_frameset = NULL;
278 cpl_frame * frame = NULL;
279 gravi_data * raw_dark = NULL, * reduced_dark = NULL;
294 if (cpl_frameset_is_empty (dark_frameset)) {
295 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
296 "No DARK_RAW file on the frameset") ;
301 nb_frame = cpl_frameset_get_size (dark_frameset);
302 used_frameset = cpl_frameset_new ();
304 for (comp = 0; comp < nb_frame; comp++){
306 cpl_frame * frame_tmp;
308 char filename_suffix[20];
309 snprintf(filename_suffix, 16,
"%d", comp);
312 frame_tmp = cpl_frameset_get_position (dark_frameset, comp);
320 dark_frameset, frame_tmp,
"gravity_dark",
321 NULL,
"BIAS_SUBTRACTED");
336 raw_dark = data_tmp; data_tmp = NULL;
358 used_frameset, frame,
"gravity_dark",
372 FREE (cpl_frameset_delete, dark_frameset);
373 FREE (cpl_frameset_delete, used_frameset);
376 return (
int)cpl_error_get_code();
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
#define GRAVI_RECIPE_OUTPUT
#define GRAVI_RECIPE_FLOW
#define GRAVI_RECIPE_INPUT
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
#define CPLCHECK_CLEAN(msg)
#define gravi_msg_function_exit(flag)
#define FREE(function, variable)
#define gravi_msg_function_start(flag)
static int gravity_dark_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int gravity_dark_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 char gravity_dark_short[]
static char gravity_dark_description[]
static int gravity_dark_create(cpl_plugin *)
Setup the recipe options
static int gravity_dark(cpl_frameset *, const cpl_parameterlist *)
Compute the master dark for each dark frames.
gravi_data * gravi_compute_dark(gravi_data *raw_data)
Compute the DARK calibration map.
cpl_error_code gravi_data_erase(gravi_data *self, const char *extname)
Erase an extension by its EXTNAME.
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_append(gravi_data *first, const gravi_data *second, int force)
Append a gravi_data into another existing one.
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.
int gravi_param_get_bool(const cpl_parameterlist *parlist, const char *name)
cpl_parameter * gravi_parameter_add_static_name(cpl_parameterlist *self)
cpl_parameter * gravi_parameter_add_biasmethod(cpl_parameterlist *self)
cpl_error_code gravi_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
cpl_parameter * gravi_parameter_add_biassub_file(cpl_parameterlist *self)
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.