62#define MODULE_ID "XSH_RESID_TAB"
63#define SYNTAX "Test the residual tab\n"\
64 "use : ./the_xsh_resid_tab RESID_TAB \n"\
65 "RESID_TAB => the residual table\n"
79int main(
int argc,
char **argv)
85 char* resid_tab_name = NULL;
86 const char* extracted_tab_name =
"redid_not_flagged.fits";
87 cpl_frame* resid_tab_frame = NULL;
89 int resid_tab_size = 0;
90 cpl_table* tab_flagged=NULL;
91 cpl_table* tab_extract=NULL;
92 cpl_propertylist* plist=NULL;
94 FILE* resid_tab_the_file = NULL;
99 cpl_msg_set_level(CPL_MSG_DEBUG);
104 resid_tab_name = argv[1];
119 tab_flagged=cpl_table_load(resid_tab_name,1,0);
120 plist=cpl_propertylist_load(resid_tab_name,0);
121 cpl_table_and_selected_int(tab_flagged,
"Flag",CPL_EQUAL_TO,0);
122 tab_extract=cpl_table_extract_selected(tab_flagged);
123 cpl_table_erase_column(tab_extract,
"Flag");
124 cpl_table_save(tab_extract,plist,NULL,extracted_tab_name,CPL_IO_DEFAULT);
127 resid_tab_frame = cpl_frame_new();
128 cpl_frame_set_filename( resid_tab_frame, extracted_tab_name) ;
129 cpl_frame_set_level( resid_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
130 cpl_frame_set_group( resid_tab_frame, CPL_FRAME_GROUP_RAW ) ;
136 xsh_msg(
"Save residual tab in RESID_TAB.reg");
137 resid_tab_the_file = fopen(
"RESID_TAB.reg",
"w");
139 fprintf( resid_tab_the_file,
"# Region file format: DS9 version 4.0\n"\
140 "global color=red font=\"helvetica 10 normal\""\
141 "select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 "\
143 fprintf( resid_tab_the_file,
"# RED the_x the_y (pixels)\n"\
144 "# MAGENTA corr_x corr_y (pixels)\n"\
145 "# GREEN gauss_x gauss_y (pixels)\n"\
146 "# BLUE poly_x poly_y (pixels)\n");
149 xsh_msg(
"Residual tab compute from POLYNOMIAL");
152 xsh_msg(
"Residual tab compute from PHYSICAL MODEL");
154 for( i=0; i<resid_tab_size; i++){
156 double corr_x, corr_y;
157 double gauss_x, gauss_y;
158 double poly_x, poly_y;
161 lambda = resid_tab->
lambda[i];
164 corr_x = resid_tab->
thcor_x[i];
165 corr_y = resid_tab->
thcor_y[i];
166 gauss_x = resid_tab->
xgauss[i];
167 gauss_y = resid_tab->
ygauss[i];
169 poly_x = resid_tab->
xpoly[i];
170 poly_y = resid_tab->
ypoly[i];
176 fprintf( resid_tab_the_file,
"point(%f,%f) #point=cross color=red text={THE %.3f} font="\
177 "\"helvetica 10 normal\"\n", the_x, the_y, lambda);
178 fprintf( resid_tab_the_file,
"point(%f,%f) #point=diamond color=magenta font="\
179 "\"helvetica 4 normal\"\n", corr_x, corr_y);
180 fprintf( resid_tab_the_file,
"point(%f,%f) #point=circle color=green font="\
181 "\"helvetica 4 normal\"\n", gauss_x, gauss_y);
182 fprintf( resid_tab_the_file,
"point(%f,%f) #point=x color=blue font="\
183 "\"helvetica 4 normal\"\n", poly_x, poly_y);
185 fclose( resid_tab_the_file);
186 xsh_msg(
"Save residual tab in RESID_TAB.dat");
196 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
void xsh_resid_tab_free(xsh_resid_tab **resid)
Free memory associated to a resid_tab.
xsh_resid_tab * xsh_resid_tab_load(cpl_frame *resid_tab_frame)
Load a residual tab from a frame.
void xsh_resid_tab_log(xsh_resid_tab *resid, const char *filename)
Log the residual tab in a ASCII file
#define xsh_error_dump(level)
#define XSH_ASSURE_NOT_NULL(pointer)
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
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)
int xsh_resid_tab_get_size(xsh_resid_tab *resid)
#define XSH_DETECT_ARCLINES_TYPE_POLY