CR2RE Pipeline Reference Manual 1.7.0
hdrl_cat_seeing-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_seeing.h"
27
28
29int main(void)
30{
31 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
32
33
34 /* Initialize */
35
36 double ell[] = {0.009, 0.050, 0.025, 0.033, 0.010, 0.012, 0.014, 0.005, 0.011, 0.011};
37
38 double pk[] = {1007.065, 101.293, 204.195, 493.250, 559.111, 609.799, 642.603, 698.117, 740.227, 797.222};
39
40 double areal[][10] = { {120., 53., 73., 104., 97., 109., 104., 107., 110., 110.},
41 {100., 39., 60., 75., 80., 81., 86., 90., 94., 95.},
42 { 75., 21., 42., 63., 66., 64., 68., 69., 69., 70.},
43 { 63., 2., 21., 45., 45., 45., 45., 47., 56., 56.},
44 { 45., 0., 4., 25., 29., 29., 37., 37., 37., 37.},
45 { 25., 0., 0., 9., 9., 13., 14., 21., 21., 21.},
46 { 9., 0., 0., 0., 0., 0., 0., 1., 1. },
47 { 0., 0., 0., 0., 0., 0., 0., 0. } };
48
49 /* Set up apm structure */
50 ap_t ap;
51 ap.lsiz = 2048;
52 ap.csiz = 2048;
53 ap.thresh = 11.0936;
54
55 /* Create areals */
56 double **areals = cpl_malloc(8 * sizeof(double *));
57 for (cpl_size i = 0; i < 8; i++) {
58 areals[i] = cpl_malloc(10 * sizeof(double));
59
60 for (cpl_size j = 0; j < 10; j++) {
61 areals[i][j] = areal[i][j];
62 }
63 }
64
65 /* Run the test */
66 double *work = cpl_malloc(10 * sizeof(double));
67 double fwhm;
68 hdrl_seeing(&ap, 10, ell, pk, areals, work, &fwhm);
69 cpl_test_rel(fwhm, 4.50384, 0.01);
70 cpl_free(work);
71
72 /* Clean up */
73 for (cpl_size i = 0; i < 8; i++) {
74 cpl_free(areals[i]);
75 }
76 cpl_free(areals);
77
78
79 return cpl_test_end(0);
80}
cpl_error_code hdrl_seeing(ap_t *ap, cpl_size nrows, double *ellipt, double *pkht, double **areal, double *work, double *fwhm)
Work out the median seeing.