X-shooter Pipeline Reference Manual 3.8.15
test-xsh_data_spectralformat.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.7 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
36/*--------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------
40 Includes
41 ---------------------------------------------------------------------------*/
42
43
45#include <xsh_error.h>
46#include <xsh_msg.h>
47#include <xsh_data_instrument.h>
48#include <xsh_dfs.h>
49#include <xsh_pfits.h>
50#include <tests.h>
51#include <cpl.h>
52#include <math.h>
53#include <getopt.h>
54/*---------------------------------------------------------------------------
55 Defines
56 ---------------------------------------------------------------------------*/
57#define MODULE_ID "XSH_DATA_SPECTRALFORMAT"
58
59#define SYNTAX \
60 "Test the xsh_data_spectralformat function \n"\
61 " analyse SPECTRAL_FORMAT tab frames\n"\
62 "use : ./test_xsh_data_spectralformat SOF\n"\
63 " SOF => [SPECTRAL_FORMAT, ORDER_TAB_EDGES, WAVE_TAB_2D|MODEL ]\n"
64
65/*---------------------------------------------------------------------------
66 Functions prototypes
67 ---------------------------------------------------------------------------*/
68
69/*--------------------------------------------------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78int main(int argc, char** argv)
79{
81 const char *sof_name = NULL;
82 cpl_frame *spectralformat_frame = NULL;
83 cpl_frame *orderlist_frame = NULL;
84 cpl_frame *wavesol_frame = NULL;
85 cpl_frame *model_frame = NULL;
86 cpl_frameset *set = NULL;
87 int ret=0;
88
89 /* Initialize libraries */
91 cpl_msg_set_level(CPL_MSG_DEBUG);
93
94 /* Analyse parameters */
95 if (argc > 1){
96 sof_name = argv[1];
97 }
98 else{
99 printf(SYNTAX);
100 TEST_END();
101 return 0;
102 }
103
104 /* Create frameset from sof */
105 check( set = sof_to_frameset( sof_name));
106
107 /* Validate frame set */
109
110 check( spectralformat_frame = xsh_find_spectral_format( set, instrument));
111 check( orderlist_frame = xsh_find_order_tab_edges( set, instrument));
112 wavesol_frame = xsh_find_wave_tab_2d( set, instrument);
113
114 /* USE load function */
115 xsh_msg("SPECTRALFORMAT : %s",
116 cpl_frame_get_filename( spectralformat_frame));
117 xsh_msg("ORDERLIST : %s",
118 cpl_frame_get_filename( orderlist_frame));
119 if (wavesol_frame != NULL){
120 xsh_msg("WAVESOL : %s",
121 cpl_frame_get_filename( wavesol_frame));
122 }
123 else{
124 check( model_frame =
126 xsh_msg("MODEL : %s",
127 cpl_frame_get_filename( model_frame));
128 }
129 check( xsh_data_check_spectralformat( spectralformat_frame,
130 orderlist_frame, wavesol_frame, model_frame, instrument));
131
132 cleanup:
133 xsh_free_frameset( &set);
135
136 if (cpl_error_get_code() != CPL_ERROR_NONE) {
137 xsh_error_dump(CPL_MSG_ERROR);
138 ret = 1;
139 }
140 TEST_END();
141 return ret;
142}
143
int main()
Unit test of xsh_bspline_interpol.
#define MODULE_ID
#define SYNTAX
static xsh_instrument * instrument
cpl_frameset * sof_to_frameset(const char *sof_name)
Definition: tests.c:576
void xsh_data_check_spectralformat(cpl_frame *spectralformat_frame, cpl_frame *orderlist_frame, cpl_frame *wavesol_frame, cpl_frame *model_config_frame, xsh_instrument *instr)
Check the borders of wavelength foreach orders in spectral format.
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
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
cpl_frame * xsh_find_spectral_format(cpl_frameset *frames, xsh_instrument *instr)
Find spectral format frame.
Definition: xsh_dfs.c:4318
cpl_frame * xsh_find_order_tab_edges(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab EDGES.
Definition: xsh_dfs.c:3595
cpl_frame * xsh_find_wave_tab_2d(cpl_frameset *frames, xsh_instrument *instr)
Find a wave tab 2D.
Definition: xsh_dfs.c:3650
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.
Definition: xsh_dfs.c:1046
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
Definition: xsh_dfs.c:3347
#define XSH_MOD_CFG_TAB
Definition: xsh_dfs.h:1251
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138