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 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030
00036
00039
00040
00041
00042
00043 #include <tests.h>
00044
00045 #include <xsh_data_pre.h>
00046 #include <xsh_error.h>
00047 #include <xsh_msg.h>
00048 #include <xsh_data_instrument.h>
00049 #include <xsh_data_resid_tab.h>
00050 #include <xsh_drl.h>
00051 #include <xsh_pfits.h>
00052
00053 #include <xsh_model_io.h>
00054 #include <xsh_model_kernel.h>
00055 #include <cpl.h>
00056 #include <math.h>
00057
00058 #include <getopt.h>
00059
00060
00061
00062
00063
00064 #define MODULE_ID "XSH_MODEL"
00065 #define SYNTAX "Create a the tab from model\n"\
00066 "use : ./test_xsh_model SOF\n"\
00067 "SOF => model config and arclist\n"
00068
00069
00070
00071
00072
00073
00081 int main( int argc, char **argv)
00082 {
00083 int ret=0;
00084 xsh_instrument *instrument = NULL ;
00085 const char *sof_name = NULL;
00086 const char *model_config_name = NULL;
00087 const char *lines_list_name = NULL;
00088 cpl_frame *model_config_frame = NULL;
00089 cpl_frame *lines_list_frame = NULL;
00090 cpl_frame *the_frame = NULL;
00091 cpl_frameset *set = NULL;
00092 cpl_frameset *raws = NULL;
00093 cpl_frameset *calib = NULL;
00094 int i = 0;
00095 FILE* sof_file = NULL;
00096 char sof_line[200];
00097 xsh_xs_3 config_model;
00098
00099
00100 TESTS_INIT(MODULE_ID);
00101 cpl_msg_set_level(CPL_MSG_DEBUG);
00102 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00103
00104
00105 if (argc > 1){
00106 sof_name = argv[1];
00107 }
00108 else{
00109 printf(SYNTAX);
00110 return 0;
00111 }
00112
00113 XSH_ASSURE_NOT_NULL( sof_name);
00114
00115
00116 check( set = cpl_frameset_new());
00117 sof_file = fopen( sof_name, "r");
00118 while ( fgets( sof_line, 200, sof_file)){
00119 char raw_name[200];
00120 char raw_tag[200];
00121 cpl_frame *raw_frame = NULL;
00122 sscanf( sof_line, "%s %s", raw_name, raw_tag);
00123 check( raw_frame = cpl_frame_new());
00124 check( cpl_frame_set_filename( raw_frame, raw_name));
00125 check( cpl_frame_set_tag( raw_frame, raw_tag));
00126 check( cpl_frameset_insert(set, raw_frame));
00127 }
00128 fclose( sof_file);
00129
00130
00131 check( instrument = xsh_dfs_set_groups( set));
00132 XSH_NEW_FRAMESET( raws);
00133 XSH_NEW_FRAMESET( calib);
00134 check( xsh_dfs_split_in_group( set, raws, calib));
00135
00136 check( lines_list_frame = xsh_find_arc_line_list( calib, instrument));
00137 check( model_config_frame = xsh_find_model_config_tab( calib, instrument));
00138
00139 check( lines_list_name = cpl_frame_get_filename( lines_list_frame));
00140 check( model_config_name = cpl_frame_get_filename( model_config_frame));
00141
00142 xsh_msg(" Find model %s\n", model_config_name);
00143 xsh_msg(" Find lines list %s\n", lines_list_name);
00144
00145 check( xsh_model_config_load_best( model_config_frame, &config_model));
00146 the_frame = xsh_model_THE_create( &config_model, instrument,
00147 lines_list_name, 9, 1.4, "THE.fits");
00148 cleanup:
00149 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00150 xsh_error_dump(CPL_MSG_ERROR);
00151 return 1;
00152 }
00153 else return ret ;
00154 }
00155