62#define MODULE_ID "XSH_GUESS"
63#define SYNTAX "Test X,Y point generation\n"\
64 "use : ./the_xsh_guess XSH_MODEL_CFG INPUT_MODEL_TAB (columns 'order', 'wavelength', 'slit')\n"\
65 "(table with predicted 'x','y' predicted positions)\n"
79int main(
int argc,
char **argv)
84 char* model_cfg_name = NULL;
85 char* input_tab_name = NULL;
86 cpl_propertylist* plist=NULL;
87 cpl_frame* model_cfg_frame = NULL;
88 cpl_frame* the_map_frame = NULL;
91 FILE* themap_file = NULL;
95 cpl_table* the_map_tab=NULL;
106 cpl_msg_set_level(CPL_MSG_DEBUG);
111 model_cfg_name = argv[1];
112 input_tab_name = argv[2];
121 plist=cpl_propertylist_load(model_cfg_name,0);
124 check(model_cfg_frame = cpl_frame_new());
125 cpl_frame_set_filename( model_cfg_frame, model_cfg_name) ;
126 cpl_frame_set_level( model_cfg_frame, CPL_FRAME_LEVEL_TEMPORARY);
127 cpl_frame_set_group( model_cfg_frame, CPL_FRAME_GROUP_RAW ) ;
128 cpl_frame_set_type( model_cfg_frame, CPL_FRAME_TYPE_TABLE ) ;
129 check(cpl_frame_set_tag( model_cfg_frame, tag ) );
131 xsh_msg(
"model_cfg_name=%s",model_cfg_name);
132 xsh_msg(
"input_tab_name=%s",input_tab_name);
138 the_map_tab=cpl_table_load(input_tab_name,1,0);
144 nrow=cpl_table_get_nrow(the_map_tab);
145 for(i=0;i<nrow;i++) {
152 themap_file = fopen(
"THEMAP.reg",
"w");
153 fprintf( themap_file,
"# Region file format: DS9 version 4.0\n\
154 global color=red font=\"helvetica 4 normal\"\
155 select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 source \nimage\n");
158 the_map_frame = cpl_frame_new();
159 cpl_frame_set_filename( the_map_frame, input_tab_name) ;
160 cpl_frame_set_level( the_map_frame, CPL_FRAME_LEVEL_TEMPORARY);
161 cpl_frame_set_group( the_map_frame, CPL_FRAME_GROUP_RAW ) ;
162 cpl_frame_set_type( the_map_frame, CPL_FRAME_TYPE_TABLE ) ;
163 cpl_frame_set_tag( the_map_frame, tag ) ;
167 int themap_size=nrow;
168 for( i=0; i<themap_size; i++){
169 float lambdaTHE = 0.0;
178 fprintf( themap_file,
"point(%f,%f) #point=cross color=yellow "\
179 "font=\"helvetica 10 normal\" text={THE %.3f}\n", xd, yd, lambdaTHE);
182 fprintf( themap_file,
"point(%f,%f) #point=cross color=yellow "\
183 "font=\"helvetica 10 normal\" text={slit %f}\n", xd, yd, slit);
196 if(themap_file != NULL) {
197 fclose( themap_file);
199 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
void xsh_the_map_free(xsh_the_map **list)
free memory associated to a the_map
double xsh_the_map_get_detx(xsh_the_map *list, int idx)
get detx of the map list
float xsh_the_map_get_slit_position(xsh_the_map *list, int idx)
get slit position of the map list
double xsh_the_map_get_dety(xsh_the_map *list, int idx)
get dety of the map list
float xsh_the_map_get_wavelength(xsh_the_map *list, int idx)
get wavelength of the map list
xsh_the_map * xsh_the_map_load(cpl_frame *frame)
load a theoretical map frame in the_map structure. Suppress spurious entries in the THE MAP (marked w...
#define xsh_error_dump(level)
#define XSH_ASSURE_NOT_NULL(pointer)
void xsh_instrument_parse_tag(xsh_instrument *inst, const char *tag)
analyse a frame tag to set data in instrument structure
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
cpl_error_code xsh_model_config_load_best(cpl_frame *config_frame, xsh_xs_3 *p_xs_3)
Load the config model table and fill the struct.
void xsh_model_get_xy(xsh_xs_3 *p_xs_3, xsh_instrument *instr, double lambda_nm, int morder, double ent_slit_pos, double *x, double *y)
Compute the detector location (floating point pixels) of a given wavelength/entrance slit position.
void xsh_model_binxy(xsh_xs_3 *p_xs_3, int bin_X, int bin_Y)
corrects model for detector's binning
#define xsh_msg(...)
Print a message on info level.
const char * xsh_pfits_get_pcatg(const cpl_propertylist *plist)
find out the pcatg
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
#define TESTS_INIT(DRL_ID)
#define XSH_THE_MAP_TABLE_COLNAME_SLITINDEX
#define XSH_THE_MAP_TABLE_COLNAME_WAVELENGTH
#define XSH_THE_MAP_TABLE_COLNAME_ORDER