62#define MODULE_ID "XSH_DATA_WAVE_TAB_2D_SAMPLE"
64#define SYNTAX "Test the wave tab 2d\n"\
65 "usage : ./the_xsh_data_wave_tab_2d [OPTIONS] WAVE_TAB_2D ARC_LIST SPECTRAL_FORMAT\n"\
66 "WAVE_TAB_2D => The wave tab 2d\n"\
67 "ARC_LIST => An arclist\n"\
68 "SPECTRAL_FORMAT => The spectral format\n"\
70 " --slit-step=<nn> : Step in slit. Default 0.2 \n"
96 while( (opt = getopt_long( argc, argv,
Options,
117int main(
int argc,
char** argv)
125 char* wave_tab_2d_name = NULL;
126 cpl_frame *wave_tab_2d_frame = NULL;
127 char* spectralformat_name = NULL;
128 cpl_frame *spectralformat_frame = NULL;
129 char* arclist_name = NULL;
130 cpl_frame *arclist_frame = NULL;
133 FILE* wave_tab_2d_file = NULL;
134 FILE* wave_tab_2d_dat_file = NULL;
140 cpl_msg_set_level(CPL_MSG_DEBUG);
146 if ( (argc-optind) == 3) {
147 wave_tab_2d_name = argv[optind++];
148 arclist_name = argv[optind++];
149 spectralformat_name = argv[optind++];
155 xsh_msg(
"Wave tab 2d : %s", wave_tab_2d_name);
156 xsh_msg(
"Arclist : %s", arclist_name);
157 xsh_msg(
"Spectral format : %s", spectralformat_name);
162 wave_tab_2d_frame = cpl_frame_new();
163 cpl_frame_set_filename( wave_tab_2d_frame, wave_tab_2d_name) ;
164 cpl_frame_set_level( wave_tab_2d_frame, CPL_FRAME_LEVEL_TEMPORARY);
165 cpl_frame_set_group( wave_tab_2d_frame, CPL_FRAME_GROUP_RAW);
168 arclist_frame = cpl_frame_new();
169 cpl_frame_set_filename( arclist_frame, arclist_name) ;
170 cpl_frame_set_level( arclist_frame, CPL_FRAME_LEVEL_TEMPORARY);
171 cpl_frame_set_group( arclist_frame, CPL_FRAME_GROUP_RAW);
174 spectralformat_frame = cpl_frame_new();
175 cpl_frame_set_filename( spectralformat_frame, spectralformat_name) ;
176 cpl_frame_set_level( spectralformat_frame, CPL_FRAME_LEVEL_TEMPORARY);
177 cpl_frame_set_group( spectralformat_frame, CPL_FRAME_GROUP_RAW);
190 wave_tab_2d_file = fopen(
"WAVE_TAB_2D_sample.reg",
"w");
191 wave_tab_2d_dat_file = fopen(
"WAVE_TAB_2D_sample.dat",
"w");
193 fprintf( wave_tab_2d_file,
"# Region file format: DS9 version 4.0\n"\
194 "global color=red font=\"helvetica 10 normal\""\
195 "select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 "\
197 fprintf( wave_tab_2d_dat_file,
"# x y lambda slit\n");
201 for( i=0; i< arclist->
size; i++){
204 cpl_vector* orders = NULL;
210 check( nb_orders = cpl_vector_get_size( orders));
215 for(j=0; j < nb_orders; j++){
217 absorder= cpl_vector_get( orders, j);
218 xsh_msg(
"order %f lambda %f", absorder, lambda);
221 fprintf( wave_tab_2d_file,
"point(%f,%f) #point=cross color=red font="\
222 "\"helvetica 10 normal\" text={ %.3f}\n",
x,
y, lambda);
223 fprintf( wave_tab_2d_dat_file,
"%f %f %f %f\n",
x,
y , lambda, 0.0);
238 fprintf( wave_tab_2d_file,
"line(%f,%f,%f,%f) #color=green font="\
239 "\"helvetica 10 normal\"\n", x1, y1, x2, y2);
240 fprintf( wave_tab_2d_dat_file,
"%f %f %f %f\n",
x,
y , lambda, k);
246 if (cpl_error_get_code() != CPL_ERROR_NONE) {
250 if ( NULL != wave_tab_2d_file) {
251 fclose( wave_tab_2d_file);
253 if ( NULL != wave_tab_2d_dat_file) {
254 fclose( wave_tab_2d_dat_file);
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
static const char * Options
static struct option LongOptions[]
float xsh_arclist_get_wavelength(xsh_arclist *list, int idx)
get wavelength of a line in the arcline list
xsh_arclist * xsh_arclist_load(cpl_frame *frame)
load an arcline list frame in arclist structure
xsh_wavesol * xsh_wavesol_load(cpl_frame *frame, xsh_instrument *instrument)
load a wavelength solution
double xsh_wavesol_eval_poly(xsh_wavesol *sol, double lambda, double order, double slit)
eval the polynomial solution in Y
double xsh_wavesol_eval_polx(xsh_wavesol *sol, double lambda, double order, double slit)
eval the polynomial solution in X
#define xsh_error_dump(level)
#define XSH_ASSURE_NOT_NULL(pointer)
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
int xsh_debug_level_set(int level)
set debug level
static void HandleOptions(int argc, char **argv)
#define TESTS_INIT(DRL_ID)