UVES Pipeline Reference Manual  5.4.6
uves_wavecal-test.c
1 /* *
2  * This file is part of the ESO UVES Pipeline *
3  * Copyright (C) 2004,2005 European Southern Observatory *
4  * *
5  * This library 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, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18  * */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2009-06-05 05:49:02 $
23  * $Revision: 1.4 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.3 2007/08/13 12:15:43 amodigli
27  * support of CPL4
28  *
29  * Revision 1.2 2007/05/23 06:43:23 jmlarsen
30  * Removed unused variables
31  *
32  * Revision 1.1 2007/03/15 12:27:18 jmlarsen
33  * Moved unit tests to ./uves/tests and ./flames/tests
34  *
35  * Revision 1.3 2007/02/27 14:04:14 jmlarsen
36  * Move unit test infrastructure to IRPLIB
37  *
38  * Revision 1.2 2007/01/29 12:17:54 jmlarsen
39  * Support setting verbosity from command line
40  *
41  * Revision 1.1 2006/11/28 08:26:35 jmlarsen
42  * Added QC log unit test
43  *
44  */
45 
46 /*-----------------------------------------------------------------------------
47  Includes
48  -----------------------------------------------------------------------------*/
49 
50 #ifdef HAVE_CONFIG_H
51 # include <config.h>
52 #endif
53 
54 #include <uves_wavecal_identify.h>
55 #include <uves_wavecal_utils.h>
56 #include <uves_utils_wrappers.h>
57 #include <uves_error.h>
58 #include <cpl_test.h>
59 
60 #include <cpl.h>
61 #include <math.h>
62 /*-----------------------------------------------------------------------------
63  Defines
64  -----------------------------------------------------------------------------*/
65 
66 /*-----------------------------------------------------------------------------
67  Functions prototypes
68  -----------------------------------------------------------------------------*/
69 
70 
71 /*----------------------------------------------------------------------------*/
75 /*----------------------------------------------------------------------------*/
78 /*----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------*/
83 static void
84 test_ppm(void)
85 {
86  int nlines = 50;
87  int minorder = 94;
88  int maxorder = 97;
89  const int norders = maxorder - minorder + 1;
90  int i, order;
91 
92  cpl_table *linetable = cpl_table_new(norders * nlines);
93  cpl_table *line_refer = cpl_table_new(nlines);
94 
95  cpl_table_new_column(line_refer, "Wave", CPL_TYPE_DOUBLE);
96 
97  for (i = 0; i < nlines; i++)
98  {
99  cpl_table_set_double(line_refer, "Wave", i, 1000 + 500*sin(i));
100  }
101 
102  cpl_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
103 
104  cpl_table_new_column(linetable, "X" , CPL_TYPE_DOUBLE);
105  cpl_table_new_column(linetable, "Order" , CPL_TYPE_INT);
106  cpl_table_new_column(linetable, LINETAB_LAMBDAC , CPL_TYPE_DOUBLE);
107  cpl_table_new_column(linetable, LINETAB_PIXELSIZE, CPL_TYPE_DOUBLE);
108 
109  for (order = minorder; order <= maxorder; order++)
110  {
111  for (i = 0; i < nlines; i++)
112  {
113  int row = (order-minorder)*nlines + i;
114 
115  cpl_table_set_int(linetable, "Order", row,
116  order);
117 
118  cpl_table_set_double(linetable, LINETAB_PIXELSIZE, row, 1);
119 
120  /* Set X = catalogue wavelength */
121  cpl_table_set_double(linetable, "X", row,
122  cpl_table_get_double(line_refer, "Wave", i, NULL));
123 
124  cpl_table_set_double(linetable, LINETAB_LAMBDAC, row,
125  cpl_table_get_double(line_refer, "Wave", i, NULL));
126  }
127  }
128 
129  cpl_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
130 
131 /*
132  cpl_table_dump_structure(linetable, stdout);
133  cpl_table_dump(linetable, 0, cpl_table_get_nrow(linetable), stdout);
134  cpl_table_dump(line_refer, 0, cpl_table_get_nrow(line_refer), stdout);
135 */
136 
138  line_refer);
139 
140  cpl_test( cpl_table_has_column(linetable, "Ident_ppm") );
141 
142  uves_free_table(&linetable);
143  uves_free_table(&line_refer);
144 
145  return;
146 }
147 
148 
149 /*----------------------------------------------------------------------------*/
153 /*----------------------------------------------------------------------------*/
154 
155 int main(void)
156 {
157  cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
158  cpl_errorstate initial_errorstate = cpl_errorstate_get();
159  test_ppm();
160 
161  if (cpl_error_get_code() != CPL_ERROR_NONE)
162  {
163  cpl_errorstate_dump(initial_errorstate,CPL_FALSE,NULL);
164  }
165  return cpl_test_end(0);
166 }
167 
168 
int uves_wavecal_identify_lines_ppm(cpl_table *linetable, const cpl_table *line_refer)
Identify lines using point pattern matching.
static void test_ppm(void)
test point pattern matching
int main(void)
Test of uves_wavecal.