00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031
00036
00037
00041
00042
00043
00044
00045 #include <xsh_data_shift_tab.h>
00046 #include <xsh_utils.h>
00047 #include <xsh_utils_table.h>
00048 #include <xsh_error.h>
00049 #include <xsh_msg.h>
00050 #include <xsh_pfits.h>
00051 #include <cpl.h>
00052 #include <xsh_drl.h>
00053 #include <math.h>
00054
00055
00056
00057
00058
00059
00070
00071 cpl_frameset* xsh_ifu_wavetab_create( cpl_frame *wavetab_frame,
00072 cpl_frame *shifttab_frame, xsh_instrument *instr)
00073 {
00074 cpl_frameset *result = NULL;
00075 xsh_shift_tab *shift_tab = NULL;
00076 xsh_wavesol *wavesol_cen = NULL;
00077 xsh_wavesol *wavesol_up = NULL;
00078 xsh_wavesol *wavesol_down = NULL;
00079 char result_name[256];
00080 const char *tag = NULL;
00081 cpl_table *trace = NULL;
00082 cpl_frame *down_frame = NULL;
00083 cpl_frame *cen_frame = NULL;
00084 cpl_frame *up_frame = NULL;
00085
00086 XSH_ASSURE_NOT_NULL( wavetab_frame);
00087 XSH_ASSURE_NOT_NULL( instr);
00088
00089 check( wavesol_down = xsh_wavesol_load( wavetab_frame, instr));
00090 check( wavesol_cen = xsh_wavesol_load( wavetab_frame, instr));
00091 check( wavesol_up = xsh_wavesol_load( wavetab_frame, instr));
00092
00093 if ( shifttab_frame != NULL){
00094 check( shift_tab = xsh_shift_tab_load( shifttab_frame, instr));
00095 check( xsh_wavesol_apply_shift( wavesol_down, 0.0,
00096 shift_tab->shift_y_down));
00097 check( xsh_wavesol_apply_shift( wavesol_cen, 0.0,
00098 shift_tab->shift_y_cen));
00099 check( xsh_wavesol_apply_shift( wavesol_up, 0.0,
00100 shift_tab->shift_y_up));
00101 }
00102 check( trace = cpl_table_new(1));
00103
00104 check( result = cpl_frameset_new());
00105
00106 tag = XSH_GET_TAG_FROM_ARM( XSH_WAVE_TAB_ARC_DOWN_IFU, instr);
00107 sprintf( result_name, "%s.fits", tag);
00108 check( down_frame = xsh_wavesol_save( wavesol_down,
00109 trace, result_name, tag));
00110 check( cpl_frameset_insert( result, down_frame));
00111
00112 tag = XSH_GET_TAG_FROM_ARM( XSH_WAVE_TAB_ARC_CEN_IFU, instr);
00113 sprintf( result_name, "%s.fits", tag);
00114 check( cen_frame = xsh_wavesol_save( wavesol_cen,
00115 trace, result_name, tag));
00116 check( cpl_frameset_insert( result, cen_frame));
00117
00118 tag = XSH_GET_TAG_FROM_ARM( XSH_WAVE_TAB_ARC_UP_IFU, instr);
00119 sprintf( result_name, "%s.fits", tag);
00120 check( up_frame = xsh_wavesol_save( wavesol_up,
00121 trace, result_name, tag));
00122 check( cpl_frameset_insert( result, up_frame));
00123
00124 cleanup:
00125 if ( cpl_error_get_code() != CPL_ERROR_NONE){
00126 xsh_free_frameset( &result);
00127 }
00128 xsh_shift_tab_free( &shift_tab);
00129 xsh_wavesol_free( &wavesol_down);
00130 xsh_wavesol_free( &wavesol_cen);
00131 xsh_wavesol_free( &wavesol_up);
00132 xsh_free_table( &trace);
00133 return result;
00134 }
00135
00136