X-shooter Pipeline Reference Manual 3.8.15
test-xsh_slitmap.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: 2010-09-25 13:45:38 $
23 * $Revision: 1.6 $
24 *
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
36/*--------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------
40 Includes
41 ---------------------------------------------------------------------------*/
42
43
44#include <xsh_data_order.h>
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 <xsh_utils_table.h>
52#include <cpl.h>
53#include <math.h>
54#include <getopt.h>
55#include <xsh_drl.h>
56
57/*---------------------------------------------------------------------------
58 Defines
59 ---------------------------------------------------------------------------*/
60#define MODULE_ID "XSH_SLITMAP"
61
62enum {
64} ;
65
66static struct option LongOptions[] = {
67 {"debug", required_argument, 0, DEBUG_OPT},
68 {"help", 0, 0, HELP_OPT},
69 {NULL, 0, 0, 0}
70} ;
71
72
73static void Help( void )
74{
75 puts ("Computes the slilet sizes with Order Table and SLIT MAP");
76 puts( "Usage : ./test_xsh_slitmap <sof>");
77
78 puts( "Options" ) ;
79 puts( " --debug=<n> : Level of debug LOW | MEDIUM | HIGH [MEDIUM]" );
80 puts( " --help : What you see" ) ;
81
82 puts( "The input files argument MUST be in this order:" ) ;
83 puts( " 1. SOF [IFU_MAP|SLIT_MAP]");
84
85 TEST_END();
86 exit(0);
87}
88
89static void HandleOptions( int argc, char ** argv)
90{
91 int opt ;
92 int option_index = 0;
93
94 while( (opt = getopt_long( argc, argv, "debug:help",
95 LongOptions, &option_index )) != EOF )
96 switch( opt ) {
97 case DEBUG_OPT:
98 if ( strcmp( optarg, "LOW")==0){
100 }
101 else if ( strcmp( optarg, "HIGH")==0){
103 }
104 break;
105 case HELP_OPT:
106 Help();
107 break;
108 default:
109 break;
110 }
111}
112
113/*--------------------------------------------------------------------------*/
121/*--------------------------------------------------------------------------*/
122int main(int argc, char** argv)
123{
124 int ret = 0;
125 xsh_instrument *instrument = NULL ;
126
127 const char *sof_name = NULL;
128 cpl_frameset *set = NULL;
129 cpl_frame * slitmap_frame = NULL ;
130 double sd, su, sld, slu;
131
132 /* Initialize libraries */
134 cpl_msg_set_level( CPL_MSG_DEBUG);
136
137 HandleOptions( argc, argv);
138
139 if ( (argc-optind) >= 1 ) {
140 sof_name = argv[optind];
141 }
142 else {
143 Help();
144 exit( 0);
145 }
146
147 /* Create frameset from sof */
148 check( set = sof_to_frameset( sof_name));
149
150 /* Validate frame set */
152
153 check( slitmap_frame = xsh_find_slitmap( set, instrument));
154 xsh_msg("SLITMAP : %s",
155 cpl_frame_get_filename( slitmap_frame));
156
157 check( xsh_get_slit_edges( slitmap_frame, &sd, &su, &sld, &slu, instrument));
158
159 cleanup:
160 if (cpl_error_get_code() != CPL_ERROR_NONE) {
161 xsh_error_dump(CPL_MSG_ERROR);
162 ret = 1;
163 }
164 xsh_free_frameset( &set);
166 TEST_END();
167 return ret ;
168}
169
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
static void HandleOptions(int argc, char **argv)
static void Help(void)
#define MODULE_ID
static struct option LongOptions[]
@ HELP_OPT
@ BINX_OPT
@ BINY_OPT
@ DEBUG_OPT
cpl_frameset * sof_to_frameset(const char *sof_name)
Definition: tests.c:576
#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_get_slit_edges(cpl_frame *slitmap_frame, double *sdown, double *sup, double *sldown, double *slup, xsh_instrument *instrument)
Trace slit edges in a master flat.
Definition: xsh_rectify.c:671
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_slitmap(cpl_frameset *frames, xsh_instrument *instr)
Find a slit map.
Definition: xsh_dfs.c:3673
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
@ XSH_DEBUG_LEVEL_HIGH
Definition: xsh_utils.h:138
@ XSH_DEBUG_LEVEL_LOW
Definition: xsh_utils.h:137
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138