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_error.h>
00046 #include <xsh_msg.h>
00047 #include <xsh_data_instrument.h>
00048 #include <xsh_drl.h>
00049 #include <xsh_model_io.h>
00050
00051 #include <cpl.h>
00052 #include <math.h>
00053
00054 #include <getopt.h>
00055
00056
00057
00058
00059
00060 #define MODULE_ID "XSH_GUESS"
00061 #define SYNTAX "Test X,Y point generation\n"\
00062 "use : ./the_xsh_guess XSH_MODEL_CFG INPUT_MODEL_TAB (columns 'order', 'wavelength', 'slit')\n"\
00063 "(table with predicted 'x','y' predicted positions)\n"
00064
00065
00066
00067
00068
00069
00077 int main( int argc, char **argv)
00078 {
00079
00080 int ret = 0 ;
00081 char* model_cfg_name = NULL;
00082 char* input_tab_name = NULL;
00083 cpl_frame* model_cfg_frame = NULL;
00084 int i = 0;
00085 FILE* themap_file = NULL;
00086 xsh_xs_3 model_config ;
00087 int binx=1;
00088 int biny=1;
00089 cpl_table* input_table=NULL;
00090 double* pord=NULL;
00091 double* pwav=NULL;
00092 double* ps=NULL;
00093 int nrow=0;
00094 double x=0;
00095 double y=0;
00096 xsh_instrument* inst;
00097
00098 TESTS_INIT(MODULE_ID);
00099
00100 cpl_msg_set_level(CPL_MSG_DEBUG);
00101 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00102
00103
00104 if (argc > 1){
00105 model_cfg_name = argv[1];
00106 input_tab_name = argv[2];
00107 }
00108 else{
00109 printf(SYNTAX);
00110 return 0;
00111 }
00112
00113
00114 XSH_ASSURE_NOT_NULL( model_cfg_name);
00115 model_cfg_frame = cpl_frame_new();
00116 cpl_frame_set_filename( model_cfg_frame, model_cfg_name) ;
00117 cpl_frame_set_level( model_cfg_frame, CPL_FRAME_LEVEL_TEMPORARY);
00118 cpl_frame_set_group( model_cfg_frame, CPL_FRAME_GROUP_RAW ) ;
00119 cpl_frame_set_type( model_cfg_frame, CPL_FRAME_TYPE_TABLE ) ;
00120 xsh_msg("model_cfg_name=%s",model_cfg_name);
00121 xsh_msg("input_tab_name=%s",model_cfg_name);
00122
00123 inst=xsh_instrument_new();
00124 xsh_instrument_parse_tag(inst,XSH_MOD_CFG_VIS);
00125
00126 check( xsh_model_config_load_best( model_cfg_frame, &model_config));
00127 xsh_model_binxy(&model_config,binx,biny);
00128 input_table=cpl_table_load(input_tab_name,1,0);
00129
00130 nrow=cpl_table_get_nrow(input_table);
00131
00132 for(i=0;i<nrow;i++) {
00133 check(xsh_model_get_xy(&model_config,inst,pwav[i],pord[i],ps[i],&x,&y));
00134
00135 }
00136
00137 exit(0);
00138
00139
00140 themap_file = fopen( "THEMAP.reg", "w");
00141 fprintf( themap_file, "# Region file format: DS9 version 4.0\n\
00142 global color=red font=\"helvetica 4 normal\"\
00143 select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 source \nimage\n");
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 fclose( themap_file);
00166
00167 cleanup:
00168 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00169 xsh_error_dump(CPL_MSG_ERROR);
00170 ret = -1;
00171 }
00172 return ret ;
00173 }
00174