X-shooter Pipeline Reference Manual 3.8.15
test-xsh_data_dispersol.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: 2011-12-02 14:13:14 $
23 * $Revision: 1.8 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
37/*--------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------
41 Includes
42 ---------------------------------------------------------------------------*/
43
44
45#include <xsh_data_order.h>
46#include <xsh_data_dispersol.h>
47#include <xsh_data_pre.h>
48#include <xsh_error.h>
49#include <xsh_msg.h>
50#include <xsh_data_instrument.h>
51#include <xsh_dfs.h>
52#include <xsh_pfits.h>
53#include <tests.h>
54#include <xsh_utils_table.h>
55#include <cpl.h>
56#include <math.h>
57
58/*---------------------------------------------------------------------------
59 Defines
60 ---------------------------------------------------------------------------*/
61#define MODULE_ID "XSH_DATA_DISPERSOL"
62
63#define SYNTAX "Test the dispersion file by producing WAVEMAP and SLITMAP\n"\
64 "usage : ./the_xsh_data_dispersol DISPERSOL_TAB ORDER_TAB PRE\n"\
65 "DISPERSOL_TAB => the dispersol table\n"\
66 "ORDER_TAB => the order table\n"\
67 "PRE => the pre image\n"
68
69/*--------------------------------------------------------------------------
70 Implementation
71 --------------------------------------------------------------------------*/
72
73/*--------------------------------------------------------------------------*/
80/*--------------------------------------------------------------------------*/
81int main( int argc, char** argv)
82{
83 int ret = 0;
84 xsh_instrument * instrument = NULL ;
85 XSH_INSTRCONFIG* iconfig = NULL;
86
87 const char* order_tab_name = NULL;
88 const char* dispersol_tab_name = NULL;
89 const char* pre_name = NULL;
90 cpl_frame *order_tab_frame = NULL;
91 cpl_frame *dispersol_tab_frame = NULL;
92 cpl_frame *pre_frame = NULL;
93 cpl_table* table = NULL;
94 cpl_frame *wavemap_frame = NULL;
95 cpl_frame *slitmap_frame = NULL;
96 int nbcol;
97
98 /* Initialize libraries */
100 cpl_msg_set_level( CPL_MSG_DEBUG);
102
103 /* Analyse parameters */
104 if ( argc > 3) {
105 dispersol_tab_name = argv[1];
106 order_tab_name = argv[2];
107 pre_name = argv[3];
108 }
109 else{
110 printf(SYNTAX);
111 TEST_END();
112 return 0;
113 }
114 xsh_msg("Dispersol tab file %s", dispersol_tab_name);
115 xsh_msg("Order tab file %s", order_tab_name);
116 xsh_msg("Pre file %s", pre_name);
117
118
119 /* Create frames */
122
123 XSH_ASSURE_NOT_NULL( pre_name);
124 pre_frame = cpl_frame_new();
125 cpl_frame_set_filename( pre_frame, pre_name) ;
126 cpl_frame_set_level( pre_frame, CPL_FRAME_LEVEL_TEMPORARY);
127 cpl_frame_set_group( pre_frame, CPL_FRAME_GROUP_RAW);
128 cpl_frame_set_tag( pre_frame, "BIAS_UVB");
129
130 XSH_ASSURE_NOT_NULL( order_tab_name);
131 order_tab_frame = cpl_frame_new();
132 cpl_frame_set_filename( order_tab_frame, order_tab_name) ;
133 cpl_frame_set_level( order_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
134 cpl_frame_set_group( order_tab_frame, CPL_FRAME_GROUP_RAW );
135
136 XSH_TABLE_LOAD( table, order_tab_name);
137 check( nbcol = cpl_table_get_nrow(table));
138
140
142 iconfig->orders = nbcol;
143
144 XSH_ASSURE_NOT_NULL( dispersol_tab_name);
145 dispersol_tab_frame = cpl_frame_new();
146 cpl_frame_set_filename( dispersol_tab_frame, dispersol_tab_name) ;
147 cpl_frame_set_level( dispersol_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
148 cpl_frame_set_group( dispersol_tab_frame, CPL_FRAME_GROUP_RAW);
149
150 xsh_msg("Create wavemap and slitmap");
151 check( xsh_create_map( dispersol_tab_frame, order_tab_frame,
152 pre_frame, instrument,
153 &wavemap_frame, &slitmap_frame,"test"));
154 cleanup:
155 if (cpl_error_get_code() != CPL_ERROR_NONE) {
156 xsh_error_dump(CPL_MSG_ERROR);
157 ret = 1;
158 }
159 XSH_TABLE_FREE( table);
161 xsh_free_frame( &pre_frame);
162 xsh_free_frame( &order_tab_frame);
163 xsh_free_frame( &dispersol_tab_frame);
164 xsh_free_frame( &wavemap_frame);
165 xsh_free_frame( &slitmap_frame);
166 TEST_END();
167 return ret ;
168}
169
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
#define MODULE_ID
#define SYNTAX
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
XSH_INSTRCONFIG * xsh_instrument_get_config(xsh_instrument *i)
Get the instrument default set of keywords.
void xsh_instrument_free(xsh_instrument **instrument)
free an 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
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TEST_END()
Definition: tests.h:111
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
void xsh_create_map(cpl_frame *dispsol_frame, cpl_frame *ordertab_frame, cpl_frame *pre_frame, xsh_instrument *instrument, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const char *rec_prefix)
@ XSH_ARM_UVB
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138
#define XSH_TABLE_LOAD(TABLE, NAME)
#define XSH_TABLE_FREE(TABLE)