CR2RE Pipeline Reference Manual 1.7.0
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <cpl_test.h>
25
26#include "../hdrl_cat_apio.h"
27#include "../hdrl_cat_phopt.h"
28
29
30int main(void)
31{
32 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
33
34 /* Initialize */
35 double apertures[] = {2.5, 3.53553, 5.0, 7.07107, 10, 14, 20, 25, 30, 35, 40, 50, 60};
36
37
38 /* Set up apm structure */
39 ap_t ap;
40 ap.lsiz = 2048;
41 ap.csiz = 2048;
42 ap.thresh = 11.0936;
43 ap.inframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
44 ap.conframe = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
45
46
47 /* Initialize */
48 hdrl_apinit(&ap);
49
50 ap.indata = cpl_image_get_data_double(ap.inframe);
51 ap.confdata = cpl_image_get_data_double(ap.conframe);
52 ap.mflag = cpl_calloc(2048 * 2048, sizeof(*ap.mflag));
53
54 /* Create a background */
55 cpl_image_fill_noise_uniform(ap.inframe, -10., 10.);
56 cpl_image_add_scalar( ap.inframe, 5000.);
57 cpl_image_fill_noise_uniform(ap.conframe, 99, 101);
58
59
60 double parm[IMNUM][NPAR];
61 for (cpl_size i = 0; i < IMNUM; i++) {
62 for (cpl_size j = 0; j < NPAR; j++) {
63 parm[i][j] = i + j;
64 }
65 }
66
67 /* Reserve memory for the fluxes */
68 double cflux[NRADS * IMNUM];
69
70 /* InitialiZe the badpix accumulator */
71 double badpix[IMNUM];
72 double avconf[IMNUM];
73
74 cpl_size nrcore = 2;
75
76 /*** TESTS ***/
77 cpl_size nbit;
78 cpl_error_code e;
79
80 /* Test 1 */
81 nbit = 1;
82 for (cpl_size i = 0; i < nbit; i++) {
83 badpix[i] = 0.;
84 avconf[i] = 0.;
85 }
86 e = hdrl_phopt(&ap, parm, nbit, NRADS, apertures, cflux, badpix, nrcore, avconf);
87 cpl_test_eq(e, CPL_ERROR_NONE);
88
89 /* Test 2 */
90 nbit = 2;
91 for (cpl_size i = 0; i < nbit; i++) {
92 badpix[i] = 0.;
93 avconf[i] = 0.;
94 }
95 e = hdrl_phopt(&ap, parm, nbit, NRADS, apertures, cflux, badpix, nrcore, avconf);
96 cpl_test_eq(e, CPL_ERROR_NONE);
97
98
99 /* Clean up */
100 hdrl_apclose(&ap);
101 cpl_free(ap.mflag);
102 cpl_image_delete(ap.inframe);
103 cpl_image_delete(ap.conframe);
104
105
106 return cpl_test_end(0);
107}
void hdrl_apinit(ap_t *ap)
Initialize the ap structure.
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.