X-shooter Pipeline Reference Manual 3.8.15
test-xsh_compute_shift_ifu.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.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_data_pre.h>
46#include <xsh_error.h>
47#include <xsh_msg.h>
48#include <xsh_data_instrument.h>
49#include <xsh_data_spectrum.h>
51#include <xsh_drl.h>
52#include <xsh_pfits.h>
53#include <xsh_parameters.h>
54#include <xsh_badpixelmap.h>
55#include <xsh_utils_ifu.h>
56#include <cpl.h>
57#include <math.h>
58
59#include <string.h>
60#include <getopt.h>
61
62/*--------------------------------------------------------------------------
63 Defines
64 --------------------------------------------------------------------------*/
65
66#define MODULE_ID "XSH_COMPUTE_SHIFT_IFU"
67
68enum {
70} ;
71
72static struct option long_options[] = {
73 {"wave-ref", required_argument, 0, WAVEREF_OPT},
74 {"wave-ref-hsize", required_argument, 0, WAVEREF_HSIZE_OPT},
75 {"help", 0, 0, HELP_OPT},
76 {0, 0, 0, 0}
77};
78
79static void Help( void )
80{
81 puts( "Unitary test of xsh_compute_shift_ifu");
82 puts( "Usage: test_xsh_localize_ifu [options] OBJPOS_TAB SHIFTIFU_TAB");
83
84 puts( "Options" ) ;
85 puts( " --help : What you see" ) ;
86 puts( " --wave-ref= : Wavelength reference");
87 puts( " --wave-ref-hsize= : Half size in nm for estimate wavelength reference [2.5]");
88 puts( "\nInput Files" ) ;
89 puts( "OBJPOS_TAB : OBJPOS frame");
90 puts( "SHIFTIFU_TAB : [OPTIONAL] SHIFTIFU_TAB frame");
91 TEST_END();
92}
93
94
95static void HandleOptions( int argc, char **argv,
96 double *waveref, double *waveref_hsize)
97{
98 int opt ;
99 int option_index = 0;
100
101 while (( opt = getopt_long (argc, argv,
102 "wave-ref",
103 long_options, &option_index)) != EOF ){
104
105 switch ( opt ) {
106 case WAVEREF_OPT:
107 *waveref = atof(optarg);
108 break;
110 *waveref_hsize = atof(optarg);
111 break;
112
113
114 default:
115 Help(); exit(-1);
116 }
117 }
118 return;
119}
120
121
122int main( int argc, char **argv)
123{
124 /* Declarations */
125 int ret = 0 ;
126 double waveref = 700;
127 double waveref_hsize = 2.5;
128 const char *objpos_name = NULL;
129 const char *shiftifu_name = NULL;
130 cpl_frame *objpos_frame = NULL;
131 cpl_frame *shiftifu_frame = NULL;
132 cpl_frame *result = NULL;
133
134 /* Initialize libraries */
136
137 cpl_msg_set_level(CPL_MSG_DEBUG);
139
140 /* Analyse parameters */
141 HandleOptions( argc, argv, &waveref, &waveref_hsize);
142
143 if ( (argc - optind) > 0 ) {
144 objpos_name = argv[optind];
145 if ( (argc - optind) > 1 ) {
146 shiftifu_name = argv[optind+1];
147 }
148 }
149 else {
150 Help();
151 exit( 0);
152 }
153
154 xsh_msg("---Input Files");
155 xsh_msg("Objpos : %s ", objpos_name);
156 xsh_msg("Shiftifu: %s ", shiftifu_name);
157 xsh_msg("---Options");
158 xsh_msg("Waveref : %f ", waveref);
159 xsh_msg("Waveref_hsize : %f ", waveref_hsize);
160
161 /* Create frames */
162 TESTS_XSH_FRAME_CREATE( objpos_frame, "OBJPOS_arm", objpos_name);
163 if ( shiftifu_name != NULL){
164 TESTS_XSH_FRAME_CREATE( shiftifu_frame, "SHIFTIFU_arm", shiftifu_name);
165 }
166
167 check( result = xsh_compute_shift_ifu_slitlet( waveref, objpos_frame,
168 shiftifu_frame, waveref_hsize, "shift.fits"));
169
170 cleanup:
171 if (cpl_error_get_code() != CPL_ERROR_NONE) {
172 xsh_error_dump(CPL_MSG_ERROR);
173 ret=1;
174 }
175 xsh_free_frame( &result);
176 xsh_free_frame( &objpos_frame);
177 xsh_free_frame( &shiftifu_frame);
178 TEST_END();
179 return ret ;
180}
181
int main()
Unit test of xsh_bspline_interpol.
static void Help(void)
#define MODULE_ID
static struct option long_options[]
static void HandleOptions(int argc, char **argv, double *waveref, double *waveref_hsize)
cpl_frame * xsh_compute_shift_ifu_slitlet(double lambda_ref, cpl_frame *objpos_frame, cpl_frame *shiftifu_frame, double lambdaref_hsize, const char *resname)
Compute the shift in slit between reference wavelength and others.
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#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 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_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138