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