61#define MODULE_ID "XSH_WAVECAL_FWHM"
63#define SYNTAX "Add evaluation of wavelength ans slit by dispersion solution to file fwhm.dat produce by wavecal\n"\
64 "usage : ./the_xsh_wavecal_fwhm DATA_FILE DISP_TAB\n"\
65 "DATA_FILE => File fwhm.dat produce by wavecal\n"\
66 "DISP_TAB => dispersion solution to apply\n"
80int main(
int argc,
char** argv)
85 const char *fwhm_name = NULL;
86 const char* disp_tab_name = NULL;
87 cpl_frame *disp_tab_frame = NULL;
88 cpl_propertylist *header = NULL;
90 FILE *fwhm_file = NULL;
91 FILE *res_file = NULL;
92 cpl_vector *pos = NULL;
96 cpl_msg_set_level( CPL_MSG_DEBUG);
102 disp_tab_name = argv[2];
109 xsh_msg(
"Fwhm data file: %s", fwhm_name);
110 xsh_msg(
"Disp tab file: %s", disp_tab_name);
113 check( header = cpl_propertylist_load( disp_tab_name, 0));
118 disp_tab_frame = cpl_frame_new();
119 cpl_frame_set_filename( disp_tab_frame, disp_tab_name) ;
120 cpl_frame_set_level( disp_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
121 cpl_frame_set_group( disp_tab_frame, CPL_FRAME_GROUP_RAW);
124 check( pos = cpl_vector_new(2));
127 fwhm_file = fopen( fwhm_name,
"r");
128 res_file = fopen(
"fwhm_full.dat",
"w+");
130 if ( fwhm_file != NULL && res_file!=NULL){
134 read = fgets( line, 200, fwhm_file);
135 fputs(
"# wavelength order xcen xcen-x0 ygauss ytilt fwhm area good lambdaG slitG lambdaT slitT\n", res_file);
136 while ( fgets( line, 200, fwhm_file)){
137 double wavelength, xcen, xcen_x0, ygauss, ytilt, fwhm, area;
139 double lambdaG, slitG, lambdaT, slitT;
142 sscanf( line,
"%64lf %64d %64lf %64lf %64lf %64lf %64lf %64lf %64d\n",
143 &wavelength, &
order, &xcen, &xcen_x0, &ygauss, &ytilt, &fwhm, &area, &good);
149 cpl_vector_set( pos, 0, xcen);
150 cpl_vector_set( pos, 1, ygauss);
156 cpl_vector_set( pos, 0, xcen);
157 cpl_vector_set( pos, 1, ytilt);
162 fprintf( res_file,
"%f %d %f %f %f %f %f %f %d %f %f %f %f\n",
163 wavelength,
order, xcen, xcen_x0, ygauss, ytilt, fwhm, area,
164 good, lambdaG, slitG, lambdaT, slitT);
170 if (cpl_error_get_code() != CPL_ERROR_NONE) {
174 if ( fwhm_file != NULL && res_file!=NULL){
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
xsh_dispersol_list * xsh_dispersol_list_load(cpl_frame *frame, xsh_instrument *instrument)
Load a dispersion list from a frame.
void xsh_dispersol_list_free(xsh_dispersol_list **list)
Free the dispersion list.
double xsh_dispersol_list_eval(xsh_dispersol_list *list, cpl_polynomial *poly, cpl_vector *pos)
Evaluate the polynomial according the binning.
#define xsh_error_dump(level)
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.
XSH_ARM xsh_pfits_get_arm(const cpl_propertylist *plist)
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
cpl_polynomial * slit_poly
cpl_polynomial * lambda_poly
#define TESTS_INIT(DRL_ID)