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