33#include "moo_params.h"
34#include "moo_single.h"
35#include "moo_psf_single.h"
36#include "moo_badpix.h"
37#include "moo_apply_p2p.h"
68_moo_apply_p2p_single(moo_single *flat, moo_single *p2pmap)
70 cpl_ensure_code(flat != NULL, CPL_ERROR_NULL_INPUT);
71 cpl_ensure_code(p2pmap != NULL, CPL_ERROR_NULL_INPUT);
73 cpl_errorstate prestate = cpl_errorstate_get();
75 cpl_msg_indent_more();
77 cpl_mask *mask1 = hdrl_image_get_mask(flat->image);
78 cpl_mask *mask2 = hdrl_image_get_mask(p2pmap->image);
79 cpl_mask *orig = cpl_mask_duplicate(mask1);
81 cpl_mask_or(orig, mask2);
83 hdrl_image_div_image(flat->image, p2pmap->image);
86 cpl_mask_and(orig, mask1);
90 cpl_mask_delete(orig);
92 cpl_msg_indent_less();
94 if (!cpl_errorstate_is_equal(prestate)) {
95 cpl_msg_error(__func__,
"Error in apply_p2p");
96 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
98 cpl_errorstate_set(prestate);
100 return CPL_ERROR_NONE;
124 cpl_errorstate prestate = cpl_errorstate_get();
127 cpl_ensure_code(flat != NULL, CPL_ERROR_NULL_INPUT);
128 cpl_ensure_code(p2pmap != NULL, CPL_ERROR_NULL_INPUT);
130 cpl_msg_info(__func__,
"Apply pixel-to-pixel variation map");
134 cpl_msg_indent_more();
136 for (
int i = 1; i <= 2; i++) {
137 for (
int j = 0; j < 3; j++) {
138 moo_single *det_single =
141 if (det_single != NULL) {
142 moo_single *p2p_single =
145 if (p2p_single != NULL) {
146 cpl_msg_info(__func__,
"Apply p2p for extension %s",
148 _moo_apply_p2p_single(det_single, p2p_single);
153 cpl_msg_indent_less();
155 if (!cpl_errorstate_is_equal(prestate)) {
156 cpl_msg_error(__func__,
"Error in apply_p2p");
157 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
159 cpl_errorstate_set(prestate);
161 return CPL_ERROR_NONE;
cpl_error_code moo_mask_to_badpix(cpl_image *badpix, cpl_mask *mask, unsigned int level)
Add the mask of the badpix level to the badpix map.
cpl_error_code moo_badpix_merge(cpl_image *badpix1, cpl_image *badpix2)
Merge to bad pixel map.
#define MOO_BADPIX_CALIB_DEFECT
moo_single * moo_det_load_single(moo_det *self, moo_detector_type type, int num, int level)
Load the type part in DET and return it.
cpl_propertylist * moo_det_get_primary_header(moo_det *self)
Get the PRIMARY HEADER in DET.
const char * moo_detector_get_extname(moo_detector_type type, int ntas)
Get the extension name of a detector.
cpl_error_code moo_apply_p2p(moo_det *flat, moo_det *p2pmap)
Divide DET by the pixel-to-pixel variation map.
cpl_error_code moo_qc_set_is_p2pcor(cpl_propertylist *plist, cpl_boolean val)
Set the QC.IS.P2PCOR value.