X-shooter Pipeline Reference Manual 3.8.15
tests.h
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 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: 2011-09-14 11:37:12 $
23 * $Revision: 1.8 $
24 * $Name: not supported by cvs2svn $
25 * $Log: not supported by cvs2svn $
26 * Revision 1.7.6.1 2011/04/15 13:31:26 rhaigron
27 * add center_cube function
28 *
29 * Revision 1.7 2009/05/22 17:35:50 rhaigron
30 * new version os slit nod work only in fast mode
31 *
32 * Revision 1.6 2009/04/22 12:55:07 rhaigron
33 * correct sompe memory leaks
34 *
35 * Revision 1.5 2009/04/17 14:13:43 rhaigron
36 * new version with some cosmics remove
37 *
38 * Revision 1.4 2009/04/16 08:55:19 rhaigron
39 * add check for spectral format
40 *
41 * Revision 1.3 2008/07/11 13:26:45 lgugliel
42 * Added functions to create fake rectified frames.
43 *
44 * Revision 1.2 2008/06/13 15:18:16 rhaigron
45 * *** empty log message ***
46 *
47 * Revision 1.1 2007/11/13 12:08:16 amodigli
48 * added to remository (from xshp/tests)
49 *
50 * Revision 1.12 2007/10/04 13:40:27 rhaigron
51 * skip nan lines in the_map
52 *
53 * Revision 1.11 2007/10/04 09:47:04 rhaigron
54 * cpl_init take an argument now
55 *
56 * Revision 1.10 2007/09/25 08:10:38 rhaigron
57 * *** empty log message ***
58 *
59 * Revision 1.9 2007/07/03 13:47:38 rhaigron
60 * introduce dbg level for log
61 *
62 * Revision 1.8 2007/06/29 11:54:28 rhaigron
63 * *** empty log message ***
64 *
65 * Revision 1.7 2007/04/03 09:12:00 lgugliel
66 * Added test-xsh_detect_continuum unitary test
67 * Added functions to create order tables and images with orders (in test.c)
68 *
69 * Revision 1.6 2006/11/20 10:07:57 rhaigron
70 * detect order edge chnages ny by ny
71 *
72 * Revision 1.5 2006/11/17 19:12:18 rhaigron
73 * *** empty log message ***
74 *
75 * Revision 1.4 2006/10/26 10:50:01 lgugliel
76 * Added creation and/or setting of fits header according to instrument
77 * configuration:
78 * mkHeader: create and fill a new header
79 * setHeader: just fill an existing header
80 *
81 * Revision 1.3 2006/10/19 14:42:22 rhaigron
82 * *** empty log message ***
83 *
84 * Revision 1.2 2006/10/19 09:08:43 rhaigron
85 * some cosmetical changes need by staticcheck
86 *
87 * Revision 1.1 2006/03/03 13:15:16 jmlarsen
88 * Imported sources
89 *
90 * Revision 1.2 2005/12/19 16:17:56 jmlarsen
91 * Replaced bool -> int
92 *
93 */
94#ifndef TESTS_H
95#define TESTS_H
96
97#include <cpl.h>
98#include <xsh_drl.h>
99#include <stdbool.h>
100#include <xsh_data_order.h>
101#include <config.h>
102#include <stdlib.h>
103#include <unistd.h>
104
105#define TESTS_INIT(DRL_ID) do { \
106 cpl_init(CPL_INIT_DEFAULT); \
107 xsh_init(); \
108 cpl_msg_set_domain("Test-" DRL_ID); \
109} while(false)
110
111#define TEST_END()\
112 xsh_free_temporary_files(); \
113 cpl_end()
114
115#define TESTS_XSH_INSTRUMENT_CREATE(instr, mode, arm, lamp, recipe)\
116 instr = xsh_instrument_new() ;\
117 xsh_instrument_set_mode( instr, mode) ;\
118 xsh_instrument_set_arm( instr, arm) ;\
119 xsh_instrument_set_lamp( instr, lamp) ;\
120 xsh_instrument_set_recipe_id( instr, recipe) ;\
121 xsh_msg( " recipe_id: %s", instr->recipe_id )
122
123#define TESTS_XSH_FRAME_CREATE( frame, tag, name)\
124 frame = cpl_frame_new();\
125 cpl_frame_set_filename( frame, name);\
126 cpl_frame_set_level( frame, CPL_FRAME_LEVEL_TEMPORARY);\
127 cpl_frame_set_group( frame, CPL_FRAME_GROUP_RAW);\
128 cpl_frame_set_tag( frame, tag)
129
130
131#define TESTS_DATA(file) XSH_TEST_DATA_PATH "/" file
132
133#define TESTS_INIT_WORKSPACE(DRL_ID) \
134 /* Create an new workspace and change to that directory. */ \
135 (void) system("test -d workspace_Test-"DRL_ID \
136 " || mkdir workspace_Test-"DRL_ID); \
137 (void) chdir("workspace_Test-"DRL_ID);
138
139#define TESTS_CLEAN_WORKSPACE(DRL_ID) \
140 /* Delete the test sub-directory if it exists and no errors \
141 * were found when running the unit tests. */ \
142 (void) chdir(".."); \
143 if (cpl_error_get_code() == CPL_ERROR_NONE) { \
144 (void) system("test -d workspace_Test-"DRL_ID \
145 " && rm -r -f workspace_Test-"DRL_ID); \
146 } \
147
148
149/* Define accuracies here */
150#define XSH_DRL_FUNC_RMS 0.01
151#define XSH_FLOAT_PRECISION 0.000003
152
153void
154tests_set_defaults(cpl_parameterlist *parlist);
155
156cpl_image* xsh_test_create_bias_image(const char* name, int nx, int ny,
158
159cpl_propertylist * mkHeader( XSH_INSTRCONFIG *iconfig,
160 int nx, int ny, double exptime ) ;
161void setHeader( cpl_propertylist *header,
162 XSH_INSTRCONFIG *iconfig,
163 int nx, int ny, double exptime ) ;
164cpl_frame* xsh_test_create_frame( const char* name,int nx, int ny,
165 const char* tag, cpl_frame_group group, xsh_instrument* instrument);
166void add_to_order_list( xsh_order_list * list, int order,
167 int absorder,
168 cpl_polynomial *poly, int xdelta,
169 int starty, int endy ) ;
171
172cpl_image * create_order_image( xsh_order_list* list,
173 int nx, int ny ) ;
174
175cpl_frame * create_rectify_nod_list( int dual, const char * fname,
176 xsh_instrument * instr ) ;
177
178cpl_frameset* sof_to_frameset( const char* sof_name);
179
180xsh_instrument * create_instrument( const char *filename);
181
182#endif /* XSH_TESTS_H */
static double exptime
static int starty
static int endy
static int norder
static xsh_instrument * instrument
xsh_order_list * create_order_list(int norder, xsh_instrument *instrument)
Definition: tests.c:410
void add_to_order_list(xsh_order_list *list, int order, int absorder, cpl_polynomial *poly, int xdelta, int starty, int endy)
Definition: tests.c:432
cpl_image * xsh_test_create_bias_image(const char *name, int nx, int ny, xsh_instrument *instrument)
Definition: tests.c:89
cpl_image * create_order_image(xsh_order_list *list, int nx, int ny)
Definition: tests.c:361
cpl_frameset * sof_to_frameset(const char *sof_name)
Definition: tests.c:576
cpl_propertylist * mkHeader(XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
Definition: tests.c:221
xsh_instrument * create_instrument(const char *filename)
Definition: tests.c:622
void setHeader(cpl_propertylist *header, XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
Definition: tests.c:288
void tests_set_defaults(cpl_parameterlist *parlist)
Set unset parameters to default value.
Definition: tests.c:173
cpl_frame * xsh_test_create_frame(const char *name, int nx, int ny, const char *tag, cpl_frame_group group, xsh_instrument *instrument)
Definition: tests.c:119
cpl_frame * create_rectify_nod_list(int dual, const char *fname, xsh_instrument *instr)
Definition: tests.c:481
int nx
int ny
int order
Definition: xsh_detmon_lg.c:80