X-shooter Pipeline Reference Manual 3.8.15
test-xsh_flat_merge.c
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: 2009-12-30 14:51:26 $
23 * $Revision: 1.5 $
24 */
25
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*-------------------------------------------------------------------------*/
36/*-------------------------------------------------------------------------*/
39/*--------------------------------------------------------------------------
40 Includes
41 --------------------------------------------------------------------------*/
42
43#include <tests.h>
44
45#include <xsh_data_pre.h>
46#include <xsh_error.h>
47#include <xsh_msg.h>
48#include <xsh_data_instrument.h>
49#include <xsh_data_rec.h>
51#include <xsh_drl.h>
52#include <xsh_pfits.h>
53
54#include <xsh_badpixelmap.h>
55
56#include <cpl.h>
57#include <math.h>
58
59#include <getopt.h>
60
61/*--------------------------------------------------------------------------
62 Defines
63 --------------------------------------------------------------------------*/
64
65#define MODULE_ID "XSH_FLAT_MERGE"
66
67#define SYNTAX "Test the flat merge function\n"\
68 "use : ./test_xsh_flat_merge QTH_FRAME QTH_ORDER_TAB D2_FRAME D2_ORDER_TAB"\
69 " SPECTRAL_TAB\n"\
70 "QTH_FRAME => the qth flat frame\n"\
71 "QTH_ORDER_TAB => the qth order table\n"\
72 "D2_FRAME => the d2 flat frame\n"\
73 "D2_ORDER_TAB => the d2 order table\n"\
74
75/*--------------------------------------------------------------------------
76 Implementation
77 --------------------------------------------------------------------------*/
78
86int main( int argc, char **argv)
87{
88 /* Declarations */
89 int ret = 0 ;
91
92 char* qth_name = NULL;
93 cpl_frame* qth_frame = NULL;
94 char* qth_order_tab_name = NULL;
95 cpl_frame* qth_order_tab_frame = NULL;
96 char* d2_name = NULL;
97 char* d2_bkg_name = NULL;
98 char* qth_bkg_name = NULL;
99 cpl_frame* d2_frame = NULL;
100 cpl_frame* d2_bkg_frame = NULL;
101 cpl_frame* qth_bkg_frame = NULL;
102
103 char* d2_order_tab_name = NULL;
104 cpl_frame* d2_order_tab_frame = NULL;
105
106 cpl_frame *qth_d2_flat_frame = NULL;
107 cpl_frame *qth_d2_bkg_frame = NULL;
108 cpl_frame *qth_d2_order_tab_frame = NULL;
109
110 /* Initialize libraries */
112
113 cpl_msg_set_level( CPL_MSG_DEBUG);
115
116
117 /* Analyse parameters */
118 if ( argc > 4 ) {
119 qth_name = argv[1];
120 qth_bkg_name = argv[2];
121 qth_order_tab_name = argv[3];
122 d2_name = argv[4];
123 d2_bkg_name = argv[5];
124 d2_order_tab_name = argv[6];
125 xsh_msg(" %s %s %s %s %s %s",
126 qth_name,qth_bkg_name,qth_order_tab_name,
127 d2_name, d2_bkg_name, d2_order_tab_name);
128 }
129 else{
130 printf(SYNTAX);
131 exit(0);
132 }
133
134 qth_frame = cpl_frame_new();
135 cpl_frame_set_filename( qth_frame, qth_name) ;
136 cpl_frame_set_level( qth_frame, CPL_FRAME_LEVEL_TEMPORARY);
137 cpl_frame_set_group( qth_frame, CPL_FRAME_GROUP_RAW ) ;
138 cpl_frame_set_tag( qth_frame, "MASTER_FLAT_SLIT_UVB_QTH");
139
140
141
142 qth_bkg_frame = cpl_frame_new();
143 cpl_frame_set_filename( qth_bkg_frame, qth_name) ;
144 cpl_frame_set_level( qth_bkg_frame, CPL_FRAME_LEVEL_TEMPORARY);
145 cpl_frame_set_group( qth_bkg_frame, CPL_FRAME_GROUP_RAW ) ;
146 cpl_frame_set_tag( qth_bkg_frame, "BKG_FLAT_SLIT_UVB_QTH");
147
148 qth_order_tab_frame = cpl_frame_new();
149 cpl_frame_set_filename( qth_order_tab_frame, qth_order_tab_name) ;
150 cpl_frame_set_level( qth_order_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
151 cpl_frame_set_group( qth_order_tab_frame, CPL_FRAME_GROUP_RAW ) ;
152
153 d2_frame = cpl_frame_new();
154 cpl_frame_set_filename( d2_frame, d2_name) ;
155 cpl_frame_set_level( d2_frame, CPL_FRAME_LEVEL_TEMPORARY);
156 cpl_frame_set_group( d2_frame, CPL_FRAME_GROUP_RAW ) ;
157 cpl_frame_set_tag( d2_frame, "MASTER_FLAT_SLIT_UVB_D2");
158
159
160 d2_bkg_frame = cpl_frame_new();
161 cpl_frame_set_filename( d2_bkg_frame, qth_name) ;
162 cpl_frame_set_level( d2_bkg_frame, CPL_FRAME_LEVEL_TEMPORARY);
163 cpl_frame_set_group( d2_bkg_frame, CPL_FRAME_GROUP_RAW ) ;
164 cpl_frame_set_tag( d2_bkg_frame, "BKG_FLAT_SLIT_UVB_D2");
165
166
167 d2_order_tab_frame = cpl_frame_new();
168 cpl_frame_set_filename( d2_order_tab_frame, d2_order_tab_name) ;
169 cpl_frame_set_level( d2_order_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
170 cpl_frame_set_group( d2_order_tab_frame, CPL_FRAME_GROUP_RAW ) ;
171
172 /* Create instrument structure and fill */
174
177
180
181 check( xsh_flat_merge_qth_d2( qth_frame,qth_order_tab_frame,
182 d2_frame,d2_order_tab_frame,
183 qth_bkg_frame,d2_bkg_frame,
184 &qth_d2_flat_frame,&qth_d2_bkg_frame,
185 &qth_d2_order_tab_frame, instrument));
186
187 cleanup:
188 if (cpl_error_get_code() != CPL_ERROR_NONE) {
189 xsh_error_dump(CPL_MSG_ERROR);
190 return 1;
191 }
192 else return ret ;
193}
194
int main()
Unit test of xsh_bspline_interpol.
#define MODULE_ID
#define SYNTAX
static xsh_instrument * instrument
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
void xsh_flat_merge_qth_d2(cpl_frame *qth_frame, cpl_frame *qth_order_tab_frame, cpl_frame *d2_frame, cpl_frame *d2_order_tab_frame, cpl_frame *qth_bkg_frame, cpl_frame *d2_bkg_frame, cpl_frame **qth_d2_flat_frame, cpl_frame **qth_d2_bkg_frame, cpl_frame **qth_d2_order_tab_frame, xsh_instrument *instrument)
Merge two master flat fields and order tables according the spectral format.
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_set_lamp(xsh_instrument *i, XSH_LAMP lamp)
Set a lamp on instrument structure.
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
@ XSH_LAMP_QTH_D2
@ XSH_ARM_UVB
@ XSH_MODE_SLIT
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138