00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023
00024
00025
00026
00027
00028 #include <irplib_detmon.h>
00029 #include <irplib_detmon_lg.h>
00030 #include <irplib_detmon_lg_impl.h>
00031
00032
00033 #include <math.h>
00034
00035
00036
00037
00038
00039
00040 #define PI 3.141592653
00041
00042
00043
00044
00045 #ifndef IMAGESIZE
00046 #define IMAGESIZE 64
00047 #endif
00048
00049 #define IMAGELISTSIZE 10
00050
00051 #define NBADPIXS 10
00052
00053 #define ON_LEVEL 300.0
00054 #define OFF_LEVEL 100.0
00055
00056 #define NOISE_MIN 10.0
00057 #define NOISE_MAX 40.0
00058
00059 #define ON TRUE
00060 #define OFF FALSE
00061
00062
00063
00064
00065
00066
00067 static void irplib_detmon_lg_tests(void);
00068 static void irplib_detmon_check_order_test(void);
00069 cpl_frameset * irplib_detmon_tests_fill_frameset(const char * tag_on,
00070 const char * tag_off,
00071 int non,
00072 cpl_boolean opt_nir,
00073 cpl_boolean with_exts,
00074 int nexts,
00075 int nsettings);
00076
00077 cpl_frameset * irplib_detmon_tests_fill_frameset_oct(const char * tag_on,
00078 const char * tag_off,
00079 int non,
00080 cpl_boolean opt_nir,
00081 cpl_boolean with_exts,
00082 int nexts);
00083
00084 int compare_settings(const cpl_frame * frame1, const cpl_frame * frame2);
00085
00086 cpl_imagelist * irplib_detmon_tests_imlist(int ndits, cpl_boolean onoff);
00087
00088
00089
00090
00091
00092
00093
00094 int main(void)
00095 {
00096
00097 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00098
00099 irplib_detmon_lg_tests();
00100 irplib_detmon_check_order_test();
00101 return cpl_test_end(0);
00102 }
00103
00104 static void irplib_detmon_lg_tests(void)
00105 {
00106
00107
00108 int px, py;
00109 cpl_image * image1;
00110 #ifdef HAVE_SFFTW_NOT_USED
00111 cpl_image * image2;
00112 #endif
00113 cpl_image * result;
00114
00115 cpl_parameterlist * parlist;
00116 cpl_frameset * frameset;
00117 cpl_frameset * set;
00118 cpl_propertylist * prolist;
00119
00120
00121 const char * tag_on;
00122 const char * tag_off;
00123
00124
00125 #ifdef HAVE_SFFTW_NOT_USED
00126
00127
00128
00129 result = irplib_detmon_image_correlate(NULL, NULL, 0, 0);
00130 cpl_test_error(CPL_ERROR_NULL_INPUT);
00131 cpl_error_reset();
00132 cpl_test_null(result);
00133 cpl_image_delete(result);
00134
00135
00136 image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00137 cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00138
00139 image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00140 cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00141
00142 px = -1;
00143 py = -1;
00144
00145 result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00146
00147 cpl_image_get_maxpos(result, &px, &py);
00148 cpl_test(px == 13+1 && py == 13+1);
00149
00150 cpl_image_delete(image1);
00151 cpl_image_delete(image2);
00152 cpl_image_delete(result);
00153
00154
00155 image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00156 cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00157
00158 image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00159 cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00160
00161 px = -1;
00162 py = -1;
00163
00164 result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00165
00166 cpl_image_get_maxpos(result, &px, &py);
00167 cpl_test(px == 13+1 && py == 13+1);
00168
00169 cpl_image_delete(image1);
00170 cpl_image_delete(image2);
00171 cpl_image_delete(result);
00172
00173
00174 image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00175 cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00176
00177 image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00178 cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2+40, (IMAGESIZE + 1)/2+40, 25, 40, 40);
00179
00180 px = -1;
00181 py = -1;
00182
00183 result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00184
00185 cpl_image_get_maxpos(result, &px, &py);
00186
00187
00188
00189
00190
00191 cpl_image_delete(image1);
00192 cpl_image_delete(image2);
00193 cpl_image_delete(result);
00194 #else
00195
00196
00197
00198 result = irplib_detmon_autocorrelate(NULL, 0, 0);
00199 cpl_test_error(CPL_ERROR_NULL_INPUT);
00200 cpl_error_reset();
00201 cpl_test_null(result);
00202 cpl_image_delete(result);
00203
00204
00205 image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00206 cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00207
00208 px = -1;
00209 py = -1;
00210
00211 result = irplib_detmon_autocorrelate(image1, 13, 13);
00212
00213 cpl_image_get_maxpos(result, &px, &py);
00214 cpl_test(px == 13+1 && py == 13+1);
00215
00216 cpl_image_delete(image1);
00217 cpl_image_delete(result);
00218
00219 #endif
00220
00221
00222
00223 tag_on = "FRAME_ON";
00224 tag_off = "FRAME_OFF";
00225
00226 set = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00227 20, TRUE, FALSE, 0, 1);
00228
00229 prolist = irplib_detmon_fill_prolist("PROCATG", "TYPE", "TECH", CPL_TRUE);
00230
00231
00232 irplib_detmon_lg(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
00233 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
00234 cpl_test_error(CPL_ERROR_NULL_INPUT);
00235 cpl_error_reset();
00236
00237
00238
00239 parlist = cpl_parameterlist_new();
00240 irplib_detmon_lg_fill_parlist_nir_default(parlist,
00241 "detmon_ir_lg", "detmon");
00242
00243 frameset = cpl_frameset_duplicate(set);
00244
00245 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00246 "detmon", REGEXP, prolist, prolist, prolist,
00247 prolist, prolist, prolist, "DETMON / 1.0",
00248 NULL, NULL, TRUE);
00249 cpl_test_error(CPL_ERROR_NONE);
00250 cpl_error_reset();
00251
00252 cpl_frameset_delete(frameset);
00253 cpl_parameterlist_delete(parlist);
00254
00255
00256
00257 parlist = cpl_parameterlist_new();
00258 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00259 "PTC",
00260 3,
00261 3,
00262 25,
00263 8,
00264 8,
00265 56,
00266 56,
00267 10000,
00268 "CPL_FALSE",
00269 "CPL_FALSE",
00270 "CPL_FALSE",
00271 "CPL_TRUE",
00272 "CPL_TRUE",
00273 "CPL_FALSE",
00274 -1,
00275 26,
00276 26,
00277 1e-3,
00278 "CPL_TRUE",
00279 "detmon_ir_lg",
00280 -1,
00281 -1,
00282 -1,
00283 -1,
00284 -1,
00285 -1,
00286 -1,
00287 -1,
00288 -1,
00289 -1,
00290 -1,
00291 -1,
00292 -1,
00293 -1,
00294 -1,
00295 -1,
00296 -1,
00297 -1,
00298 -1,
00299 -1,
00300 0,
00301 NIR);
00302
00303 frameset = cpl_frameset_duplicate(set);
00304
00305 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00306 "detmon", REGEXP, prolist, prolist, prolist,
00307 prolist, prolist, prolist, "DETMON / 1.0",
00308 NULL, NULL, TRUE);
00309 cpl_test_error(CPL_ERROR_NONE);
00310 cpl_error_reset();
00311
00312 cpl_frameset_delete(frameset);
00313 cpl_parameterlist_delete(parlist);
00314
00315
00316 parlist = cpl_parameterlist_new();
00317 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00318 "MED",
00319 3,
00320 3,
00321 25,
00322 -1,
00323 -1,
00324 -1,
00325 -1,
00326 10000,
00327 "CPL_FALSE",
00328 "CPL_FALSE",
00329 "CPL_FALSE",
00330 "CPL_TRUE",
00331 "CPL_TRUE",
00332 "CPL_FALSE",
00333 -1,
00334 26,
00335 26,
00336 1e-3,
00337 "CPL_TRUE",
00338 "detmon_ir_lg",
00339 -1,
00340 -1,
00341 -1,
00342 -1,
00343 -1,
00344 -1,
00345 -1,
00346 -1,
00347 -1,
00348 -1,
00349 -1,
00350 -1,
00351 -1,
00352 -1,
00353 -1,
00354 -1,
00355 -1,
00356 -1,
00357 -1,
00358 -1,
00359 0,
00360 NIR);
00361
00362 frameset = cpl_frameset_duplicate(set);
00363
00364 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00365 "detmon", REGEXP, prolist, prolist, prolist,
00366 prolist, prolist, prolist, "DETMON / 1.0",
00367 NULL, NULL, TRUE);
00368 cpl_test_error(CPL_ERROR_NONE);
00369 cpl_error_reset();
00370
00371 cpl_frameset_delete(frameset);
00372 cpl_parameterlist_delete(parlist);
00373
00374
00375
00376
00377
00378 parlist = cpl_parameterlist_new();
00379 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00380 "PTC",
00381 3,
00382 3,
00383 25,
00384 -1,
00385 -1,
00386 -1,
00387 -1,
00388 10000,
00389 "CPL_TRUE",
00390 "CPL_FALSE",
00391 "CPL_FALSE",
00392 "CPL_TRUE",
00393 "CPL_TRUE",
00394 "CPL_FALSE",
00395 -1,
00396 26,
00397 26,
00398 1e-3,
00399 "CPL_TRUE",
00400 "detmon_ir_lg",
00401 -1,
00402 -1,
00403 -1,
00404 -1,
00405 -1,
00406 -1,
00407 -1,
00408 -1,
00409 -1,
00410 -1,
00411 -1,
00412 -1,
00413 -1,
00414 -1,
00415 -1,
00416 -1,
00417 -1,
00418 -1,
00419 -1,
00420 -1,
00421 0,
00422 NIR);
00423
00424 frameset = cpl_frameset_duplicate(set);
00425
00426 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00427 "detmon", REGEXP, prolist, prolist, prolist,
00428 prolist, prolist, prolist, "DETMON / 1.0",
00429 NULL, NULL, TRUE);
00430 cpl_test_error(CPL_ERROR_NONE);
00431 cpl_error_reset();
00432
00433 cpl_frameset_delete(frameset);
00434 cpl_parameterlist_delete(parlist);
00435
00436
00437
00438
00439 parlist = cpl_parameterlist_new();
00440 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00441 "PTC",
00442 3,
00443 3,
00444 25,
00445 -1,
00446 -1,
00447 -1,
00448 -1,
00449 10000,
00450 "CPL_FALSE",
00451 "CPL_FALSE",
00452 "CPL_FALSE",
00453 "CPL_FALSE",
00454 "CPL_TRUE",
00455 "CPL_FALSE",
00456 -1,
00457 26,
00458 26,
00459 1e-3,
00460 "CPL_TRUE",
00461 "detmon_ir_lg",
00462 -1,
00463 -1,
00464 -1,
00465 -1,
00466 -1,
00467 -1,
00468 -1,
00469 -1,
00470 -1,
00471 -1,
00472 -1,
00473 -1,
00474 -1,
00475 -1,
00476 -1,
00477 -1,
00478 -1,
00479 -1,
00480 -1,
00481 -1,
00482 0,
00483 NIR);
00484
00485 frameset = cpl_frameset_duplicate(set);
00486
00487 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00488 "detmon", REGEXP, prolist, prolist, prolist,
00489 prolist, prolist, prolist, "DETMON / 1.0",
00490 NULL, NULL, TRUE);
00491 cpl_test_error(CPL_ERROR_NONE);
00492 cpl_error_reset();
00493
00494 cpl_frameset_delete(frameset);
00495 cpl_parameterlist_delete(parlist);
00496
00497
00498 parlist = cpl_parameterlist_new();
00499 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00500 "PTC",
00501 3,
00502 3,
00503 25,
00504 -1,
00505 -1,
00506 -1,
00507 -1,
00508 10000,
00509 "CPL_FALSE",
00510 "CPL_FALSE",
00511 "CPL_FALSE",
00512 "CPL_TRUE",
00513 "CPL_TRUE",
00514 "CPL_TRUE",
00515 -1,
00516 26,
00517 26,
00518 1e-3,
00519 "CPL_TRUE",
00520 "detmon_ir_lg",
00521 -1,
00522 -1,
00523 -1,
00524 -1,
00525 -1,
00526 -1,
00527 -1,
00528 -1,
00529 -1,
00530 -1,
00531 -1,
00532 -1,
00533 -1,
00534 -1,
00535 -1,
00536 -1,
00537 -1,
00538 -1,
00539 -1,
00540 -1,
00541 0,
00542 NIR);
00543
00544 frameset = cpl_frameset_duplicate(set);
00545
00546 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00547 "detmon", REGEXP, prolist, prolist, prolist,
00548 prolist, prolist, prolist, "DETMON / 1.0",
00549 NULL, NULL, TRUE);
00550 cpl_test_error(CPL_ERROR_NONE);
00551 cpl_error_reset();
00552
00553 {
00554
00555 cpl_image * bpm = cpl_image_load("detmon_ir_lg_bpm.fits",
00556 CPL_TYPE_INT, 0, 0);
00557
00558 cpl_mask * mask = cpl_mask_threshold_image_create(bpm, 0.5, 1.5);
00559
00560 int nbpixs = cpl_mask_count(mask);
00561
00562 int flux = (int)cpl_image_get_flux(bpm);
00563
00564 cpl_test_eq(flux, nbpixs);
00565
00566 cpl_image_delete(bpm);
00567 cpl_mask_delete(mask);
00568 }
00569
00570 cpl_frameset_delete(frameset);
00571 cpl_parameterlist_delete(parlist);
00572
00573
00574
00575
00576
00577
00578 parlist = cpl_parameterlist_new();
00579 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00580 "PTC",
00581 3,
00582 3,
00583 25,
00584 -1,
00585 -1,
00586 -1,
00587 -1,
00588 10000,
00589 "CPL_FALSE",
00590 "CPL_FALSE",
00591 "CPL_FALSE",
00592 "CPL_TRUE",
00593 "CPL_FALSE",
00594 "CPL_FALSE",
00595 -1,
00596 26,
00597 26,
00598 1e-3,
00599 "CPL_TRUE",
00600 "detmon_ir_lg",
00601 -1,
00602 -1,
00603 -1,
00604 -1,
00605 -1,
00606 -1,
00607 -1,
00608 -1,
00609 -1,
00610 -1,
00611 -1,
00612 -1,
00613 -1,
00614 -1,
00615 -1,
00616 -1,
00617 -1,
00618 -1,
00619 -1,
00620 -1,
00621 0,
00622 NIR);
00623
00624 frameset = cpl_frameset_duplicate(set);
00625
00626
00627
00628
00629
00630
00631
00632
00633 cpl_frameset_delete(frameset);
00634 cpl_parameterlist_delete(parlist);
00635
00636
00637
00638
00639 parlist = cpl_parameterlist_new();
00640 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00641 "PTC",
00642 3,
00643 3,
00644 25,
00645 -1,
00646 -1,
00647 -1,
00648 -1,
00649 10000,
00650 "CPL_FALSE",
00651 "CPL_FALSE",
00652 "CPL_FALSE",
00653 "CPL_TRUE",
00654 "CPL_TRUE",
00655 "CPL_FALSE",
00656 4000,
00657 26,
00658 26,
00659 1e-3,
00660 "CPL_TRUE",
00661 "detmon_ir_lg",
00662 -1,
00663 -1,
00664 -1,
00665 -1,
00666 -1,
00667 -1,
00668 -1,
00669 -1,
00670 -1,
00671 -1,
00672 -1,
00673 -1,
00674 -1,
00675 -1,
00676 -1,
00677 -1,
00678 -1,
00679 -1,
00680 -1,
00681 -1,
00682 0,
00683 NIR);
00684
00685 frameset = cpl_frameset_duplicate(set);
00686
00687 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00688 "detmon", REGEXP, prolist, prolist, prolist,
00689 prolist, prolist, prolist, "DETMON / 1.0",
00690 NULL, NULL, TRUE);
00691 cpl_test_error(CPL_ERROR_NONE);
00692 cpl_error_reset();
00693
00694 cpl_frameset_delete(frameset);
00695 cpl_parameterlist_delete(parlist);
00696
00697
00698
00699 cpl_frameset_delete(set);
00700
00701
00702
00703
00704
00705
00706
00707 parlist = cpl_parameterlist_new();
00708 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00709 "PTC",
00710 3,
00711 3,
00712 25,
00713 -1,
00714 -1,
00715 -1,
00716 -1,
00717 10000,
00718 "CPL_FALSE",
00719 "CPL_FALSE",
00720 "CPL_FALSE",
00721 "CPL_TRUE",
00722 "CPL_TRUE",
00723 "CPL_FALSE",
00724 -1,
00725 26,
00726 26,
00727 1e-3,
00728 "CPL_TRUE",
00729 "detmon_ir_lg",
00730 -1,
00731 -1,
00732 -1,
00733 -1,
00734 -1,
00735 -1,
00736 -1,
00737 -1,
00738 -1,
00739 -1,
00740 -1,
00741 -1,
00742 -1,
00743 -1,
00744 -1,
00745 -1,
00746 -1,
00747 -1,
00748 -1,
00749 -1,
00750 0,
00751 NIR);
00752
00753 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00754 6, TRUE, FALSE, 0, 1);
00755
00756
00757
00758
00759
00760
00761
00762
00763 cpl_frameset_delete(frameset);
00764 cpl_parameterlist_delete(parlist);
00765
00766
00767
00768 parlist = cpl_parameterlist_new();
00769 irplib_detmon_lg_fill_parlist_opt_default(parlist,
00770 "detmon_opt_lg", "detmon");
00771
00772 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00773 20, FALSE, FALSE, 0, 1);
00774
00775
00776
00777
00778
00779
00780
00781
00782 cpl_frameset_delete(frameset);
00783 cpl_parameterlist_delete(parlist);
00784
00785 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 1, 0)
00786
00787 parlist = cpl_parameterlist_new();
00788 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00789 "PTC",
00790 3,
00791 3,
00792 25,
00793 -1,
00794 -1,
00795 -1,
00796 -1,
00797 10000,
00798 "CPL_FALSE",
00799 "CPL_FALSE",
00800 "CPL_FALSE",
00801 "CPL_TRUE",
00802 "CPL_TRUE",
00803 "CPL_FALSE",
00804 -1,
00805 26,
00806 26,
00807 1e-3,
00808 "CPL_TRUE",
00809 "detmon_ir_lg",
00810 -1,
00811 -1,
00812 -1,
00813 -1,
00814 -1,
00815 -1,
00816 -1,
00817 -1,
00818 -1,
00819 -1,
00820 -1,
00821 -1,
00822 -1,
00823 -1,
00824 -1,
00825 -1,
00826 -1,
00827 -1,
00828 -1,
00829 -1,
00830 -1,
00831 NIR);
00832
00833
00834
00835
00836
00837
00838
00839
00840 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00841 20, TRUE, TRUE, 8, 1);
00842
00843 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00844 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", NULL, NULL, TRUE);
00845 cpl_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00846 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00847 cpl_error_reset();
00848
00849 cpl_parameterlist_delete(parlist);
00850 cpl_frameset_delete(frameset);
00851 #endif
00852
00853
00854
00855 parlist = cpl_parameterlist_new();
00856 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00857 "PTC",
00858 3,
00859 3,
00860 25,
00861 -1,
00862 -1,
00863 -1,
00864 -1,
00865 10000,
00866 "CPL_FALSE",
00867 "CPL_FALSE",
00868 "CPL_FALSE",
00869 "CPL_TRUE",
00870 "CPL_TRUE",
00871 "CPL_FALSE",
00872 -1,
00873 26,
00874 26,
00875 1e-3,
00876 "CPL_TRUE",
00877 "detmon_ir_lg",
00878 -1,
00879 -1,
00880 -1,
00881 -1,
00882 -1,
00883 -1,
00884 -1,
00885 -1,
00886 -1,
00887 -1,
00888 -1,
00889 -1,
00890 -1,
00891 -1,
00892 -1,
00893 -1,
00894 -1,
00895 -1,
00896 -1,
00897 -1,
00898 2,
00899 NIR);
00900
00901
00902
00903
00904
00905
00906
00907
00908 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00909 20, TRUE, TRUE, 8, 1);
00910
00911 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00912 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", NULL, NULL, TRUE);
00913 cpl_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00914 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00915 cpl_error_reset();
00916
00917 cpl_parameterlist_delete(parlist);
00918 cpl_frameset_delete(frameset);
00919
00920
00921
00922 parlist = cpl_parameterlist_new();
00923 irplib_detmon_lg_fill_parlist_nir_default(parlist, "detmon_ir_lg", "detmon");
00924
00925 frameset = irplib_detmon_tests_fill_frameset_oct(tag_on, tag_off, 20, TRUE, FALSE, 0);
00926
00927
00928
00929
00930
00931
00932
00933 cpl_parameterlist_delete(parlist);
00934 cpl_frameset_delete(frameset);
00935
00936
00937 parlist = cpl_parameterlist_new();
00938 irplib_detmon_lg_fill_parlist_nir_default(parlist, "detmon_ir_lg", "detmon");
00939
00940 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00941 20, TRUE, FALSE, 0, 3);
00942
00943 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00944 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", compare_settings, NULL, TRUE);
00945
00946 cpl_test_error(CPL_ERROR_NONE);
00947
00948 cpl_parameterlist_delete(parlist);
00949 cpl_frameset_delete(frameset);
00950
00951 cpl_propertylist_delete(prolist);
00952
00953 cpl_test_zero(system("rm *.paf *.fits"));
00954
00955
00956 {
00957
00958 cpl_table * gain_table;
00959 cpl_imagelist * imlist_on;
00960 cpl_imagelist * imlist_off;
00961 cpl_imagelist * diff;
00962 cpl_imagelist * corr;
00963 cpl_vector * exptimes;
00964 cpl_vector * ndits;
00965 cpl_propertylist * qclist;
00966 int i;
00967 double gain;
00968
00969
00970 gain_table = irplib_detmon_gain(NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0.0,
00971 0, 0, 0, NULL, 0, NULL, NULL);
00972 cpl_test_null(gain_table);
00973 cpl_test_error(CPL_ERROR_NULL_INPUT);
00974
00975 imlist_on = irplib_detmon_tests_imlist(8, ON);
00976 imlist_off = irplib_detmon_tests_imlist(8, OFF);
00977
00978 exptimes = cpl_vector_new(16);
00979 ndits = cpl_vector_new(16);
00980
00981 for(i = 0; i < 16; i++) {
00982 cpl_vector_set(exptimes, i, (double)(i/2 + 1));
00983 cpl_vector_set(ndits, i, 1.);
00984 }
00985
00986 qclist = cpl_propertylist_new();
00987
00988 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
00989 0.0,
00990 1, 1,
00991 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
00992 qclist, IRPLIB_GAIN_NO_COLLAPSE |
00993 IRPLIB_GAIN_NIR,
00994 NULL, NULL);
00995
00996
00997 cpl_test_nonnull(gain_table);
00998 cpl_test_error(CPL_ERROR_NONE);
00999
01000
01001 gain = cpl_propertylist_get_double(qclist, DETMON_QC_GAIN);
01002 cpl_test(gain > 220.0 && gain < 240.0);
01003
01004 cpl_table_delete(gain_table);
01005 cpl_propertylist_delete(qclist);
01006
01007
01008 qclist = cpl_propertylist_new();
01009
01010 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01011 0.0,
01012 1, 1,
01013 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01014 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01015 IRPLIB_GAIN_NIR |
01016 IRPLIB_GAIN_PTC,
01017 NULL, NULL);
01018 cpl_test_nonnull(gain_table);
01019 cpl_test_error(CPL_ERROR_NONE);
01020
01021
01022 gain = cpl_propertylist_get_double(qclist, DETMON_QC_GAIN);
01023 cpl_test(gain > 160.0 && gain < 180.0);
01024
01025 cpl_table_delete(gain_table);
01026 cpl_propertylist_delete(qclist);
01027
01028 qclist = cpl_propertylist_new();
01029
01030 diff = NULL;
01031 corr = NULL;
01032
01033 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01034 0.0,
01035 1, 1,
01036 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01037 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01038 IRPLIB_GAIN_NIR |
01039 IRPLIB_GAIN_WITH_AUTOCORR, &diff, &corr);
01040 cpl_test_nonnull(gain_table);
01041 cpl_test_nonnull(diff);
01042 cpl_test_nonnull(corr);
01043 cpl_test_error(CPL_ERROR_NONE);
01044
01045 cpl_imagelist_delete(diff);
01046 cpl_imagelist_delete(corr);
01047 cpl_table_delete(gain_table);
01048 cpl_propertylist_delete(qclist);
01049
01050 qclist = cpl_propertylist_new();
01051
01052 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01053 0.0,
01054 1, 1,
01055 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01056 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01057 IRPLIB_GAIN_NIR |
01058 IRPLIB_GAIN_WITH_AUTOCORR, NULL, NULL);
01059 cpl_test_nonnull(gain_table);
01060 cpl_test_error(CPL_ERROR_NONE);
01061
01062 cpl_imagelist_delete(imlist_on);
01063 cpl_imagelist_delete(imlist_off);
01064 cpl_propertylist_delete(qclist);
01065 cpl_vector_delete(exptimes);
01066 cpl_vector_delete(ndits);
01067 cpl_table_delete(gain_table);
01068 }
01069
01070
01071 {
01072 cpl_table * lin_table;
01073 cpl_imagelist * imlist_on;
01074 cpl_imagelist * imlist_off;
01075 cpl_vector * exptimes;
01076 cpl_propertylist * qclist;
01077 cpl_imagelist * coeffs_cube =NULL;
01078 cpl_image * bpm =NULL;
01079 double lincoeff1, lincoeff2, lincoeff3;
01080 int i;
01081
01082
01083 lin_table = irplib_detmon_lin(NULL, NULL, NULL, 0.0, 0, 0, 0, 0,
01084 0, 10000, 3, FALSE, NULL, 0, NULL, NULL);
01085
01086 cpl_test_null(lin_table);
01087 cpl_test_error(CPL_ERROR_NULL_INPUT);
01088
01089
01090 imlist_on = irplib_detmon_tests_imlist(8, ON);
01091 imlist_off = irplib_detmon_tests_imlist(8, OFF);
01092
01093 exptimes = cpl_vector_new(16);
01094
01095 for(i = 0; i < 16; i++) {
01096 cpl_vector_set(exptimes, i, (double)(i/2 + 1));
01097 }
01098
01099 qclist = cpl_propertylist_new();
01100
01101 lin_table = irplib_detmon_lin(imlist_on, imlist_off, exptimes, 0.0,
01102 1, 1, IMAGESIZE, IMAGESIZE,
01103 3, 10000, 3, FALSE, qclist,
01104 IRPLIB_LIN_NO_COLLAPSE |
01105 IRPLIB_LIN_NIR,
01106 NULL, NULL);
01107
01108 cpl_test_nonnull(lin_table);
01109 cpl_test_error(CPL_ERROR_NONE);
01110
01111
01112 lincoeff1 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF1");
01113 lincoeff2 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF2");
01114 lincoeff3 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF3");
01115
01116 cpl_test(lincoeff1 > 195.0 && lincoeff1 < 205.0);
01117 cpl_test(abs(lincoeff2) < 1);
01118 cpl_test(abs(lincoeff3) < 1);
01119
01120 cpl_table_delete(lin_table);
01121
01122 lin_table = irplib_detmon_lin(imlist_on, imlist_off, exptimes, 0.0,
01123 1, 1, IMAGESIZE, IMAGESIZE,
01124 3, 10000, 3, FALSE, qclist,
01125 IRPLIB_LIN_NO_COLLAPSE |
01126 IRPLIB_LIN_NIR | IRPLIB_LIN_PIX2PIX,
01127 &coeffs_cube, &bpm);
01128
01129 cpl_test_nonnull(lin_table);
01130 cpl_test_nonnull(coeffs_cube);
01131 cpl_test_nonnull(bpm);
01132 cpl_test_error(CPL_ERROR_NONE);
01133
01134 cpl_table_delete(lin_table);
01135 cpl_imagelist_delete(coeffs_cube);
01136 cpl_image_delete(bpm);
01137
01138 cpl_imagelist_delete(imlist_on);
01139 cpl_imagelist_delete(imlist_off);
01140 cpl_vector_delete(exptimes);
01141 cpl_propertylist_delete(qclist);
01142 }
01143 }
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156 cpl_frameset * irplib_detmon_tests_fill_frameset(const char * tag_on,
01157 const char * tag_off,
01158 int non,
01159 cpl_boolean opt_nir,
01160 cpl_boolean with_exts,
01161 int nexts,
01162 int nsettings)
01163 {
01164 cpl_frameset * frameset;
01165 cpl_frame * frame;
01166 int i, h;
01167 char frame_name[20];
01168 cpl_propertylist * plist;
01169 cpl_image * image;
01170 frameset = cpl_frameset_new();
01171
01172 for (h = 0; h < nsettings; h++) {
01173 for (i=0; i<non; i++) {
01174 frame = cpl_frame_new();
01175 sprintf(frame_name, "dummyon%d%d.fits",i,h);
01176 cpl_frame_set_filename(frame, frame_name);
01177 cpl_frame_set_tag(frame, tag_on);
01178 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01179 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01180
01181 cpl_frameset_insert(frameset, frame);
01182
01183 plist = cpl_propertylist_new();
01184 if(opt_nir == TRUE) {
01185 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01186 cpl_propertylist_append_int(plist, "ESO DET NDIT", 1);
01187 } else {
01188 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01189 }
01190
01191 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2 + 1) );
01192 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01193
01194 cpl_propertylist_append_double(plist, "SETTING", h+1);
01195 if(with_exts == TRUE) {
01196 int j;
01197 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01198 for(j = 0; j < nexts; j++) {
01199 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01200 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01201 cpl_image_add_scalar(image,300* i);
01202 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01203
01204 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01205 cpl_image_delete(image);
01206 }
01207 } else {
01208 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01209 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01210 cpl_image_add_scalar(image,300* i);
01211 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01212
01213 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01214
01215
01216 cpl_image_delete(image);
01217 }
01218 cpl_propertylist_delete(plist);
01219 }
01220 for (i=0; i<non; i++) {
01221
01222
01223 frame = cpl_frame_new();
01224 sprintf(frame_name, "dummyoff%d%d.fits",i,h);
01225 cpl_frame_set_filename(frame, frame_name);
01226 cpl_frame_set_tag(frame, tag_off);
01227 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01228 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01229
01230 cpl_frameset_insert(frameset, frame);
01231
01232 plist = cpl_propertylist_new();
01233 if(opt_nir == TRUE) {
01234 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01235 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01236 } else {
01237 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01238 }
01239 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01240 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2 + 1));
01241 cpl_propertylist_append_double(plist, "SETTING", h+1);
01242
01243 if(with_exts == TRUE) {
01244 int j;
01245 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01246 for(j = 0; j < nexts; j++) {
01247 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01248 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01249 cpl_image_add_scalar(image, i);
01250 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01251
01252 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01253 cpl_image_delete(image);
01254 }
01255 } else {
01256 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01257 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01258 cpl_image_add_scalar(image, i);
01259 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01260
01261 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01262
01263
01264 cpl_image_delete(image);
01265 }
01266 cpl_propertylist_delete(plist);
01267 }
01268 }
01269
01270 return frameset;
01271 }
01272
01273
01274 cpl_frameset * irplib_detmon_tests_fill_frameset_oct(const char * tag_on,
01275 const char * tag_off,
01276 int non,
01277 cpl_boolean opt_nir,
01278 cpl_boolean with_exts,
01279 int nexts)
01280 {
01281 cpl_frameset * frameset;
01282 cpl_frame * frame;
01283 int i;
01284 char frame_name[20];
01285 cpl_propertylist * plist;
01286 cpl_image * image;
01287 frameset = cpl_frameset_new();
01288
01289 for (i=0; i<non; i++) {
01290 frame = cpl_frame_new();
01291 sprintf(frame_name, "dummyon%d.fits",i);
01292 cpl_frame_set_filename(frame, frame_name);
01293 cpl_frame_set_tag(frame, tag_on);
01294 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01295 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01296
01297 cpl_frameset_insert(frameset, frame);
01298
01299 plist = cpl_propertylist_new();
01300 if(opt_nir == TRUE) {
01301 if( i == 2 || i == 3) {
01302 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
01303 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01304 cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
01305 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01306 } else {
01307 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01308 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01309 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
01310 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01311 }
01312 } else {
01313 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01314 cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
01315 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01316 }
01317
01318 if(with_exts == TRUE) {
01319 int j;
01320 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01321 for(j = 0; j < nexts; j++) {
01322 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01323 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01324 if(i == 0 || i == 1 || i== 2 || i == 3) {
01325 cpl_image_add_scalar(image,300);
01326 } else
01327 cpl_image_add_scalar(image,300* i);
01328 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01329
01330 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01331 cpl_image_delete(image);
01332 }
01333 } else {
01334 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01335 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01336 if(i == 0 || i == 1 || i== 2 || i == 3) {
01337 cpl_image_add_scalar(image,300);
01338 } else
01339 cpl_image_add_scalar(image,300* i);
01340
01341 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01342
01343 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01344
01345
01346 cpl_image_delete(image);
01347 }
01348 cpl_propertylist_delete(plist);
01349 }
01350
01351 for (i=0; i<non; i++) {
01352
01353
01354 frame = cpl_frame_new();
01355 sprintf(frame_name, "dummyoff%d.fits",i);
01356 cpl_frame_set_filename(frame, frame_name);
01357 cpl_frame_set_tag(frame, tag_off);
01358 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01359 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01360
01361 cpl_frameset_insert(frameset, frame);
01362
01363 plist = cpl_propertylist_new();
01364 if(opt_nir == TRUE) {
01365 if( i == 2 || i == 3) {
01366 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
01367 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01368 cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
01369 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01370 } else {
01371 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01372 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01373 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
01374 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01375 }
01376 } else {
01377 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01378 cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
01379 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01380 }
01381
01382 if(with_exts == TRUE) {
01383 int j;
01384 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01385 for(j = 0; j < nexts; j++) {
01386 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01387 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01388 if(i == 0 || i == 1 || i== 2 || i == 3) {
01389 cpl_image_add_scalar(image,300);
01390 } else
01391 cpl_image_add_scalar(image,300* i);
01392
01393 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01394
01395 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01396 cpl_image_delete(image);
01397 }
01398 } else {
01399 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01400 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01401 if(i == 0 || i == 1 || i== 2 || i == 3) {
01402 cpl_image_add_scalar(image,300);
01403 } else
01404 cpl_image_add_scalar(image,300* i);
01405
01406 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01407
01408 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01409
01410
01411 cpl_image_delete(image);
01412 }
01413 cpl_propertylist_delete(plist);
01414 }
01415
01416 return frameset;
01417 }
01418
01419
01420 int compare_settings(const cpl_frame * frame1, const cpl_frame * frame2)
01421 {
01422 int comparison;
01423 cpl_propertylist *plist1;
01424 cpl_propertylist *plist2;
01425 double dval1, dval2;
01426
01427
01428 if(frame1 == NULL || frame2 == NULL)
01429 return -1;
01430
01431
01432 if((plist1 = cpl_propertylist_load(cpl_frame_get_filename(frame1),
01433 0)) == NULL) {
01434 cpl_msg_error(cpl_func, "getting header from reference frame");
01435 return -1;
01436 }
01437 if((plist2 = cpl_propertylist_load(cpl_frame_get_filename(frame2),
01438 0)) == NULL) {
01439 cpl_msg_error(cpl_func, "getting header from reference frame");
01440 cpl_propertylist_delete(plist1);
01441 return -1;
01442 }
01443
01444
01445 if(cpl_error_get_code()) {
01446 cpl_propertylist_delete(plist1);
01447 cpl_propertylist_delete(plist2);
01448 return -1;
01449 }
01450
01451
01452 comparison = 1;
01453 dval1 = cpl_propertylist_get_double(plist1, "SETTING");
01454 dval2 = cpl_propertylist_get_double(plist2, "SETTING");
01455 if(cpl_error_get_code()) {
01456 cpl_msg_error(cpl_func, "cannot get exposure time");
01457 cpl_propertylist_delete(plist1);
01458 cpl_propertylist_delete(plist2);
01459 return -1;
01460 }
01461 if( dval1 != dval2)
01462 comparison = 0;
01463
01464
01465 cpl_propertylist_delete(plist1);
01466 cpl_propertylist_delete(plist2);
01467 return comparison;
01468
01469 }
01470
01471 cpl_imagelist * irplib_detmon_tests_imlist(int ndits, cpl_boolean onoff)
01472 {
01473 cpl_imagelist * imlist = cpl_imagelist_new();
01474 int i;
01475
01476 double levelstep = onoff ? ON_LEVEL : OFF_LEVEL;
01477 double factor = onoff ? 1.0 : 0.5;
01478
01479 for (i = 1; i <= ndits; i++) {
01480 cpl_image * im1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01481 cpl_image * im2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01482 double noise_min = NOISE_MIN * sqrt(i) / (double) ndits * factor;
01483 double noise_max = NOISE_MAX * sqrt(i) / (double) ndits * factor;
01484 cpl_image_fill_noise_uniform(im1, noise_min, noise_max);
01485 cpl_image_fill_noise_uniform(im2, noise_min, noise_max);
01486 cpl_image_add_scalar(im1, levelstep * i);
01487 cpl_image_add_scalar(im2, levelstep * i);
01488 cpl_imagelist_set(imlist, im1, 2 * (i - 1));
01489 cpl_imagelist_set(imlist, im2, 2 * (i - 1) + 1);
01490 }
01491
01492 return imlist;
01493 }
01494
01495 static void irplib_detmon_check_order_test(void)
01496 {
01497 const double TOLERANCE = 1E-7;
01498
01499 const double exptime[][9] = {
01500 { 1,2,3,4,5,6,7,8,9} ,
01501 { 1,1,1,4,5,6,7,8,9} ,
01502 { 1,2,3,4,5,5,5,8,9} ,
01503 { 1,2,3,4,5,6,8,8,8} ,
01504 { 1,1,1,1,1,6,6,6,6} ,
01505 };
01506 const int order[] = { 8, 6, 6, 6, 1 };
01507
01508 int sz = sizeof(exptime) / sizeof(exptime[0]);
01509 int i;
01510 for (i = 0; i < sz; i++)
01511 {
01512 const double* ex = exptime[i];
01513 cpl_error_code err = irplib_detmon_check_order(ex, 9, TOLERANCE, order[i]);
01514 cpl_test(err == CPL_ERROR_NONE);
01515 };
01516 }