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 "detmon_ir_lg",
00279 -1,
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 0,
00300 NIR);
00301
00302 frameset = cpl_frameset_duplicate(set);
00303
00304 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00305 "detmon", REGEXP, prolist, prolist, prolist,
00306 prolist, prolist, prolist, "DETMON / 1.0",
00307 NULL, NULL, TRUE);
00308 cpl_test_error(CPL_ERROR_NONE);
00309 cpl_error_reset();
00310
00311 cpl_frameset_delete(frameset);
00312 cpl_parameterlist_delete(parlist);
00313
00314
00315 parlist = cpl_parameterlist_new();
00316 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00317 "MED",
00318 3,
00319 3,
00320 25,
00321 -1,
00322 -1,
00323 -1,
00324 -1,
00325 10000,
00326 "CPL_FALSE",
00327 "CPL_FALSE",
00328 "CPL_FALSE",
00329 "CPL_TRUE",
00330 "CPL_TRUE",
00331 "CPL_FALSE",
00332 -1,
00333 26,
00334 26,
00335 1e-3,
00336 "detmon_ir_lg",
00337 -1,
00338 -1,
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 0,
00358 NIR);
00359
00360 frameset = cpl_frameset_duplicate(set);
00361
00362 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00363 "detmon", REGEXP, prolist, prolist, prolist,
00364 prolist, prolist, prolist, "DETMON / 1.0",
00365 NULL, NULL, TRUE);
00366 cpl_test_error(CPL_ERROR_NONE);
00367 cpl_error_reset();
00368
00369 cpl_frameset_delete(frameset);
00370 cpl_parameterlist_delete(parlist);
00371
00372
00373
00374
00375
00376 parlist = cpl_parameterlist_new();
00377 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00378 "PTC",
00379 3,
00380 3,
00381 25,
00382 -1,
00383 -1,
00384 -1,
00385 -1,
00386 10000,
00387 "CPL_TRUE",
00388 "CPL_FALSE",
00389 "CPL_FALSE",
00390 "CPL_TRUE",
00391 "CPL_TRUE",
00392 "CPL_FALSE",
00393 -1,
00394 26,
00395 26,
00396 1e-3,
00397 "detmon_ir_lg",
00398 -1,
00399 -1,
00400 -1,
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 0,
00419 NIR);
00420
00421 frameset = cpl_frameset_duplicate(set);
00422
00423 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00424 "detmon", REGEXP, prolist, prolist, prolist,
00425 prolist, prolist, prolist, "DETMON / 1.0",
00426 NULL, NULL, TRUE);
00427 cpl_test_error(CPL_ERROR_NONE);
00428 cpl_error_reset();
00429
00430 cpl_frameset_delete(frameset);
00431 cpl_parameterlist_delete(parlist);
00432
00433
00434
00435
00436 parlist = cpl_parameterlist_new();
00437 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00438 "PTC",
00439 3,
00440 3,
00441 25,
00442 -1,
00443 -1,
00444 -1,
00445 -1,
00446 10000,
00447 "CPL_FALSE",
00448 "CPL_FALSE",
00449 "CPL_FALSE",
00450 "CPL_FALSE",
00451 "CPL_TRUE",
00452 "CPL_FALSE",
00453 -1,
00454 26,
00455 26,
00456 1e-3,
00457 "detmon_ir_lg",
00458 -1,
00459 -1,
00460 -1,
00461 -1,
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 0,
00479 NIR);
00480
00481 frameset = cpl_frameset_duplicate(set);
00482
00483 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00484 "detmon", REGEXP, prolist, prolist, prolist,
00485 prolist, prolist, prolist, "DETMON / 1.0",
00486 NULL, NULL, TRUE);
00487 cpl_test_error(CPL_ERROR_NONE);
00488 cpl_error_reset();
00489
00490 cpl_frameset_delete(frameset);
00491 cpl_parameterlist_delete(parlist);
00492
00493
00494 parlist = cpl_parameterlist_new();
00495 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00496 "PTC",
00497 3,
00498 3,
00499 25,
00500 -1,
00501 -1,
00502 -1,
00503 -1,
00504 10000,
00505 "CPL_FALSE",
00506 "CPL_FALSE",
00507 "CPL_FALSE",
00508 "CPL_TRUE",
00509 "CPL_TRUE",
00510 "CPL_TRUE",
00511 -1,
00512 26,
00513 26,
00514 1e-3,
00515 "detmon_ir_lg",
00516 -1,
00517 -1,
00518 -1,
00519 -1,
00520 -1,
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 0,
00537 NIR);
00538
00539 frameset = cpl_frameset_duplicate(set);
00540
00541 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00542 "detmon", REGEXP, prolist, prolist, prolist,
00543 prolist, prolist, prolist, "DETMON / 1.0",
00544 NULL, NULL, TRUE);
00545 cpl_test_error(CPL_ERROR_NONE);
00546 cpl_error_reset();
00547
00548 {
00549
00550 cpl_image * bpm = cpl_image_load("detmon_ir_lg_bpm.fits",
00551 CPL_TYPE_INT, 0, 0);
00552
00553 cpl_mask * mask = cpl_mask_threshold_image_create(bpm, 0.5, 1.5);
00554
00555 int nbpixs = cpl_mask_count(mask);
00556
00557 int flux = (int)cpl_image_get_flux(bpm);
00558
00559 cpl_test_eq(flux, nbpixs);
00560
00561 cpl_image_delete(bpm);
00562 cpl_mask_delete(mask);
00563 }
00564
00565 cpl_frameset_delete(frameset);
00566 cpl_parameterlist_delete(parlist);
00567
00568
00569
00570
00571
00572
00573 parlist = cpl_parameterlist_new();
00574 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00575 "PTC",
00576 3,
00577 3,
00578 25,
00579 -1,
00580 -1,
00581 -1,
00582 -1,
00583 10000,
00584 "CPL_FALSE",
00585 "CPL_FALSE",
00586 "CPL_FALSE",
00587 "CPL_TRUE",
00588 "CPL_FALSE",
00589 "CPL_FALSE",
00590 -1,
00591 26,
00592 26,
00593 1e-3,
00594 "detmon_ir_lg",
00595 -1,
00596 -1,
00597 -1,
00598 -1,
00599 -1,
00600 -1,
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 0,
00616 NIR);
00617
00618 frameset = cpl_frameset_duplicate(set);
00619
00620
00621
00622
00623
00624
00625
00626
00627 cpl_frameset_delete(frameset);
00628 cpl_parameterlist_delete(parlist);
00629
00630
00631
00632
00633 parlist = cpl_parameterlist_new();
00634 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00635 "PTC",
00636 3,
00637 3,
00638 25,
00639 -1,
00640 -1,
00641 -1,
00642 -1,
00643 10000,
00644 "CPL_FALSE",
00645 "CPL_FALSE",
00646 "CPL_FALSE",
00647 "CPL_TRUE",
00648 "CPL_TRUE",
00649 "CPL_FALSE",
00650 4000,
00651 26,
00652 26,
00653 1e-3,
00654 "detmon_ir_lg",
00655 -1,
00656 -1,
00657 -1,
00658 -1,
00659 -1,
00660 -1,
00661 -1,
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 0,
00676 NIR);
00677
00678 frameset = cpl_frameset_duplicate(set);
00679
00680 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg",
00681 "detmon", REGEXP, prolist, prolist, prolist,
00682 prolist, prolist, prolist, "DETMON / 1.0",
00683 NULL, NULL, TRUE);
00684 cpl_test_error(CPL_ERROR_NONE);
00685 cpl_error_reset();
00686
00687 cpl_frameset_delete(frameset);
00688 cpl_parameterlist_delete(parlist);
00689
00690
00691
00692 cpl_frameset_delete(set);
00693
00694
00695
00696
00697
00698
00699
00700 parlist = cpl_parameterlist_new();
00701 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00702 "PTC",
00703 3,
00704 3,
00705 25,
00706 -1,
00707 -1,
00708 -1,
00709 -1,
00710 10000,
00711 "CPL_FALSE",
00712 "CPL_FALSE",
00713 "CPL_FALSE",
00714 "CPL_TRUE",
00715 "CPL_TRUE",
00716 "CPL_FALSE",
00717 -1,
00718 26,
00719 26,
00720 1e-3,
00721 "detmon_ir_lg",
00722 -1,
00723 -1,
00724 -1,
00725 -1,
00726 -1,
00727 -1,
00728 -1,
00729 -1,
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 0,
00743 NIR);
00744
00745 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00746 6, TRUE, FALSE, 0, 1);
00747
00748
00749
00750
00751
00752
00753
00754
00755 cpl_frameset_delete(frameset);
00756 cpl_parameterlist_delete(parlist);
00757
00758
00759
00760 parlist = cpl_parameterlist_new();
00761 irplib_detmon_lg_fill_parlist_opt_default(parlist,
00762 "detmon_opt_lg", "detmon");
00763
00764 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00765 20, FALSE, FALSE, 0, 1);
00766
00767
00768
00769
00770
00771
00772
00773
00774 cpl_frameset_delete(frameset);
00775 cpl_parameterlist_delete(parlist);
00776
00777 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 1, 0)
00778
00779 parlist = cpl_parameterlist_new();
00780 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00781 "PTC",
00782 3,
00783 3,
00784 25,
00785 -1,
00786 -1,
00787 -1,
00788 -1,
00789 10000,
00790 "CPL_FALSE",
00791 "CPL_FALSE",
00792 "CPL_FALSE",
00793 "CPL_TRUE",
00794 "CPL_TRUE",
00795 "CPL_FALSE",
00796 -1,
00797 26,
00798 26,
00799 1e-3,
00800 "detmon_ir_lg",
00801 -1,
00802 -1,
00803 -1,
00804 -1,
00805 -1,
00806 -1,
00807 -1,
00808 -1,
00809 -1,
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 NIR);
00823
00824
00825
00826
00827
00828
00829
00830
00831 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00832 20, TRUE, TRUE, 8, 1);
00833
00834 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00835 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", NULL, NULL, TRUE);
00836 cpl_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00837 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00838 cpl_error_reset();
00839
00840 cpl_parameterlist_delete(parlist);
00841 cpl_frameset_delete(frameset);
00842 #endif
00843
00844
00845
00846 parlist = cpl_parameterlist_new();
00847 irplib_detmon_lg_fill_parlist(parlist, "detmon_ir_lg", "detmon",
00848 "PTC",
00849 3,
00850 3,
00851 25,
00852 -1,
00853 -1,
00854 -1,
00855 -1,
00856 10000,
00857 "CPL_FALSE",
00858 "CPL_FALSE",
00859 "CPL_FALSE",
00860 "CPL_TRUE",
00861 "CPL_TRUE",
00862 "CPL_FALSE",
00863 -1,
00864 26,
00865 26,
00866 1e-3,
00867 "detmon_ir_lg",
00868 -1,
00869 -1,
00870 -1,
00871 -1,
00872 -1,
00873 -1,
00874 -1,
00875 -1,
00876 -1,
00877 -1,
00878 -1,
00879 -1,
00880 -1,
00881 -1,
00882 -1,
00883 -1,
00884 -1,
00885 -1,
00886 -1,
00887 -1,
00888 2,
00889 NIR);
00890
00891
00892
00893
00894
00895
00896
00897
00898 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00899 20, TRUE, TRUE, 8, 1);
00900
00901 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00902 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", NULL, NULL, TRUE);
00903 cpl_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00904 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00905 cpl_error_reset();
00906
00907 cpl_parameterlist_delete(parlist);
00908 cpl_frameset_delete(frameset);
00909
00910
00911
00912 parlist = cpl_parameterlist_new();
00913 irplib_detmon_lg_fill_parlist_nir_default(parlist, "detmon_ir_lg", "detmon");
00914
00915 frameset = irplib_detmon_tests_fill_frameset_oct(tag_on, tag_off, 20, TRUE, FALSE, 0);
00916
00917
00918
00919
00920
00921
00922
00923 cpl_parameterlist_delete(parlist);
00924 cpl_frameset_delete(frameset);
00925
00926
00927 parlist = cpl_parameterlist_new();
00928 irplib_detmon_lg_fill_parlist_nir_default(parlist, "detmon_ir_lg", "detmon");
00929
00930 frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00931 20, TRUE, FALSE, 0, 3);
00932
00933 irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00934 prolist, prolist, prolist, prolist, prolist, prolist, "DETMON / 1.0", compare_settings, NULL, TRUE);
00935
00936 cpl_test_error(CPL_ERROR_NONE);
00937
00938 cpl_parameterlist_delete(parlist);
00939 cpl_frameset_delete(frameset);
00940
00941 cpl_propertylist_delete(prolist);
00942
00943 cpl_test_zero(system("rm *.paf *.fits"));
00944
00945
00946 {
00947
00948 cpl_table * gain_table;
00949 cpl_imagelist * imlist_on;
00950 cpl_imagelist * imlist_off;
00951 cpl_imagelist * diff;
00952 cpl_imagelist * corr;
00953 cpl_vector * exptimes;
00954 cpl_vector * ndits;
00955 cpl_propertylist * qclist;
00956 int i;
00957 double gain;
00958
00959
00960 gain_table = irplib_detmon_gain(NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0.0,
00961 0, 0, 0, NULL, 0, NULL, NULL);
00962 cpl_test_null(gain_table);
00963 cpl_test_error(CPL_ERROR_NULL_INPUT);
00964
00965 imlist_on = irplib_detmon_tests_imlist(8, ON);
00966 imlist_off = irplib_detmon_tests_imlist(8, OFF);
00967
00968 exptimes = cpl_vector_new(16);
00969 ndits = cpl_vector_new(16);
00970
00971 for(i = 0; i < 16; i++) {
00972 cpl_vector_set(exptimes, i, (double)(i/2 + 1));
00973 cpl_vector_set(ndits, i, 1.);
00974 }
00975
00976 qclist = cpl_propertylist_new();
00977
00978 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
00979 0.0,
00980 1, 1,
00981 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
00982 qclist, IRPLIB_GAIN_NO_COLLAPSE |
00983 IRPLIB_GAIN_NIR,
00984 NULL, NULL);
00985
00986
00987 cpl_test_nonnull(gain_table);
00988 cpl_test_error(CPL_ERROR_NONE);
00989
00990
00991 gain = cpl_propertylist_get_double(qclist, DETMON_QC_GAIN);
00992 cpl_test(gain > 220.0 && gain < 240.0);
00993
00994 cpl_table_delete(gain_table);
00995 cpl_propertylist_delete(qclist);
00996
00997
00998 qclist = cpl_propertylist_new();
00999
01000 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01001 0.0,
01002 1, 1,
01003 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01004 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01005 IRPLIB_GAIN_NIR |
01006 IRPLIB_GAIN_PTC,
01007 NULL, NULL);
01008 cpl_test_nonnull(gain_table);
01009 cpl_test_error(CPL_ERROR_NONE);
01010
01011
01012 gain = cpl_propertylist_get_double(qclist, DETMON_QC_GAIN);
01013 cpl_test(gain > 160.0 && gain < 180.0);
01014
01015 cpl_table_delete(gain_table);
01016 cpl_propertylist_delete(qclist);
01017
01018 qclist = cpl_propertylist_new();
01019
01020 diff = NULL;
01021 corr = NULL;
01022
01023 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01024 0.0,
01025 1, 1,
01026 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01027 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01028 IRPLIB_GAIN_NIR |
01029 IRPLIB_GAIN_WITH_AUTOCORR, &diff, &corr);
01030 cpl_test_nonnull(gain_table);
01031 cpl_test_nonnull(diff);
01032 cpl_test_nonnull(corr);
01033 cpl_test_error(CPL_ERROR_NONE);
01034
01035 cpl_imagelist_delete(diff);
01036 cpl_imagelist_delete(corr);
01037 cpl_table_delete(gain_table);
01038 cpl_propertylist_delete(qclist);
01039
01040 qclist = cpl_propertylist_new();
01041
01042 gain_table = irplib_detmon_gain(imlist_on, imlist_off, exptimes, ndits,
01043 0.0,
01044 1, 1,
01045 IMAGESIZE, IMAGESIZE, 3.0, 25, 26, 26,
01046 qclist, IRPLIB_GAIN_NO_COLLAPSE |
01047 IRPLIB_GAIN_NIR |
01048 IRPLIB_GAIN_WITH_AUTOCORR, NULL, NULL);
01049 cpl_test_nonnull(gain_table);
01050 cpl_test_error(CPL_ERROR_NONE);
01051
01052 cpl_imagelist_delete(imlist_on);
01053 cpl_imagelist_delete(imlist_off);
01054 cpl_propertylist_delete(qclist);
01055 cpl_vector_delete(exptimes);
01056 cpl_vector_delete(ndits);
01057 cpl_table_delete(gain_table);
01058 }
01059
01060
01061 {
01062 cpl_table * lin_table;
01063 cpl_imagelist * imlist_on;
01064 cpl_imagelist * imlist_off;
01065 cpl_vector * exptimes;
01066 cpl_propertylist * qclist;
01067 cpl_imagelist * coeffs_cube =NULL;
01068 cpl_image * bpm =NULL;
01069 double lincoeff1, lincoeff2, lincoeff3;
01070 int i;
01071
01072
01073 lin_table = irplib_detmon_lin(NULL, NULL, NULL, 0.0, 0, 0, 0, 0,
01074 0, 10000, 3, FALSE, NULL, 0, NULL, NULL);
01075
01076 cpl_test_null(lin_table);
01077 cpl_test_error(CPL_ERROR_NULL_INPUT);
01078
01079
01080 imlist_on = irplib_detmon_tests_imlist(8, ON);
01081 imlist_off = irplib_detmon_tests_imlist(8, OFF);
01082
01083 exptimes = cpl_vector_new(16);
01084
01085 for(i = 0; i < 16; i++) {
01086 cpl_vector_set(exptimes, i, (double)(i/2 + 1));
01087 }
01088
01089 qclist = cpl_propertylist_new();
01090
01091 lin_table = irplib_detmon_lin(imlist_on, imlist_off, exptimes, 0.0,
01092 1, 1, IMAGESIZE, IMAGESIZE,
01093 3, 10000, 3, FALSE, qclist,
01094 IRPLIB_LIN_NO_COLLAPSE |
01095 IRPLIB_LIN_NIR,
01096 NULL, NULL);
01097
01098 cpl_test_nonnull(lin_table);
01099 cpl_test_error(CPL_ERROR_NONE);
01100
01101
01102 lincoeff1 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF1");
01103 lincoeff2 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF2");
01104 lincoeff3 = cpl_propertylist_get_double(qclist, "ESO QC LIN COEF3");
01105
01106 cpl_test(lincoeff1 > 195.0 && lincoeff1 < 205.0);
01107 cpl_test(abs(lincoeff2) < 1);
01108 cpl_test(abs(lincoeff3) < 1);
01109
01110 cpl_table_delete(lin_table);
01111
01112 lin_table = irplib_detmon_lin(imlist_on, imlist_off, exptimes, 0.0,
01113 1, 1, IMAGESIZE, IMAGESIZE,
01114 3, 10000, 3, FALSE, qclist,
01115 IRPLIB_LIN_NO_COLLAPSE |
01116 IRPLIB_LIN_NIR | IRPLIB_LIN_PIX2PIX,
01117 &coeffs_cube, &bpm);
01118
01119 cpl_test_nonnull(lin_table);
01120 cpl_test_nonnull(coeffs_cube);
01121 cpl_test_nonnull(bpm);
01122 cpl_test_error(CPL_ERROR_NONE);
01123
01124 cpl_table_delete(lin_table);
01125 cpl_imagelist_delete(coeffs_cube);
01126 cpl_image_delete(bpm);
01127
01128 cpl_imagelist_delete(imlist_on);
01129 cpl_imagelist_delete(imlist_off);
01130 cpl_vector_delete(exptimes);
01131 cpl_propertylist_delete(qclist);
01132 }
01133 }
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146 cpl_frameset * irplib_detmon_tests_fill_frameset(const char * tag_on,
01147 const char * tag_off,
01148 int non,
01149 cpl_boolean opt_nir,
01150 cpl_boolean with_exts,
01151 int nexts,
01152 int nsettings)
01153 {
01154 cpl_frameset * frameset;
01155 cpl_frame * frame;
01156 int i, h;
01157 char frame_name[20];
01158 cpl_propertylist * plist;
01159 cpl_image * image;
01160 frameset = cpl_frameset_new();
01161
01162 for (h = 0; h < nsettings; h++) {
01163 for (i=0; i<non; i++) {
01164 frame = cpl_frame_new();
01165 sprintf(frame_name, "dummyon%d%d.fits",i,h);
01166 cpl_frame_set_filename(frame, frame_name);
01167 cpl_frame_set_tag(frame, tag_on);
01168 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01169 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01170
01171 cpl_frameset_insert(frameset, frame);
01172
01173 plist = cpl_propertylist_new();
01174 if(opt_nir == TRUE) {
01175 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01176 cpl_propertylist_append_int(plist, "ESO DET NDIT", 1);
01177 } else {
01178 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01179 }
01180
01181 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2 + 1) );
01182 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01183
01184 cpl_propertylist_append_double(plist, "SETTING", h+1);
01185 if(with_exts == TRUE) {
01186 int j;
01187 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01188 for(j = 0; j < nexts; j++) {
01189 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01190 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01191 cpl_image_add_scalar(image,300* i);
01192 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01193
01194 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01195 cpl_image_delete(image);
01196 }
01197 } else {
01198 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01199 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01200 cpl_image_add_scalar(image,300* i);
01201 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01202
01203 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01204
01205
01206 cpl_image_delete(image);
01207 }
01208 cpl_propertylist_delete(plist);
01209 }
01210 for (i=0; i<non; i++) {
01211
01212
01213 frame = cpl_frame_new();
01214 sprintf(frame_name, "dummyoff%d%d.fits",i,h);
01215 cpl_frame_set_filename(frame, frame_name);
01216 cpl_frame_set_tag(frame, tag_off);
01217 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01218 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01219
01220 cpl_frameset_insert(frameset, frame);
01221
01222 plist = cpl_propertylist_new();
01223 if(opt_nir == TRUE) {
01224 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01225 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01226 } else {
01227 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01228 }
01229 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01230 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2 + 1));
01231 cpl_propertylist_append_double(plist, "SETTING", h+1);
01232
01233 if(with_exts == TRUE) {
01234 int j;
01235 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01236 for(j = 0; j < nexts; j++) {
01237 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01238 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01239 cpl_image_add_scalar(image, i);
01240 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01241
01242 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01243 cpl_image_delete(image);
01244 }
01245 } else {
01246 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01247 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01248 cpl_image_add_scalar(image, i);
01249 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01250
01251 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01252
01253
01254 cpl_image_delete(image);
01255 }
01256 cpl_propertylist_delete(plist);
01257 }
01258 }
01259
01260 return frameset;
01261 }
01262
01263
01264 cpl_frameset * irplib_detmon_tests_fill_frameset_oct(const char * tag_on,
01265 const char * tag_off,
01266 int non,
01267 cpl_boolean opt_nir,
01268 cpl_boolean with_exts,
01269 int nexts)
01270 {
01271 cpl_frameset * frameset;
01272 cpl_frame * frame;
01273 int i;
01274 char frame_name[20];
01275 cpl_propertylist * plist;
01276 cpl_image * image;
01277 frameset = cpl_frameset_new();
01278
01279 for (i=0; i<non; i++) {
01280 frame = cpl_frame_new();
01281 sprintf(frame_name, "dummyon%d.fits",i);
01282 cpl_frame_set_filename(frame, frame_name);
01283 cpl_frame_set_tag(frame, tag_on);
01284 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01285 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01286
01287 cpl_frameset_insert(frameset, frame);
01288
01289 plist = cpl_propertylist_new();
01290 if(opt_nir == TRUE) {
01291 if( i == 2 || i == 3) {
01292 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
01293 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01294 cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
01295 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01296 } else {
01297 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01298 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01299 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
01300 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01301 }
01302 } else {
01303 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01304 cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
01305 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01306 }
01307
01308 if(with_exts == TRUE) {
01309 int j;
01310 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01311 for(j = 0; j < nexts; j++) {
01312 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01313 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01314 if(i == 0 || i == 1 || i== 2 || i == 3) {
01315 cpl_image_add_scalar(image,300);
01316 } else
01317 cpl_image_add_scalar(image,300* i);
01318 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01319
01320 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01321 cpl_image_delete(image);
01322 }
01323 } else {
01324 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01325 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01326 if(i == 0 || i == 1 || i== 2 || i == 3) {
01327 cpl_image_add_scalar(image,300);
01328 } else
01329 cpl_image_add_scalar(image,300* i);
01330
01331 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01332
01333 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01334
01335
01336 cpl_image_delete(image);
01337 }
01338 cpl_propertylist_delete(plist);
01339 }
01340
01341 for (i=0; i<non; i++) {
01342
01343
01344 frame = cpl_frame_new();
01345 sprintf(frame_name, "dummyoff%d.fits",i);
01346 cpl_frame_set_filename(frame, frame_name);
01347 cpl_frame_set_tag(frame, tag_off);
01348 cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
01349 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
01350
01351 cpl_frameset_insert(frameset, frame);
01352
01353 plist = cpl_propertylist_new();
01354 if(opt_nir == TRUE) {
01355 if( i == 2 || i == 3) {
01356 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
01357 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01358 cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
01359 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01360 } else {
01361 cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
01362 cpl_propertylist_append_double(plist, "ESO DET NDIT", 1);
01363 cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
01364 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01365 }
01366 } else {
01367 cpl_propertylist_append_double(plist, "ESO DET WIN1 UIT1", (double)((i+1)/2));
01368 cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
01369 cpl_propertylist_append_double(plist, "MJD-OBS", 0);
01370 }
01371
01372 if(with_exts == TRUE) {
01373 int j;
01374 cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01375 for(j = 0; j < nexts; j++) {
01376 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01377 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01378 if(i == 0 || i == 1 || i== 2 || i == 3) {
01379 cpl_image_add_scalar(image,300);
01380 } else
01381 cpl_image_add_scalar(image,300* i);
01382
01383 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01384
01385 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
01386 cpl_image_delete(image);
01387 }
01388 } else {
01389 image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01390 cpl_image_fill_noise_uniform(image, 5 - i, 10 + i);
01391 if(i == 0 || i == 1 || i== 2 || i == 3) {
01392 cpl_image_add_scalar(image,300);
01393 } else
01394 cpl_image_add_scalar(image,300* i);
01395
01396 cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
01397
01398 cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
01399
01400
01401 cpl_image_delete(image);
01402 }
01403 cpl_propertylist_delete(plist);
01404 }
01405
01406 return frameset;
01407 }
01408
01409
01410 int compare_settings(const cpl_frame * frame1, const cpl_frame * frame2)
01411 {
01412 int comparison;
01413 cpl_propertylist *plist1;
01414 cpl_propertylist *plist2;
01415 double dval1, dval2;
01416
01417
01418 if(frame1 == NULL || frame2 == NULL)
01419 return -1;
01420
01421
01422 if((plist1 = cpl_propertylist_load(cpl_frame_get_filename(frame1),
01423 0)) == NULL) {
01424 cpl_msg_error(cpl_func, "getting header from reference frame");
01425 return -1;
01426 }
01427 if((plist2 = cpl_propertylist_load(cpl_frame_get_filename(frame2),
01428 0)) == NULL) {
01429 cpl_msg_error(cpl_func, "getting header from reference frame");
01430 cpl_propertylist_delete(plist1);
01431 return -1;
01432 }
01433
01434
01435 if(cpl_error_get_code()) {
01436 cpl_propertylist_delete(plist1);
01437 cpl_propertylist_delete(plist2);
01438 return -1;
01439 }
01440
01441
01442 comparison = 1;
01443 dval1 = cpl_propertylist_get_double(plist1, "SETTING");
01444 dval2 = cpl_propertylist_get_double(plist2, "SETTING");
01445 if(cpl_error_get_code()) {
01446 cpl_msg_error(cpl_func, "cannot get exposure time");
01447 cpl_propertylist_delete(plist1);
01448 cpl_propertylist_delete(plist2);
01449 return -1;
01450 }
01451 if( dval1 != dval2)
01452 comparison = 0;
01453
01454
01455 cpl_propertylist_delete(plist1);
01456 cpl_propertylist_delete(plist2);
01457 return comparison;
01458
01459 }
01460
01461 cpl_imagelist * irplib_detmon_tests_imlist(int ndits, cpl_boolean onoff)
01462 {
01463 cpl_imagelist * imlist = cpl_imagelist_new();
01464 int i;
01465
01466 double levelstep = onoff ? ON_LEVEL : OFF_LEVEL;
01467 double factor = onoff ? 1.0 : 0.5;
01468
01469 for (i = 1; i <= ndits; i++) {
01470 cpl_image * im1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01471 cpl_image * im2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
01472 double noise_min = NOISE_MIN * sqrt(i) / (double) ndits * factor;
01473 double noise_max = NOISE_MAX * sqrt(i) / (double) ndits * factor;
01474 cpl_image_fill_noise_uniform(im1, noise_min, noise_max);
01475 cpl_image_fill_noise_uniform(im2, noise_min, noise_max);
01476 cpl_image_add_scalar(im1, levelstep * i);
01477 cpl_image_add_scalar(im2, levelstep * i);
01478 cpl_imagelist_set(imlist, im1, 2 * (i - 1));
01479 cpl_imagelist_set(imlist, im2, 2 * (i - 1) + 1);
01480 }
01481
01482 return imlist;
01483 }
01484
01485 static void irplib_detmon_check_order_test(void)
01486 {
01487 const double TOLERANCE = 1E-7;
01488
01489 const double exptime[][9] = {
01490 { 1,2,3,4,5,6,7,8,9} ,
01491 { 1,1,1,4,5,6,7,8,9} ,
01492 { 1,2,3,4,5,5,5,8,9} ,
01493 { 1,2,3,4,5,6,8,8,8} ,
01494 { 1,1,1,1,1,6,6,6,6} ,
01495 };
01496 const int order[] = { 8, 6, 6, 6, 1 };
01497
01498 int sz = sizeof(exptime) / sizeof(exptime[0]);
01499 int i;
01500 for (i = 0; i < sz; i++)
01501 {
01502 const double* ex = exptime[i];
01503 cpl_error_code err = irplib_detmon_check_order(ex, 9, TOLERANCE, order[i]);
01504 cpl_test(err == CPL_ERROR_NONE);
01505 };
01506 }