ERIS Pipeline Reference Manual 1.9.2
eris_ifu_detlin_static.c
1/* $Id$
2 *
3 * This file is part of the ERIS Pipeline
4 * Copyright (C) 2002,2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "eris_ifu_detlin_static.h"
22#include "eris_ifu_error.h"
23#include "eris_ifu_utils.h"
24#include "eris_ifu_debug.h"
25#include "eris_ifu_dfs.h"
26#include "eris_utils.h"
27#include "eris_ifu_functions.h"
28#include "eris_pfits.h"
29#include "eris_utils.h"
30
31#include <hdrl.h>
32#include <string.h>
33#define FILE_NAME_SZ 256
34
35/*----------------------------------------------------------------------------*/
48/*----------------------------------------------------------------------------*/
49
52/*----------------------------------------------------------------------------*/
73/*----------------------------------------------------------------------------*/
74cpl_error_code eris_ifu_detlin_load_frames(const cpl_frameset *frameset,
75 int exposureCorrectionMode,
76 hdrl_imagelist **hdrl_imglist_on,
77 hdrl_imagelist **hdrl_imglist_off,
78 cpl_vector **vec_dit_on,
79 cpl_vector **vec_dit_off)
80{
81 cpl_error_code ret = CPL_ERROR_NONE;
82 const cpl_frame *fr = NULL;
83 const char *fn = NULL;
84 cpl_size nr_dit_on = 0,
85 nr_dit_off = 0;
86 double_t dit = 0.;
87 hdrl_image *tmp_img = NULL;
88 cpl_propertylist *pl = NULL;
89
90 cpl_ensure_code(frameset, CPL_ERROR_NULL_INPUT);
91 cpl_ensure_code(hdrl_imglist_on, CPL_ERROR_NULL_INPUT);
92 cpl_ensure_code(hdrl_imglist_off, CPL_ERROR_NULL_INPUT);
93 cpl_ensure_code(vec_dit_on, CPL_ERROR_NULL_INPUT);
94 cpl_ensure_code(vec_dit_off, CPL_ERROR_NULL_INPUT);
95
96 TRY
97 {
98 *hdrl_imglist_on = hdrl_imagelist_new();
99 *hdrl_imglist_off = hdrl_imagelist_new();
100 *vec_dit_on = cpl_vector_new(cpl_frameset_get_size(frameset));
101 *vec_dit_off = cpl_vector_new(cpl_frameset_get_size(frameset));
102
103 /*
104 * Loop through all LINEARITY_LAMP frames and save on- and off-frames
105 * accordingly in their cpl_imagelists
106 */
107 fr = cpl_frameset_find_const(frameset, ERIS_IFU_RAW_LIN);
108 while (fr != NULL) {
109 fn = cpl_frame_get_filename(fr);
111 tmp_img = eris_ifu_load_exposure_file(fn,
112 exposureCorrectionMode, NULL);
113
114 pl = cpl_propertylist_load(fn, 0);
115 dit = eris_ifu_get_dit(pl);
117
118 if (eris_ifu_frame_is_on(fr) == 1) {
119 hdrl_imagelist_set(*hdrl_imglist_on, tmp_img, nr_dit_on);
120 cpl_vector_set(*vec_dit_on, nr_dit_on++, dit);
121 } else {
122 hdrl_imagelist_set(*hdrl_imglist_off, tmp_img, nr_dit_off);
123 cpl_vector_set(*vec_dit_off, nr_dit_off++, dit);
124 }
125
126 /* next frame */
127 fr = cpl_frameset_find_const(frameset, NULL);
129 }
130 cpl_vector_set_size(*vec_dit_on, nr_dit_on);
131 cpl_vector_set_size(*vec_dit_off, nr_dit_off);
132
133 /*
134 * check if there are twice as dits of on- than and dits of off-frames
135 */
136 if (nr_dit_on != 2*nr_dit_off) {
137 cpl_msg_warning(cpl_func, "Found %lld on-frames and %lld off-frames, "
138 "but twice as many on-frmaes than off-frames are expected",
139 nr_dit_on, nr_dit_off);
140 }
141 }
142 CATCH
143 {
144 CATCH_MSGS();
145 ret = cpl_error_get_code();
146 eris_ifu_free_hdrl_imagelist(hdrl_imglist_on);
147 eris_ifu_free_hdrl_imagelist(hdrl_imglist_off);
148 eris_ifu_free_vector(vec_dit_on);
149 eris_ifu_free_vector(vec_dit_off);
150 }
151
153 eris_check_error_code("eris_ifu_detlin_load_frames");
154 return ret;
155}
156
157/*----------------------------------------------------------------------------*/
174/*----------------------------------------------------------------------------*/
175static cpl_error_code
176eris_detlin_qc_lin_log(hdrl_imagelist* fit_coef, cpl_image* chi2,
177 cpl_image* dof, cpl_mask* mask, cpl_propertylist* linc_qclist)
178{
179
180 cpl_mask* bpm;
181 cpl_size planes = hdrl_imagelist_get_size(fit_coef);
182 cpl_image* image = NULL;
183 cpl_image* error = NULL;
184 char* name_o1;
185 char* name_o2;
186
187 for(cpl_size deg = 0; deg < planes; deg++)
188 {
189
190 image = hdrl_image_get_image(hdrl_imagelist_get(fit_coef, deg));
191 error = hdrl_image_get_error(hdrl_imagelist_get(fit_coef, deg));
192 cpl_image_power(error, 2.);
193 cpl_image_multiply(error, chi2);
194 cpl_image_divide(error, dof);
195 cpl_image_power(error, 0.5);
196
197 bpm = cpl_image_set_bpm(image, mask);
198 const double coeff = cpl_image_get_median(image);
199 cpl_image_set_bpm(image, bpm);
200
201 name_o1 = cpl_sprintf("ESO QC LIN COEF%d", (int)deg);
202
203 cpl_propertylist_append_double(linc_qclist, name_o1, coeff);
204 cpl_propertylist_set_comment(linc_qclist, name_o1, ERIS_QC_LIN_COEF_C);
205
206 cpl_free(name_o1);
207 name_o1= NULL;
208
209 name_o2 = cpl_sprintf("ESO QC LIN COEF%d ERR", (int)deg);
210
211 bpm = cpl_image_set_bpm(error, mask);
212 const double coeff_err = cpl_image_get_median(error);
213 cpl_image_set_bpm(error, bpm);
214
215 cpl_propertylist_append_double(linc_qclist, name_o2, coeff_err);
216 cpl_propertylist_set_comment(linc_qclist, name_o2, ERIS_QC_LIN_COEF_ERR_C);
217
218 cpl_free(name_o2);
219 name_o2= NULL;
220
221 }
222 eris_check_error_code("eris_detlin_qc_lin_log");
223 return cpl_error_get_code();
224}
225
226/*----------------------------------------------------------------------------*/
248/*----------------------------------------------------------------------------*/
250 const cpl_parameterlist *parlist,
251 const hdrl_imagelist *imglist,
252 const cpl_vector *vec_dit,
253 cpl_propertylist* qclog)
254{
255 hdrl_parameter *hp = NULL;
256 cpl_image *bpm_fit = NULL;
257
258 cpl_ensure(parlist, CPL_ERROR_NULL_INPUT, NULL);
259 cpl_ensure(imglist, CPL_ERROR_NULL_INPUT, NULL);
260 cpl_ensure(vec_dit, CPL_ERROR_NULL_INPUT, NULL);
261
262 cpl_size nr_img = hdrl_imagelist_get_size(imglist),
263 nr_vec = cpl_vector_get_size(vec_dit);
264 cpl_ensure(nr_img == nr_vec, CPL_ERROR_ILLEGAL_INPUT, NULL);
265
266 TRY
267 {
268 // get bpm_fit-parameter
269 hp = hdrl_bpm_fit_parameter_parse_parlist(parlist, REC_NAME_DETLIN);
270
271 // calculate bpm_fit
272 hdrl_bpm_fit_compute(hp, imglist, vec_dit, &bpm_fit);
273
274 cpl_size sx = cpl_image_get_size_x(bpm_fit);
275 cpl_size sy = cpl_image_get_size_y(bpm_fit);
276 cpl_mask* mask = cpl_mask_new(sx, sy);
277 int* pbpm = cpl_image_get_data(bpm_fit);
278 cpl_binary* pmsk = cpl_mask_get_data(mask);
279 for (cpl_size j = 0; j < sy; j++) {
280 for (cpl_size i = 0; i < sx; i++) {
281 if(pbpm[i+j*sx] != 0 ) {
282 pmsk[i+j*sx] = BAD_PIX;
283 }
284 }
285 }
286 /* flag pixels defined in bpm_fit into hdrl imagelist imglist */
287 cpl_image* image;
288 cpl_image* error;
289 hdrl_image* hima;
290
291 for(cpl_size i = 0; i < hdrl_imagelist_get_size(imglist); i++) {
292 hima = hdrl_imagelist_get(imglist,i);
293 image = hdrl_image_get_image(hima);
294 cpl_image_reject_from_mask(image, mask);
295 error = hdrl_image_get_error(hima);
296 cpl_image_reject_from_mask(error, mask);
297 //cpl_image_set_bpm(error, mask);
298 }
299
300 cpl_image * out_chi2 = NULL, * out_dof = NULL;
301 hdrl_imagelist * out_coef = NULL;
302 int order = hdrl_bpm_fit_parameter_get_degree(hp);
303 hdrl_fit_polynomial_imagelist(imglist, vec_dit, order, &out_coef,
304 &out_chi2, &out_dof);
305
306 /* log fit coeff as QC params */
307 eris_detlin_qc_lin_log(out_coef, out_chi2, out_dof, mask, qclog);
308 hdrl_imagelist_delete(out_coef);
309 cpl_image_delete(out_chi2);
310 cpl_image_delete(out_dof);
311 cpl_mask_delete(mask);
312 eris_ifu_get_badpix_qc_from_ima(bpm_fit, qclog, "LINEARITY");
313 }
314 CATCH
315 {
316 CATCH_MSGS();
317 eris_ifu_free_image(&bpm_fit);
318 }
320 eris_check_error_code("eris_ifu_detlin_compute_linearity");
321 return bpm_fit;
322}
323
324/*----------------------------------------------------------------------------*/
342/*----------------------------------------------------------------------------*/
343cpl_mask* eris_ifu_detlin_filter_mask(const cpl_mask *bpm,
344 const cpl_parameterlist *parlist)
345{
346 cpl_mask *filtered = NULL;
347 const cpl_parameter *p = NULL;
348 int pfx = 0,
349 pfy = 0;
350 const char *pfm = NULL;
351 cpl_filter_mode filter_mode = CPL_FILTER_CLOSING;
352
353 cpl_ensure(bpm, CPL_ERROR_NULL_INPUT, NULL);
354 cpl_ensure(parlist, CPL_ERROR_NULL_INPUT, NULL);
355
356 TRY
357 {
358 p = cpl_parameterlist_find_const(parlist,
359 REC_NAME_DETLIN".post-filter-x");
360 pfx = cpl_parameter_get_int(p);
362
363 p = cpl_parameterlist_find_const(parlist,
364 REC_NAME_DETLIN".post-filter-y");
365 pfy = cpl_parameter_get_int(p);
367
368 p = cpl_parameterlist_find_const(parlist,
369 REC_NAME_DETLIN".post-filter-mode");
370 pfm = cpl_parameter_get_string(p);
371
372 if (!strcmp(pfm, "closing")) {
373 filter_mode = CPL_FILTER_CLOSING ;
374 }
375 else if (!strcmp(pfm, "dilation")) {
376 filter_mode = CPL_FILTER_DILATION ;
377 }
378 else {
380 CPL_ERROR_ILLEGAL_INPUT,
381 "Filter mode can only be \"closing\" or \"dilation\" (not %s)",
382 pfm);
383 }
384
385 /* Post Filtering */
386 if ((pfx > 0) && (pfy > 0)) {
388 filtered = hdrl_bpm_filter(bpm, pfx, pfy, filter_mode));
389 }
390 }
391 CATCH
392 {
393 CATCH_MSGS();
394 eris_ifu_free_mask(&filtered);
395 }
396 eris_check_error_code("eris_ifu_detlin_filter_mask");
397 return filtered;
398}
399
400/*----------------------------------------------------------------------------*/
422/*----------------------------------------------------------------------------*/
423static int
424eris_get_clean_mean_window(cpl_image* img,
425 int llx, int lly, int urx, int ury,
426 const int kappa, const int nclip,
427 double* local_clean_mean,
428 double* clean_stdev)
429{
430
431 double mean = 0;
432 double stdev = 0;
433
434 cpl_image * tmp = NULL;
435 cpl_stats * stats = NULL;
436 int i = 0;
437
438 tmp = cpl_image_extract(img, llx, lly, urx, ury);
439 cpl_image_accept_all(tmp);
440 for(i = 0; i < nclip; i++) {
441
442 cpl_stats_delete(stats);
443 stats = cpl_stats_new_from_image(tmp, CPL_STATS_MEAN | CPL_STATS_STDEV);
444 mean = cpl_stats_get_mean(stats);
445 stdev = cpl_stats_get_stdev(stats);
446
447 double threshold = kappa * stdev;
448 double lo_cut = mean - threshold;
449 double hi_cut = mean + threshold;
450 cpl_image_accept_all(tmp);
451 cpl_mask* mask = cpl_mask_threshold_image_create(tmp, lo_cut, hi_cut);
452
453 cpl_mask_not(mask);
454 cpl_image_reject_from_mask(tmp, mask);
455 cpl_mask_delete(mask);
456
457 }
458 *local_clean_mean = mean;
459 *clean_stdev = stdev;
460 cpl_image_delete(tmp);
461 cpl_stats_delete(stats);
462 eris_check_error_code("eris_get_clean_mean_window");
463 return 0;
464
465}
466
467/*----------------------------------------------------------------------------*/
492/*----------------------------------------------------------------------------*/
493cpl_table* eris_compute_gain(cpl_frameset* frameset)
494{
495
496 cpl_ensure(frameset,CPL_ERROR_NULL_INPUT, NULL);
497
498 cpl_frame* frm = NULL;
499
500 cpl_image* img_on1 = NULL;
501 cpl_image* img_on2 = NULL;
502 cpl_image* img_on_dif = NULL;
503 cpl_image* img_on_sub = NULL;
504
505
506 cpl_image* img_of1 = NULL;
507 cpl_image* img_of2 = NULL;
508 cpl_image* img_of_dif = NULL;
509 cpl_image* img_of_sub = NULL;
510
511 cpl_table* res_tbl = NULL;
512 cpl_vector* dit_on = NULL;
513 cpl_vector* dit_of = NULL;
514 cpl_vector* exptime_on = NULL;
515 cpl_vector* exptime_of = NULL;
516 cpl_propertylist* plist = NULL;
517
518 int non = 0;
519 int nof = 0;
520 int nfr = 0;
521 double avg_on1 = 0;
522 double avg_on2 = 0;
523 double avg_of1 = 0;
524 double avg_of2 = 0;
525 double std = 0;
526
527 double sig_on_dif = 0;
528 double sig_of_dif = 0;
529 char* name = NULL;
530 int i = 0;
531 int m = 0;
532
533 int llx = 270;
534 int lly = 1000;
535 int urx = 320;
536 int ury = 1050;
537 //int zone[4];
538 double gain = 0;
539 double dit_ref = 0;
540 double dit_tmp = 0;
541 double exptime_ref = 0;
542 double exptime_tmp = 0;
543 int kappa = 5;
544 int nclip = 25;
545 double centre = 0;
546
547 cpl_size nff = cpl_frameset_get_size(frameset);
548 cpl_frameset* son = cpl_frameset_new();
549 cpl_frameset* sof = cpl_frameset_new();
550 cpl_frame* frm_dup;
551 /* separates on and off frames */
552
553 for(i = 0; i < nff; i++) {
554 frm = cpl_frameset_get_position(frameset, i);
555 frm_dup = cpl_frame_duplicate(frm);
556 if(eris_ifu_frame_is_on(frm)) {
557 cpl_frameset_insert(son, frm_dup);
558 } else {
559 cpl_frameset_insert(sof, frm_dup);
560 }
561 }
562
563 non = cpl_frameset_get_size(son);
564 nof = cpl_frameset_get_size(sof);
565 nfr = (non <= nof) ? non : nof;
566
567 dit_on = cpl_vector_new(nfr);
568 dit_of = cpl_vector_new(nfr);
569 exptime_on = cpl_vector_new(nfr);
570 exptime_of = cpl_vector_new(nfr);
571
572 for(i = 0; i < nfr; i++) {
573
574 frm = cpl_frameset_get_position(son, i);
575 name = (char*) cpl_frame_get_filename(frm);
576 plist = cpl_propertylist_load(name, 0);
577 dit_ref = eris_pfits_get_dit(plist);
578 exptime_ref = cpl_propertylist_get_double(plist, "EXPTIME");
579 cpl_propertylist_delete(plist);
580 cpl_vector_set(dit_on, i, dit_ref);
581 cpl_vector_set(exptime_on, i, exptime_ref);
582
583 frm = cpl_frameset_get_position(sof, i);
584 name = (char*) cpl_frame_get_filename(frm);
585 plist = cpl_propertylist_load(name, 0);
586 dit_ref = eris_pfits_get_dit(plist);
587 exptime_ref = cpl_propertylist_get_double(plist, "EXPTIME");
588 cpl_propertylist_delete(plist);
589 cpl_vector_set(dit_of, i, dit_ref);
590 cpl_vector_set(exptime_of, i, exptime_ref);
591
592 }
593
594 res_tbl = cpl_table_new(nfr);
595 cpl_table_new_column(res_tbl, "adu", CPL_TYPE_DOUBLE);
596 cpl_table_new_column(res_tbl, "gain", CPL_TYPE_DOUBLE);
597
598 for(i = 0; i < nfr; i++) {
599 frm = cpl_frameset_get_position(son, i);
600 name = (char*) cpl_frame_get_filename(frm);
601 img_on1 = cpl_image_load(name, CPL_TYPE_DOUBLE, 0, 0);
602
603 frm = cpl_frameset_get_position(sof, i);
604 name = (char*) cpl_frame_get_filename(frm);
605 img_of1 = cpl_image_load(name, CPL_TYPE_DOUBLE, 0, 0);
606
607
608 dit_ref = cpl_vector_get(dit_on, i);
609 exptime_ref = cpl_vector_get(exptime_on, i);
610
611 for(m = 0; m < nfr; m++) {
612 if(m != i) {
613 frm = cpl_frameset_get_position(son, m);
614 name = (char*) cpl_frame_get_filename(frm);
615 dit_tmp = cpl_vector_get(dit_on, m);
616 exptime_tmp = cpl_vector_get(exptime_on, m);
617 if(dit_tmp == dit_ref && exptime_tmp == exptime_ref) {
618 /* eris_msg("m=%d i=%d\n", m, i); */
619 img_on2 = cpl_image_load(name, CPL_TYPE_DOUBLE, 0, 0);
620 frm = cpl_frameset_get_position(sof, m);
621 name = (char*) cpl_frame_get_filename(frm);
622 img_of2 = cpl_image_load(name, CPL_TYPE_DOUBLE, 0, 0);
623
624 img_on_dif = cpl_image_subtract_create(img_on1, img_on2);
625 img_of_dif = cpl_image_subtract_create(img_of1, img_of2);
626
627 img_on_sub = cpl_image_extract(img_on_dif, llx, lly, urx, ury);
628 img_of_sub = cpl_image_extract(img_of_dif, llx, lly, urx, ury);
629
630 eris_get_clean_mean_window(img_on1, llx, lly, urx, ury, kappa,
631 nclip, &avg_on1, &std);
632 eris_get_clean_mean_window(img_on2, llx, lly, urx, ury, kappa,
633 nclip, &avg_on2, &std);
634 eris_get_clean_mean_window(img_of1, llx, lly, urx, ury, kappa,
635 nclip, &avg_of1, &std);
636 eris_get_clean_mean_window(img_of2, llx, lly, urx, ury, kappa,
637 nclip, &avg_of2, &std);
638 /*
639 cpl_image_save(img_on_sub, "ima_on_sub.fits",
640 CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT);
641 cpl_image_save(img_of_sub, "ima_of_sub.fits",
642 CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT);
643 */
644 /*
645 //worse accuracy
646 eris_stat_rectangle(img_on_dif, kappa, nclip, &centre, &sig_on_dif);
647 eris_stat_rectangle(img_of_dif, kappa, nclip, &centre, &sig_of_dif);
648 */
649
650
651 //better accuracy
652 eris_get_clean_mean_window(img_on_dif, llx, lly, urx, ury, kappa,
653 nclip, &centre, &sig_on_dif);
654 eris_get_clean_mean_window(img_of_dif, llx, lly, urx, ury, kappa,
655 nclip, &centre, &sig_of_dif);
667 cpl_image_delete(img_on2);
668 cpl_image_delete(img_of2);
669 cpl_image_delete(img_on_dif);
670 cpl_image_delete(img_of_dif);
671 cpl_image_delete(img_on_sub);
672 cpl_image_delete(img_of_sub);
673
674 gain = ( (avg_on1 + avg_on2) - (avg_of1 + avg_of2) ) /
675 ( (sig_on_dif * sig_on_dif) - (sig_of_dif * sig_of_dif) );
676
677 cpl_table_set_double(res_tbl, "gain", m, gain);
678 cpl_table_set_double(res_tbl, "adu", m,
679 ( (avg_on1 + avg_on2) / 2 - (avg_of1 + avg_of2) / 2) );
680 /* eris_msg("gain=%f ADU=%f\n",gain,
681 (avg_on1 + avg_on2) / 2 - (avg_of1 + avg_of2) / 2);
682 eris_msg("g=%f avg_on1=%f avg_on2=%f", gain, avg_on1, avg_on2);
683 eris_msg("avg_of1=%f avg_of2=%f sig_on_dif=%f sig_of_dif=%f",
684 avg_of1, avg_of2, sig_on_dif, sig_of_dif);
685 */
686
687 }
688 }
689 }
690 cpl_image_delete(img_on1);
691 cpl_image_delete(img_of1);
692 }
693
694
695 /*
696 eris_get_clean_mean_window(img_on_dif, llx, lly, urx, ury, kappa,
697 nclip, &avg, &sig_on_dif);
698 eris_get_clean_mean_window(img_of_dif, llx, lly, urx, ury, kappa,
699 nclip, &avg, &sig_of_dif);
700 */
701
702 cpl_vector_delete(dit_on);
703 cpl_vector_delete(dit_of);
704 cpl_vector_delete(exptime_on);
705 cpl_vector_delete(exptime_of);
706 cpl_frameset_delete(son);
707 cpl_frameset_delete(sof);
708 eris_check_error_code("eris_compute_gain");
709 return res_tbl;
710
711}
712
cpl_mask * eris_ifu_detlin_filter_mask(const cpl_mask *bpm, const cpl_parameterlist *parlist)
Apply morphological filtering to a bad pixel mask.
cpl_error_code eris_ifu_detlin_load_frames(const cpl_frameset *frameset, int exposureCorrectionMode, hdrl_imagelist **hdrl_imglist_on, hdrl_imagelist **hdrl_imglist_off, cpl_vector **vec_dit_on, cpl_vector **vec_dit_off)
Load linearity calibration frames from a frameset.
cpl_table * eris_compute_gain(cpl_frameset *frameset)
Compute detector gain from linearity frames.
cpl_image * eris_ifu_detlin_compute_linearity(const cpl_parameterlist *parlist, const hdrl_imagelist *imglist, const cpl_vector *vec_dit, cpl_propertylist *qclog)
Compute detector linearity bad pixel map.
float eris_ifu_get_dit(cpl_propertylist *header)
Get the detector integration time (DIT) from FITS header.
bool eris_ifu_frame_is_on(const cpl_frame *fr)
Determine if a frame has calibration lamps ON or OFF.
#define CHECK_ERROR_STATE(void)
Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.
#define BRK_WITH_ERROR_MSG(code,...)
Set a new CPL error, and exit the try-block.
#define TRY
Beginning of a TRY-block.
#define CATCH
End of a TRY-block, beginning of a CATCH-block.
#define BRK_IF_NULL(function)
If function is or returns a NULL pointer, then the try-block is exited.
#define CATCH_MSGS()
Displays an error message stack.
hdrl_image * eris_ifu_load_exposure_file(const char *filename, int exposureCorrectionMode, cpl_image *dqi)
Load a raw detector exposure from file with corrections and noise.
void eris_ifu_free_propertylist(cpl_propertylist **item)
Free memory and set pointer to null.
void eris_ifu_free_vector(cpl_vector **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_file_exists(const char *filename)
‍**
cpl_error_code eris_ifu_get_badpix_qc_from_ima(const cpl_image *image, cpl_propertylist *qc_list, const char *prefix)
compute QC keyword with number of bad pixels and fraction to total
void eris_ifu_free_hdrl_imagelist(hdrl_imagelist **item)
Free memory and set pointer to null.
void eris_ifu_free_image(cpl_image **item)
Free memory and set pointer to null.
void eris_ifu_free_mask(cpl_mask **item)
Free memory and set pointer to null.
void eris_ifu_free_hdrl_parameter(hdrl_parameter **item)
Free memory and set pointer to null.
double eris_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
Definition: eris_pfits.c:98
cpl_error_code eris_check_error_code(const char *func_id)
handle CPL errors
Definition: eris_utils.c:56
hdrl_parameter * hdrl_bpm_fit_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
Parse a parameterlist to create input parameters for the BPM_FIT.
Definition: hdrl_bpm_fit.c:442
int hdrl_bpm_fit_parameter_get_degree(const hdrl_parameter *p)
get degree of polynomial fit of parameter
Definition: hdrl_bpm_fit.c:263
cpl_error_code hdrl_bpm_fit_compute(const hdrl_parameter *par, const hdrl_imagelist *data, const cpl_vector *sample_pos, cpl_image **out_mask)
compute bad pixel map based on fitting a stack of images
Definition: hdrl_bpm_fit.c:587
cpl_mask * hdrl_bpm_filter(const cpl_mask *input_mask, cpl_size kernel_nx, cpl_size kernel_ny, cpl_filter_mode filter)
Allows the growing and shrinking of bad pixel masks. It can be used to e.g. set pixels to bad if the ...
cpl_error_code hdrl_fit_polynomial_imagelist(const hdrl_imagelist *list, const cpl_vector *samplepos, const int degree, hdrl_imagelist **coef, cpl_image **chi2, cpl_image **dof)
weighted least squares polynomial fit of each pixel of a imagelist
Definition: hdrl_fit.c:367
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
Definition: hdrl_image.c:131
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
Definition: hdrl_image.c:105
cpl_error_code hdrl_imagelist_set(hdrl_imagelist *himlist, hdrl_image *himg, cpl_size pos)
Insert an image into an imagelist.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.
cpl_size hdrl_imagelist_get_size(const hdrl_imagelist *himlist)
Get the number of images in the imagelist.
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.
hdrl_image * hdrl_imagelist_get(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.