VIRCAM Pipeline 2.3.12
imcore_areals-test.c
1/* $Id: imcore_areals-test.c,v 1.1 2015/10/15 16:18:25 jim Exp $
2 *
3 * This file is part of the CASU Pipeline utilities
4 * Copyright (C) 2015 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jim $
23 * $Date: 2015/10/15 16:18:25 $
24 * $Revision: 1.1 $
25 * $Name: $
26 */
27
28#include <stdio.h>
29#include <stdlib.h>
30
31#include <cpl_init.h>
32#include <cpl_test.h>
33#include <casu_mods.h>
34#include "../imcore.h"
35
36#define NT 117
37
38int main(void) {
39 int x[] = {398,399,400,397,398,399,400,401,402,403,396,397,398,399,400,
40 401,402,403,404,395,396,397,398,399,400,401,402,403,404,405,
41 395,396,397,398,399,400,401,402,403,404,405,395,396,397,398,
42 399,400,401,402,403,404,405,395,396,397,398,399,400,401,402,
43 403,404,405,406,395,396,397,398,399,400,401,402,403,404,405,
44 395,396,397,398,399,400,401,402,403,404,405,395,396,397,398,
45 399,400,401,402,403,404,405,396,397,398,399,400,401,402,403,
46 404,397,398,399,400,401,402,403,398,399,400,401};
47 int y[] = {394,394,394,395,395,395,395,395,395,395,396,396,396,396,396,
48 396,396,396,396,397,397,397,397,397,397,397,397,397,397,397,
49 398,398,398,398,398,398,398,398,398,398,398,399,399,399,399,
50 399,399,399,399,399,399,399,400,400,400,400,400,400,400,400,
51 400,400,400,400,401,401,401,401,401,401,401,401,401,401,401,
52 402,402,402,402,402,402,402,402,402,402,402,403,403,403,403,
53 403,403,403,403,403,403,403,404,404,404,404,404,404,404,404,
54 404,405,405,405,405,405,405,405,406,406,406,406};
55 float z[] = {8.87152,12.515,7.69699,10.8527,22.2509,21.7368,13.0388,
56 12.1853,17.1976,7.43948,15.2245,29.1964,37.9117,57.9371,
57 71.5542,57.1288,34.7726,15.5934,11.5374,15.995,21.3606,
58 60.4006,103.46,147.55,168.274,147.476,98.9157,51.7186,20.188,
59 3.04248,5.77832,49.3103,98.2057,187.557,268.353,310.638,
60 274.295,183.969,94.6933,47.9889,20.245,26.3758,59.1781,
61 152.389,275.916,395.107,450.251,397.53,272.322,147.053,54.767,
62 11.8971,13.3888,73.3689,165.899,298.455,449.707,493.25,441.585,
63 299.31,157.474,70.1224,15.5313,8.76074,20.7188,54.5798,141.249,
64 264.87,382.736,435.452,393.871,268.175,138.485,65.9307,28.7812,
65 19.379,36.6449,93.5458,186.823,270.95,305.093,260.879,183.683,
66 100.676,32.6281,16.6497,5.94965,17.8105,57.256,106.32,145.264,
67 164.271,137.093,88.9384,60.7841,31.8582,10.0435,4.69162,
68 15.2187,32.5385,61.0381,74.5399,67.3727,43.3964,25.0956,
69 16.7595,-0.37323,21.3832,19.2497,18.5883,9.37448,19.6048,
70 11.5006,13.0159,14.5852,13.66,-1.04889};
71 ap_t ap;
72 int i,iareal[NAREAL];
73
74 /* Initialise */
75
76 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
77
78 /* Set up apm structure */
79
80 ap.lsiz = 2048;
81 ap.csiz = 2048;
82 ap.xtnum = 0;
83 ap.inframe = NULL;
84 ap.conframe = NULL;
85 imcore_apinit(&ap);
86 ap.npl_pix = NT;
87 ap.plarray = cpl_realloc(ap.plarray,NT*sizeof(plstruct));
88 for (i = 0; i < NT; i++) {
89 ap.plarray[i].x = x[i];
90 ap.plarray[i].y = y[i];
91 ap.plarray[i].z = z[i];
92 ap.plarray[i].zsm = z[i];
93 }
94 ap.xintmin = 0.0;
95 ap.areal_offset = 3.47165;
96 ap.thresh = 11.0936;
97 ap.fconst = 1.4427;
98
99 /* Run the test */
100
101 imcore_areals(&ap,iareal);
102 cpl_test_eq(iareal[0],104);
103 cpl_test_eq(iareal[1],75);
104 cpl_test_eq(iareal[2],63);
105 cpl_test_eq(iareal[3],45);
106 cpl_test_eq(iareal[4],25);
107 cpl_test_eq(iareal[5],9);
108 cpl_test_eq(iareal[6],0);
109 cpl_test_eq(iareal[7],0);
110
111 /* Get out of here */
112
113 imcore_apclose(&ap);
114 return(cpl_test_end(0));
115
116}
117
118/*
119
120$Log: imcore_areals-test.c,v $
121Revision 1.1 2015/10/15 16:18:25 jim
122New
123
124
125*/
void imcore_areals(ap_t *ap, int iareal[NAREAL])
Work out the areal profiles for an object.
Definition: areals.c:67
void imcore_apclose(ap_t *ap)
Close ap structure.
Definition: apinit.c:186
void imcore_apinit(ap_t *ap)
Initialise the ap structure.
Definition: apinit.c:65