62#define MODULE_ID "XSH_DATA_WAVEMAP"
64#define SYNTAX "Test the wavemap (work only for vis for now)\n"\
65 "use : ./test_xsh_data_wavemap [OPTIONS] ORDER_TAB WAVESOL WAVEMAP"\
67 "ORDER_TAB => the order table\n"\
68 "WAVESOL => the wavesolution table\n"\
69 "WAVEMAP => the wavemap frame\n"\
70 "SPECTRALFORMAT => the spectral format table\n"
83int main(
int argc,
char **argv)
89 char* order_tab_name = NULL;
90 char* wavesol_name = NULL;
91 char* wavemap_name = NULL;
92 char* spectralformat_name = NULL;
94 cpl_frame *order_tab_frame = NULL;
95 cpl_frame *wavesol_frame = NULL;
96 cpl_frame *wavemap_frame = NULL;
97 cpl_frame *spectralformat_frame = NULL;
102 cpl_msg_set_level( CPL_MSG_DEBUG);
106 if ( (argc ) >= 4 ) {
107 order_tab_name = argv[1];
108 wavesol_name = argv[2];
109 wavemap_name = argv[3];
110 spectralformat_name = argv[4];
116 xsh_msg(
" order tab frame name %s",order_tab_name);
117 xsh_msg(
" wave sol frame name %s", wavesol_name);
118 xsh_msg(
" wave map frame name %s",wavemap_name);
119 xsh_msg(
" spectral format frame name %s",spectralformat_name);
126 spectralformat_name);
139 cpl_image* wavemap = NULL;
140 float * wavemap_data = NULL;
144 int iorder=0, nblines=0;
145 cpl_table *table = NULL;
147 check( wavemap = cpl_image_load( cpl_frame_get_filename( wavemap_frame),
148 CPL_TYPE_FLOAT, 0, 0));
149 check (
nx = cpl_image_get_size_x( wavemap));
150 check (
ny = cpl_image_get_size_y( wavemap));
151 check( wavemap_data = cpl_image_get_data_float( wavemap));
154 check( table = cpl_table_new( 6));
161 check(cpl_table_set_size( table, order_list->
size*
ny));
163 for( iorder= 0; iorder < order_list->
size; iorder++) {
164 int abs_order, start_y, end_y,
y;
170 for(
y=start_y;
y < end_y;
y++){
171 double x, x_center, y_center;
173 double lambda_wavemap;
178 lambda_wavemap = wavemap_data[int_x+
y*
nx];
183 check(cpl_table_set_int(table,
"absorder", nblines, abs_order));
184 check(cpl_table_set_double(table,
"wavelength", nblines, lambda_wavemap));
185 check(cpl_table_set_double(table,
"wavemap_x", nblines, int_x));
186 check(cpl_table_set_double(table,
"wavemap_y", nblines,
y));
187 check(cpl_table_set_double(table,
"wavesol_x", nblines, x_center));
188 check(cpl_table_set_double(table,
"wavesol_y", nblines, y_center));
192 check( cpl_table_save(table, NULL, NULL,
"result.fits", CPL_IO_DEFAULT));
195 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
xsh_order_list * xsh_order_list_load(cpl_frame *frame, xsh_instrument *instr)
load an order list from a frame
int xsh_order_list_get_starty(xsh_order_list *list, int i)
get position on Y axis of first pixel detected on order
int xsh_order_list_get_endy(xsh_order_list *list, int i)
get position on Y axis of last pixel detected on order
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)
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_set_lamp(xsh_instrument *i, XSH_LAMP lamp)
Set a lamp on instrument structure.
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
#define TESTS_XSH_FRAME_CREATE(frame, tag, name)
#define TESTS_INIT(DRL_ID)
#define XSH_TABLE_NEW_COL(TABLE, NAME, UNIT, TYPE)