32#include "hdrl_persistence.c"
36static cpl_error_code get_error_and_reset(
void){
37 cpl_error_code r = cpl_error_get_code();
47#define ARRAY_LEN(a) (sizeof((a))/sizeof((a)[0]))
54 cpl_frame* frm = cpl_frame_new();
56 cpl_test_error(CPL_ERROR_NONE);
57 cpl_test_nonnull(frm);
59 cpl_image_add_scalar(NULL, 1);
60 cpl_test_error(CPL_ERROR_NULL_INPUT);
63 cpl_test_abs(1, 1, HDRL_EPS_DATA);
64 cpl_test_rel(1, 1, HDRL_EPS_DATA);
68 cpl_frame_delete(frm);
70 cpl_test_error(CPL_ERROR_NONE);
75static hdrl_imagelist *
76test_hdrl_persistence_mkhilist(
83 for (
int i=0; i<n; i++) {
86 if (!zero) cpl_image_fill_noise_uniform(im, -1, 1);
94test_hdrl_persistence_make_trapMEF(
111 cpl_image * max = cpl_image_new(maxx, maxy, maxt);
112 cpl_image * den = cpl_image_new(denx, deny, dent);
113 cpl_image * fullwell = cpl_image_new(fullwellx, fullwelly, fullwellt);
114 cpl_table * frac = cpl_table_new(tabrows);
115 cpl_table_new_column(frac, tabc1n, tabc1t);
116 cpl_table_new_column(frac, tabc2n, tabc2t);
118 cpl_propertylist * plist = cpl_propertylist_new();
120 cpl_image_save(0, fn, CPL_TYPE_DOUBLE, 0, CPL_IO_CREATE);
122 cpl_propertylist_update_string(plist,
"EXTNAME",
"PERSIST_TRAP_MAX");
123 cpl_image_save(max, fn, cpl_image_get_type(max), plist, CPL_IO_EXTEND);
125 cpl_propertylist_update_string(plist,
"EXTNAME",
"PERSIST_TRAP_DENSITY");
126 cpl_image_save(den, fn, cpl_image_get_type(den), plist, CPL_IO_EXTEND);
128 cpl_propertylist_update_string(plist,
"EXTNAME",
"PERSIST_FULL_WELL");
129 cpl_image_save(fullwell, fn, cpl_image_get_type(fullwell), plist, CPL_IO_EXTEND);
131 cpl_propertylist_update_string(plist,
"EXTNAME",
"PERSIST_TRAP_FRACTION");
132 cpl_table_save(frac, 0, plist, fn, CPL_IO_EXTEND);
133 cpl_propertylist_delete(plist);
134 cpl_table_delete(frac);
135 cpl_image_delete(den);
136 cpl_image_delete(fullwell);
137 cpl_image_delete(max);
150static cpl_error_code test_hdrl_persistence_read_info(
152 cpl_image ** maximum,
153 cpl_image ** density,
154 cpl_image ** fullwell,
159 maximum && !*maximum && density && !*density && fullwell && !*fullwell
160 && frac && !*frac, CPL_ERROR_NULL_INPUT,
return CPL_ERROR_ILLEGAL_INPUT,
161 " Input should be non-NULL but pointers to NULL");
165 cpl_size extmax = cpl_fits_find_extension(traps_,
"PERSIST_TRAP_MAX");
166 cpl_size extdens = cpl_fits_find_extension(traps_,
"PERSIST_TRAP_DENSITY");
167 cpl_size extfullwell = cpl_fits_find_extension(traps_,
"PERSIST_FULL_WELL");
168 cpl_size extfraction = cpl_fits_find_extension(traps_,
"PERSIST_TRAP_FRACTION");
170 cpl_error_ensure(!cpl_error_get_code(), CPL_ERROR_ILLEGAL_INPUT,
171 return CPL_ERROR_DATA_NOT_FOUND,
172 "Can not find at least one of the required extensions");
174 *maximum = cpl_image_load(traps_, CPL_TYPE_DOUBLE, 0, extmax);
175 if(cpl_error_get_code() != CPL_ERROR_NONE) {
176 return cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
177 "Couldn't load maximum trap map");
180 *density = cpl_image_load(traps_, CPL_TYPE_DOUBLE, 0, extdens);
181 if(cpl_error_get_code() != CPL_ERROR_NONE) {
182 cpl_image_delete(*maximum);
184 return cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
185 "Couldn't load trap density map");
188 *fullwell = cpl_image_load(traps_, CPL_TYPE_DOUBLE, 0, extfullwell);
189 if(cpl_error_get_code() != CPL_ERROR_NONE) {
190 cpl_image_delete(*maximum);
191 cpl_image_delete(*density);
194 return cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
195 "Couldn't load full well map");
198 *frac = cpl_table_load(traps_, extfraction, 0);
199 if(cpl_error_get_code() != CPL_ERROR_NONE) {
200 cpl_image_delete(*maximum);
201 cpl_image_delete(*density);
202 cpl_image_delete(*fullwell);
207 return cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
208 "Couldn't load trap fraction table");
210 return CPL_ERROR_NONE;
218test_hdrl_persistence_verify_inputs(
void)
249 cpl_array * good_dates = cpl_array_new(2, CPL_TYPE_DOUBLE);
250 cpl_array * bad1_dates = NULL;
251 cpl_array * bad2_dates = cpl_array_new(0, CPL_TYPE_DOUBLE);
252 cpl_array * bad3_dates = cpl_array_new(3, CPL_TYPE_DOUBLE);
253 cpl_array * bad4_dates = cpl_array_new(2, CPL_TYPE_STRING);
256 cpl_array * good_exps = cpl_array_new(1, CPL_TYPE_DOUBLE);
257 cpl_array * bad1_exps = NULL;
258 cpl_array * bad2_exps = cpl_array_new(0, CPL_TYPE_DOUBLE);
259 cpl_array * bad3_exps = cpl_array_new(2, CPL_TYPE_DOUBLE);
260 cpl_array * bad4_exps = cpl_array_new(1, CPL_TYPE_STRING);
263 hdrl_imagelist * good_illums = test_hdrl_persistence_mkhilist(1, 3, 3, 0);
264 hdrl_imagelist * bad1_illums = NULL;
266 hdrl_imagelist * bad3_illums = test_hdrl_persistence_mkhilist(2, 3, 3, 0);
267 hdrl_imagelist * bad5_illums = test_hdrl_persistence_mkhilist(1, 4, 4, 0);
270 const char * good_trap = test_hdrl_persistence_make_trapMEF(
"good_vi_trap.fits",
271 3, 3, CPL_TYPE_DOUBLE, 3, 3, CPL_TYPE_DOUBLE, 3, 3, CPL_TYPE_DOUBLE, 6,
272 "TAU", CPL_TYPE_FLOAT,
"NU", CPL_TYPE_FLOAT);
296 cpl_mask * good_bpm = cpl_mask_new(3, 3);
300 cpl_imagelist * good_srcmasks = cpl_imagelist_new();
301 cpl_imagelist_set(good_srcmasks, cpl_image_new(3, 3, CPL_TYPE_INT), 0);
303 cpl_imagelist * bad2_srcmasks = cpl_imagelist_new();
304 cpl_imagelist * bad3_srcmasks = cpl_imagelist_new();
305 cpl_imagelist_set(bad3_srcmasks, cpl_image_new(3, 3, CPL_TYPE_INT), 0);
306 cpl_imagelist_set(bad3_srcmasks, cpl_image_new(3, 3, CPL_TYPE_INT), 1);
307 cpl_imagelist * bad4_srcmasks = cpl_imagelist_new();
308 cpl_imagelist_set(bad4_srcmasks, cpl_image_new(3, 3, CPL_TYPE_FLOAT), 0);
311 cpl_image * good_max = NULL;
312 cpl_image * bad1_max = cpl_image_new(3, 3, CPL_TYPE_DOUBLE);
315 cpl_image * good_den = NULL;
316 cpl_image * bad1_den = cpl_image_new(3, 3, CPL_TYPE_DOUBLE);
319 cpl_image * good_fullwell = NULL;
320 cpl_image * bad1_fullwell = cpl_image_new(3, 3, CPL_TYPE_DOUBLE);
323 cpl_table * good_frac = NULL;
324 cpl_table * bad1_frac = cpl_table_new(3);
326 test_hdrl_persistence_read_info(good_trap, &good_max, &good_den, &good_fullwell, &good_frac);
330 hdrl_persistence_verify_inputs(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
331 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
333 hdrl_persistence_verify_inputs(1.0,
334 10., 1000.0, CPL_FALSE, good_dates, good_exps, good_illums,
335 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
336 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
338 hdrl_persistence_verify_inputs(1.0,
339 1.0, 1.0, CPL_FALSE, bad1_dates, good_exps, good_illums,
340 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
341 cpl_test_error(CPL_ERROR_NULL_INPUT);
343 hdrl_persistence_verify_inputs(1.0,
344 1.0, 1.0, CPL_FALSE, good_dates, bad1_exps, good_illums,
345 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
346 cpl_test_error(CPL_ERROR_NULL_INPUT);
348 hdrl_persistence_verify_inputs(1.0,
349 1.0, 1.0, CPL_FALSE, good_dates, good_exps, bad1_illums,
350 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
351 cpl_test_error(CPL_ERROR_NULL_INPUT);
353 hdrl_persistence_verify_inputs(1.0,
354 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
355 good_srcmasks, NULL, good_den, good_fullwell, good_frac);
356 cpl_test_error(CPL_ERROR_NULL_INPUT);
358 hdrl_persistence_verify_inputs(1.0,
359 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
360 good_srcmasks, good_max, NULL, good_fullwell, good_frac);
361 cpl_test_error(CPL_ERROR_NULL_INPUT);
363 hdrl_persistence_verify_inputs(1.0,
364 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
365 good_srcmasks, good_max, good_den, good_fullwell, NULL);
366 cpl_test_error(CPL_ERROR_NULL_INPUT);
389 hdrl_persistence_verify_inputs(1.0,
390 1.0, 1.0, CPL_FALSE, bad2_dates, good_exps, good_illums,
391 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
392 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
394 hdrl_persistence_verify_inputs(1.0,
395 1.0, 1.0, CPL_FALSE, bad3_dates, good_exps, good_illums,
396 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
397 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
399 hdrl_persistence_verify_inputs(1.0,
400 1.0, 1.0, CPL_FALSE, good_dates, bad2_exps, good_illums,
401 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
402 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
404 hdrl_persistence_verify_inputs(1.0,
405 1.0, 1.0, CPL_FALSE, good_dates, bad3_exps, good_illums,
406 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
407 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
409 hdrl_persistence_verify_inputs(1.0,
410 1.0, 1.0, CPL_FALSE, good_dates, good_exps, bad2_illums,
411 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
412 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
414 hdrl_persistence_verify_inputs(1.0,
415 1.0, 1.0, CPL_FALSE, good_dates, good_exps, bad3_illums,
416 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
417 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
419 hdrl_persistence_verify_inputs(1.0,
420 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
421 bad2_srcmasks, good_max, good_den, good_fullwell, good_frac);
422 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
424 hdrl_persistence_verify_inputs(1.0,
425 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
426 bad3_srcmasks, good_max, good_den, good_fullwell, good_frac);
427 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
431 hdrl_persistence_verify_inputs(1.0,
432 1.0, 1.0, CPL_FALSE, bad4_dates, good_exps, good_illums,
433 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
434 cpl_test_error(CPL_ERROR_INVALID_TYPE);
436 hdrl_persistence_verify_inputs(1.0,
437 1.0, 1.0, CPL_FALSE, good_dates, bad4_exps, good_illums,
438 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
439 cpl_test_error(CPL_ERROR_INVALID_TYPE);
441 hdrl_persistence_verify_inputs(1.0,
442 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
443 bad4_srcmasks, good_max, good_den, good_fullwell, good_frac);
444 cpl_test_error(CPL_ERROR_INVALID_TYPE);
448 hdrl_persistence_verify_inputs(1.0,
449 1.0, 1.0, CPL_FALSE, good_dates, good_exps, bad5_illums,
450 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
451 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
455 hdrl_persistence_verify_inputs(1.0,
456 1.0, 1.0, CPL_FALSE, good_dates, good_exps, good_illums,
457 good_srcmasks, good_max, good_den, good_fullwell, good_frac);
458 cpl_test_error(CPL_ERROR_NONE);
462 cpl_array_delete(good_dates);
463 cpl_array_delete(bad2_dates);
464 cpl_array_delete(bad3_dates);
465 cpl_array_delete(bad4_dates);
466 cpl_array_delete(bad2_exps);
467 cpl_array_delete(bad3_exps);
468 cpl_array_delete(bad4_exps);
469 cpl_array_delete(good_exps);
474 cpl_mask_delete(good_bpm);
475 cpl_imagelist_delete(good_srcmasks);
476 cpl_imagelist_delete(bad2_srcmasks);
477 cpl_imagelist_delete(bad3_srcmasks);
478 cpl_imagelist_delete(bad4_srcmasks);
479 cpl_image_delete(good_max);
480 cpl_image_delete(bad1_max);
481 cpl_image_delete(good_den);
482 cpl_image_delete(bad1_den);
483 cpl_image_delete(good_fullwell);
484 cpl_image_delete(bad1_fullwell);
485 cpl_table_delete(good_frac);
486 cpl_table_delete(bad1_frac);
488 cpl_test_error(CPL_ERROR_NONE);
493test_hdrl_persistence_threshhold_qi(
void)
510 const cpl_size ny = 10;
511 const cpl_size nx = 10;
514 cpl_image * tmp = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
515 cpl_image_fill_window(tmp, 1, 1, nx, ny, 90.0);
517 cpl_image_fill_window(tmp, 1, 1, nx, ny, 10.0);
521 for (
int i=0, xpos=1; xpos <= nx; xpos++) {
522 for (
int ypos=1 ; ypos <= ny; ypos++ ) {
523 hdrl_value val = { i++, 0.0 };
528 hdrl_persistence_threshhold_img(NULL, zero, upper);
529 cpl_test_error(CPL_ERROR_NULL_INPUT);
531 hdrl_persistence_threshhold_img(hi, NULL, upper);
532 cpl_test_error(CPL_ERROR_NULL_INPUT);
534 hdrl_persistence_threshhold_img(NULL, NULL, NULL);
535 cpl_test_error(CPL_ERROR_NULL_INPUT);
537 hdrl_persistence_threshhold_img(hi, zero, upper);
541 cpl_test_error(CPL_ERROR_NONE);
545 cpl_test_error(CPL_ERROR_NONE);
549 cpl_test_error(CPL_ERROR_NONE);
553 cpl_test_error(CPL_ERROR_NONE);
555 hdrl_persistence_threshhold_img(hi, lower, hi);
559 cpl_test_error(CPL_ERROR_NONE);
563 cpl_test_error(CPL_ERROR_NONE);
567 cpl_test_error(CPL_ERROR_NONE);
573 cpl_image_delete(tmp);
575 cpl_test_error(CPL_ERROR_NONE);
580test_hdrl_persistence_zero_flagged_pixels(
void)
595 const cpl_size ny = 3;
596 const cpl_size nx = 3;
597 cpl_image * tmp = cpl_image_new(ny, nx, CPL_TYPE_DOUBLE);
598 cpl_image_add_scalar(tmp, 7.0);
601 cpl_mask * srcmask = cpl_mask_new(nx, ny);
602 cpl_mask_set(srcmask, 2, 2, CPL_BINARY_1);
604 hdrl_persistence_zero_flagged_pixels(NULL, srcmask, CPL_BINARY_1);
605 cpl_test_error(CPL_ERROR_NULL_INPUT);
607 hdrl_persistence_zero_flagged_pixels(hi, NULL, CPL_BINARY_1);
608 cpl_test_error(CPL_ERROR_NULL_INPUT);
610 hdrl_persistence_zero_flagged_pixels(hi, srcmask,
's');
611 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
613 hdrl_persistence_zero_flagged_pixels(hi, srcmask, CPL_BINARY_1);
614 cpl_test_error(CPL_ERROR_NONE);
626 cpl_mask_delete(srcmask);
627 cpl_image_delete(tmp);
633test_hdrl_persistence_compute_qi(
void)
652 const float taud[] = {1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0};
655 const cpl_size ny = 20;
656 const cpl_size nx = 20;
657 hdrl_imagelist * hirhos = test_hdrl_persistence_mkhilist(n_tau, nx, ny, 0);
658 hdrl_imagelist * himaxs = test_hdrl_persistence_mkhilist(n_tau, nx, ny, 0);
659 hdrl_imagelist * Q = test_hdrl_persistence_mkhilist(n_tau, nx, ny, 1);
660 hdrl_imagelist * Qacc = test_hdrl_persistence_mkhilist(n_tau, nx, ny, 1);
664 cpl_image * peak_img = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
665 cpl_test_error(CPL_ERROR_NONE);
666 cpl_image_fill_gaussian(peak_img, 10, 10, 1000.0, 1.0, 0.5);
667 cpl_test_error(CPL_ERROR_NONE);
668 cpl_image_add_scalar(peak_img, 1.0);
669 cpl_test_error(CPL_ERROR_NONE);
672 double exptime = 300.0;
673 double diff = 58967.353850 - 58967.315219;
674 diff *= 24.0 * 3600.0;
676 hdrl_persistence_compute_qi(
677 NULL, Qacc, diff, hirhos, taud, exptime, hiillum, n_tau, himaxs);
678 cpl_test_error(CPL_ERROR_NULL_INPUT);
680 hdrl_persistence_compute_qi(
681 Q, NULL, diff, hirhos, taud, exptime, hiillum, n_tau, himaxs);
682 cpl_test_error(CPL_ERROR_NULL_INPUT);
684 hdrl_persistence_compute_qi(
685 Q, Qacc, diff, NULL, taud, exptime, hiillum, n_tau, himaxs);
686 cpl_test_error(CPL_ERROR_NULL_INPUT);
688 hdrl_persistence_compute_qi(
689 Q, Qacc, diff, hirhos, NULL, exptime, hiillum, n_tau, himaxs);
690 cpl_test_error(CPL_ERROR_NULL_INPUT);
692 hdrl_persistence_compute_qi(
693 Q, Qacc, diff, hirhos, taud, -1, hiillum, n_tau, himaxs);
694 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
696 hdrl_persistence_compute_qi(
697 Q, Qacc, diff, hirhos, taud, exptime, NULL, n_tau, himaxs);
698 cpl_test_error(CPL_ERROR_NULL_INPUT);
700 hdrl_persistence_compute_qi(
701 Q, Qacc, diff, hirhos, taud, exptime, hiillum, -1, himaxs);
702 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
704 hdrl_persistence_compute_qi(
705 Q, Qacc, diff, hirhos, taud, exptime, hiillum, n_tau, NULL);
706 cpl_test_error(CPL_ERROR_NULL_INPUT);
708 hdrl_persistence_compute_qi(
709 Q, Qacc, diff, hirhos, taud, exptime, hiillum, n_tau, himaxs);
710 cpl_test_error(CPL_ERROR_NONE);
714 typedef struct {
int x;
int y; } pixel_t;
715 pixel_t pixs[] = { {4,6}, {9,2} };
716 for (
size_t j = 0; j < ARRAY_LEN(pixs); ++j) {
717 const pixel_t p = pixs[j];
721 hdrl_data_t q[] = { 0, 0, 0, 0, 0, 0 };
722 hdrl_data_t qacc[] = { 0, 0, 0, 0, 0, 0 };
723 hdrl_data_t rhos[] = { 0, 0, 0, 0, 0, 0 };
724 hdrl_data_t maxs[] = { 0, 0, 0, 0, 0, 0 };
725 for (
size_t i = 0; i < ARRAY_LEN(rhos); ++i) {
733 for (
int i=0; i<n_tau; i++) {
735 hdrl_data_t tmp = qacc[i] * exp(-diff/taud[i]);
747 tmp = illum * rhos[i] * (1.0 - exp(-exptime/taud[i]));
748 if (tmp > maxs[i]) tmp = maxs[i];
753 cpl_test_abs(qacc[i], val, HDRL_EPS_DATA);
758 cpl_image_delete(peak_img);
764 cpl_test_error(CPL_ERROR_NONE);
769test_hdrl_persistence_calc_stats(
void)
785 cpl_test_error(CPL_ERROR_NONE);
790test_hdrl_persistence_compute(
void)
807 double det_turnover = 1.0;
808 const double mean_trim = 1.0;
809 const cpl_boolean cleanQ = CPL_FALSE;
810 const cpl_array * dates = cpl_array_new(2, CPL_TYPE_FLOAT);
811 const cpl_array * exps = cpl_array_new(1, CPL_TYPE_FLOAT);
812 hdrl_imagelist * illums = test_hdrl_persistence_mkhilist(1, 3, 3, 0);
813 const char * traps = test_hdrl_persistence_make_trapMEF(
"compute_trap.fits",
814 3, 3, CPL_TYPE_DOUBLE, 3, 3, CPL_TYPE_DOUBLE, 3, 3, CPL_TYPE_DOUBLE, 6,
815 "TAU", CPL_TYPE_FLOAT,
"NU", CPL_TYPE_FLOAT);
816 const cpl_mask * bpm = cpl_mask_new(3, 3);
817 cpl_imagelist * srcmasks = cpl_imagelist_new();
818 cpl_imagelist_set(srcmasks, cpl_image_new(3, 3, CPL_TYPE_INT), 0);
824 det_turnover = -45727230.0;
827 cpl_table * frac = NULL;
828 cpl_image * maximum = NULL, * density = NULL, * fullwell = NULL;
830 test_hdrl_persistence_read_info(traps, &maximum, &density, &fullwell, &frac);
832 hdrl_image * persistence = NULL;
833 cpl_propertylist * persistence_qc = NULL;
836 mean_trim, cleanQ, dates,
837 exps, illums, srcmasks, maximum, density, fullwell, frac, &persistence, &persistence_qc);
839 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
842 cpl_propertylist_delete(persistence_qc);
843 cpl_image_delete(maximum);
844 cpl_image_delete(density);
845 cpl_image_delete(fullwell);
846 cpl_table_delete(frac);
848 cpl_imagelist_delete(srcmasks);
849 cpl_mask_delete((cpl_mask *)bpm);
851 cpl_array_delete((cpl_array *)exps);
852 cpl_array_delete((cpl_array *)dates);
854 cpl_test_error(CPL_ERROR_NONE);
865 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
868 test_hdrl_persistence_verify_inputs();
870 test_hdrl_persistence_threshhold_qi();
871 test_hdrl_persistence_zero_flagged_pixels();
872 test_hdrl_persistence_compute_qi();
873 test_hdrl_persistence_calc_stats();
876 test_hdrl_persistence_compute();
879 return cpl_test_end(0);
hdrl_value hdrl_image_get_pixel(const hdrl_image *self, cpl_size xpos, cpl_size ypos, int *pis_rejected)
get pixel values of hdrl_image
cpl_error_code hdrl_image_set_pixel(hdrl_image *self, cpl_size xpos, cpl_size ypos, hdrl_value value)
set pixel values of hdrl_image
hdrl_image * hdrl_image_create(const cpl_image *image, const cpl_image *error)
create a new hdrl_image from to existing images by copying them
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
hdrl_image * hdrl_image_new(cpl_size nx, cpl_size ny)
create new zero filled hdrl image
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
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.
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.
cpl_error_code hdrl_persistence_compute(const double gain, const double turnover, const double mean_trim, const cpl_boolean cleanQ, const cpl_array *dateobs, const cpl_array *exptimes, hdrl_imagelist *ilist_persistence, const cpl_imagelist *ilist_obj, const cpl_image *maximum, const cpl_image *density, const cpl_image *fullwell, const cpl_table *frac, hdrl_image **persistence, cpl_propertylist **persistence_qc)
generate the persistence map