X-shooter Pipeline Reference Manual 3.8.15
test-xsh_compute_absorp.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: rhaigron $
22 * $Date: 2011-04-08 13:26:00 $
23 * $Revision: 1.3 $
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_error.h>
46#include <xsh_msg.h>
47#include <xsh_drl.h>
48#include <cpl.h>
49#include <math.h>
50
51#include <string.h>
52#include <getopt.h>
53
54/*--------------------------------------------------------------------------
55 Defines
56 --------------------------------------------------------------------------*/
57
58#define MODULE_ID "XSH_COMPUTE_ABSORP"
59
60enum {
62} ;
63
64static struct option long_options[] = {
65 {"filter-hsize", required_argument, 0, FILTER_HSIZE_OPT},
66 {"threshold", required_argument, 0, THRESH_OPT},
67 {"help", 0, 0, HELP_OPT},
68 {0, 0, 0, 0}
69};
70
71static void Help( void )
72{
73 puts( "Unitary test of xsh_compute_absorp");
74 puts( "Usage: test_xsh_compute_absorp [options] S1D TELLLIST");
75
76 puts( "Options" ) ;
77 puts( " --help : What you see" ) ;
78 puts( " --filter-hsize= : Half size of filter");
79 puts( " --threshold= : Threshold");
80 puts( "\nInput Files" ) ;
81 puts( "S1D : 1D spectrum file");
82 puts( "TELLLIST : tell line list");
83 TEST_END();
84}
85
86
87static void HandleOptions( int argc, char **argv,
88 int *filter_hsize, double *threshold)
89{
90 int opt ;
91 int option_index = 0;
92
93 while (( opt = getopt_long (argc, argv,
94 "filter-hsize",
95 long_options, &option_index)) != EOF ){
96
97 switch ( opt ) {
99 *filter_hsize = atoi( optarg);
100 break;
101 case THRESH_OPT:
102 *threshold = atof( optarg);
103 break;
104 default:
105 Help(); exit(-1);
106 }
107 }
108 return;
109}
110
111
112int main( int argc, char **argv)
113{
114 /* Declarations */
115 int ret = 0 ;
116 int filter_hsize = 5;
117 double threshold = 0.0;
118 const char *s1d_name = NULL;
119 cpl_frame *s1d_frame = NULL;
120 const char *tell_name = NULL;
121 cpl_frame *tell_frame = NULL;
122 xsh_instrument *instr = NULL;
123
124 /* Initialize libraries */
126
127 cpl_msg_set_level(CPL_MSG_DEBUG);
129
130 /* Analyse parameters */
131 HandleOptions( argc, argv, &filter_hsize, &threshold);
132
133 if ( (argc - optind) > 1 ) {
134 s1d_name = argv[optind];
135 tell_name = argv[optind+1];
136 }
137 else {
138 Help();
139 exit( 0);
140 }
141
142 xsh_msg("---Input Files");
143 xsh_msg("S1D File : %s ", s1d_name);
144 xsh_msg("Telllist File : %s ", tell_name);
145 xsh_msg("---Options");
146 xsh_msg("Filter hsize : %d ", filter_hsize);
147 xsh_msg("Threshold : %f ", threshold);
148
149 instr = xsh_instrument_new();
151 TESTS_XSH_FRAME_CREATE( s1d_frame, "S1D", s1d_name);
152 TESTS_XSH_FRAME_CREATE( tell_frame, "TELL_LINE_LIST", tell_name);
153
154 check( xsh_compute_absorp( s1d_frame, tell_frame, filter_hsize, threshold, instr));
155
156 cleanup:
157 if (cpl_error_get_code() != CPL_ERROR_NONE) {
158 xsh_error_dump(CPL_MSG_ERROR);
159 ret=1;
160 }
161 xsh_instrument_free( &instr);
162 xsh_free_frame( &s1d_frame);
163 xsh_free_frame( &tell_frame);
164 TEST_END();
165 return ret ;
166}
167
int main()
Unit test of xsh_bspline_interpol.
static void HandleOptions(int argc, char **argv, int *filter_hsize, double *threshold)
#define MODULE_ID
static struct option long_options[]
@ FILTER_HSIZE_OPT
cpl_frame * xsh_compute_absorp(cpl_frame *s1d_frame, cpl_frame *telllist_frame, int filter_hsize, double threshold, xsh_instrument *instr)
Compute the shift in slit between reference wavelength and others for all the slitlets.
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
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
static void Help(void)
#define TESTS_XSH_FRAME_CREATE(frame, tag, name)
Definition: tests.h:123
#define TEST_END()
Definition: tests.h:111
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
@ XSH_ARM_UVB
int threshold
Definition: xsh_detmon_lg.c:90
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138