CR2RE Pipeline Reference Manual 1.6.8
hdrl_cat_phopt-test.c
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2017 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <cpl_test.h>
21
22#include "../hdrl_cat_apio.h"
23#include "../hdrl_cat_phopt.h"
24
25
26int main(void)
27{
28 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
29
30 /* Initialize */
31 double apertures[] = {2.5, 3.53553, 5.0, 7.07107, 10, 14, 20, 25, 30, 35, 40, 50, 60};
32
33
34 /* Set up apm structure */
35 ap_t ap;
36 ap.lsiz = 2048;
37 ap.csiz = 2048;
38 ap.thresh = 11.0936;
39 ap.inframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
40 ap.conframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
41
42
43 /* Initialize */
44 hdrl_apinit(&ap);
45
46 ap.indata = cpl_image_get_data_double(ap.inframe);
47 ap.confdata = cpl_image_get_data_double(ap.conframe);
48 ap.mflag = cpl_calloc(2048 * 2048, sizeof(*ap.mflag));
49
50 /* Create a background */
51 cpl_image_fill_noise_uniform(ap.inframe, -10., 10.);
52 cpl_image_add_scalar( ap.inframe, 5000.);
53 cpl_image_fill_noise_uniform(ap.conframe, 99, 101);
54
55
56 double parm[IMNUM][NPAR];
57 for (cpl_size i = 0; i < IMNUM; i++) {
58 for (cpl_size j = 0; j < NPAR; j++) {
59 parm[i][j] = i + j;
60 }
61 }
62
63 /* Reserve memory for the fluxes */
64 double cflux[NRADS * IMNUM];
65
66 /* InitialiZe the badpix accumulator */
67 double badpix[IMNUM];
68 double avconf[IMNUM];
69
70 cpl_size nrcore = 2;
71
72 /*** TESTS ***/
73 cpl_size nbit;
74 cpl_error_code e;
75
76 /* Test 1 */
77 nbit = 1;
78 for (cpl_size i = 0; i < nbit; i++) {
79 badpix[i] = 0.;
80 avconf[i] = 0.;
81 }
82 e = hdrl_phopt(&ap, parm, nbit, NRADS, apertures, cflux, badpix, nrcore, avconf);
83 cpl_test_eq(e, CPL_ERROR_NONE);
84
85 /* Test 2 */
86 nbit = 2;
87 for (cpl_size i = 0; i < nbit; i++) {
88 badpix[i] = 0.;
89 avconf[i] = 0.;
90 }
91 e = hdrl_phopt(&ap, parm, nbit, NRADS, apertures, cflux, badpix, nrcore, avconf);
92 cpl_test_eq(e, CPL_ERROR_NONE);
93
94
95 /* Clean up */
96 hdrl_apclose(&ap);
97 cpl_free(ap.mflag);
98 cpl_image_delete(ap.inframe);
99 cpl_image_delete(ap.conframe);
100
101
102 return cpl_test_end(0);
103}
void hdrl_apinit(ap_t *ap)
Initialize the ap structure.
Definition: hdrl_cat_apio.c:54
void hdrl_apclose(ap_t *ap)
Close ap structure.
cpl_error_code hdrl_phopt(ap_t *ap, double parm[IMNUM][NPAR], cpl_size nbit, cpl_size naper, double apertures[], double cflux[], double badpix[], cpl_size nrcore, double avconf[])
Does multiple profile fitting to determine intensities.