65#include <gsl/gsl_multifit.h>
72 int*
size,
double **lambda,
double **
n,
double **
s,
int **s_index,
73 double **xthe,
double **ythe,
int nb_pinhole);
77 double **
n,
double **
s,
double **sn,
78 int **s_index,
double **xthe,
double **ythe,
82 double *A,
double *lambda,
double *
n,
double *
s,
int size,
83 int max_iter,
double min_frac,
double sigma,
int* rejected);
86 double y,
double* sn);
104 check( flux = cpl_image_get( pre->
data, xpix, ypix, &rej));
105 check( noise = cpl_image_get( pre->
errs, xpix, ypix, &rej));
107 res = (*sn > sn_ref);
114 double **
n,
double **
s,
double** sn,
115 int **s_index,
double **xthe,
double **ythe,
119 cpl_vector** spectral_tab = NULL;
130 XSH_CALLOC( spectral_tab, cpl_vector*, arc_size);
132 nb_slit = nb_pinhole;
136 for( i=0; i< arc_size; i++){
137 cpl_vector* res = NULL;
145 check( res_size = cpl_vector_get_size( res));
152 global_size += res_size;
153 spectral_tab[i] = res;
165 for( i=0; i< arc_size; i++){
166 double model_x, model_y;
167 cpl_vector *spectral_res = NULL;
168 int spectral_res_size;
172 check( spectral_res = spectral_tab[i]);
174 if (spectral_res != NULL){
175 check( spectral_res_size = cpl_vector_get_size( spectral_res));
176 for( j=0; j< spectral_res_size; j++){
183 for(islit=0; islit < nb_slit; islit++){
185 slit = config_model->
slit[islit];
186 check( absorder = (
int) cpl_vector_get( spectral_res, j));
191 &model_x, &model_y));
192 (*lambda)[index_loc] = lambdaARC;
193 (*n)[index_loc] = absorder;
194 (*s_index)[index_loc] = islit;
195 (*s)[index_loc] = slit;
196 (*sn)[index_loc] = 0;
197 (*xthe)[index_loc] = model_x;
198 (*ythe)[index_loc] = model_y;
204 slit = config_model->
slit[islit];
205 check( absorder = (
int) cpl_vector_get( spectral_res, j));
207 &model_x, &model_y));
208 (*lambda)[index_loc] = lambdaARC;
209 (*n)[index_loc] = absorder;
210 (*s_index)[index_loc] = islit;
211 (*s)[index_loc] = slit;
212 (*sn)[index_loc] = 0;
213 (*xthe)[index_loc] = model_x;
214 (*ythe)[index_loc] = model_y;
225 if ( spectral_tab != NULL){
226 for(i=0; i< arc_size; i++){
231 if ( cpl_error_get_code() != CPL_ERROR_NONE){
263 int*
size,
double **lambda,
double **
n,
double **
s,
int **s_index,
264 double **xthe,
double **ythe,
int nb_pinhole)
285 nb_slit = nb_pinhole;
288 for(i=0; i< arc_size; i++){
289 float lambdaARC, lambdaTHE;
290 int nb_match = 0, max_match = 0;
298 while ( (j < the_size-1) &&
306 max_match = the_size-j;
309 double order, slit, xtheval, ytheval;
315 if ( (nb_slit > 1) || (islit == 4) ){
320 (*lambda)[sol_size] = lambdaTHE;
321 (*n)[sol_size] =
order;
322 (*s)[sol_size] = slit;
323 (*s_index)[sol_size] = islit;
324 (*xthe)[sol_size] = xtheval;
325 (*ythe)[sol_size] = ytheval;
328 sol_size, (*
n)[sol_size], (*
s)[sol_size], (*lambda)[sol_size]);
333 if ( j < (the_size-1) ){
347 if ( cpl_error_get_code() != CPL_ERROR_NONE){
383 double *A,
double *lambda,
double *
n,
double *
s,
int size,
384 int max_iter,
double min_frac,
double sigma,
int* rejected)
389 int new_rejected = 1;
390 cpl_polynomial *fitpoly = NULL;
391 cpl_vector *dispy = NULL;
406 &(wavesol->
min_y), &(wavesol->
max_y), lambda,
n,
s, fitpoly));
409 for(i=0; i< index_size; i++){
413 xsh_msg(
"Fit wavesol with sigma clipping");
415 while (nbiter < max_iter && frac > min_frac && new_rejected > 0){
420 dispy = cpl_vector_new( index_size);
422 for(i = 0; i < index_size; i ++){
427 check( cpl_vector_set( dispy, i, diffy));
430 check( sigma_med = cpl_vector_get_stdev( dispy));
433 for(i = 0; i < index_size; i++){
434 if ( fabs(cpl_vector_get( dispy, i)) > (
sigma * sigma_med) ){
436 rejected[idx[i]] = 1;
439 idx[i-new_rejected] = idx[i];
440 A[i-new_rejected] = A[i];
441 lambda[i-new_rejected] = lambda[i];
442 n[i-new_rejected] =
n[i];
443 s[i-new_rejected] =
s[i];
447 index_size -= new_rejected;
448 nbrejected += new_rejected;
450 frac = 1 - ( (float) nbrejected / (
float)
size);
455 &(wavesol->
min_y), &(wavesol->
max_y), lambda,
n,
s, fitpoly));
508 cpl_frame *theo_tab_frame,
509 cpl_frame *arc_lines_tab_frame,
510 cpl_frame* wave_tab_guess_frame,
511 cpl_frame *order_tab_recov_frame,
512 cpl_frame *config_model_frame,
513 cpl_frame *spectralformat_frame,
514 cpl_frame **resid_tab_orders_frame,
515 cpl_frame **arc_lines_clean_tab_frame,
516 cpl_frame **wave_tab_frame,
517 cpl_frame **resid_tab_frame,
524 const int resid_tab_name_sw)
532 cpl_polynomial *fit2dx = NULL;
533 cpl_propertylist* header = NULL;
535 double *vlambdadata = NULL, *vsdata = NULL, *vorderdata = NULL, *vsndata=NULL;
536 int *vsindexdata = NULL;
537 double *vxthedata = NULL, *vythedata = NULL;
538 double *corr_x = NULL, *corr_y = NULL;
539 double *gaussian_pos_x = NULL, *gaussian_pos_y = NULL,
540 *gaussian_sigma_x = NULL, *gaussian_sigma_y = NULL,
541 *gaussian_fwhm_x = NULL, *gaussian_fwhm_y = NULL, *gaussian_norm=NULL;
543 cpl_array *gaussian_sigma_x_arr =NULL;
544 cpl_array *gaussian_sigma_y_arr =NULL;
545 cpl_array *gaussian_fwhm_x_arr =NULL;
546 cpl_array *gaussian_fwhm_y_arr =NULL;
549 double *diffx = NULL, *diffy = NULL;
550 double *diffxmean = NULL, *diffymean = NULL, *diffxsig = NULL, *diffysig = NULL;
553 int nlinematched, nlinecat_clean=0, nlinecat;
556 char wave_table_name[256];
557 const char* wave_table_tag = NULL;
562 int lines_not_in_image = 0;
563 int lines_not_good_sn = 0;
564 int lines_not_gauss_fit = 0;
565 int lines_not_valid_pixels = 0;
566 int lines_too_few_ph=0;
568 int* rejected = NULL;
570 int solution_type = 0;
571 const char* solution_type_name[2] = {
"POLY",
"MODEL"};
572 int detection_mode = 0;
573 const char* detection_mode_name[3] = {
"NORMAL",
"CORRECTED",
"RECOVER"};
578 const char* tag=NULL;
582 cpl_table* wave_trace=NULL;
585 cpl_table* cfg_tab=NULL;
586 const char* cfg_name=NULL;
589 cpl_propertylist* plist=NULL;
591 int min_slit_match=4;
592 double line_devs=2.5;
620 "fail to find number of pinholes info in frame %s",
621 cpl_frame_get_filename(frame) );
624 if(strstr(dpr_type,
"FMTCHK") != NULL) {
625 strcpy(type,
"FMTCHK_");
626 }
else if(strstr(dpr_type,
"WAVE") != NULL) {
627 strcpy(type,
"WAVE_");
628 }
else if(strstr(dpr_type,
"WAVE") != NULL) {
638 spectralformat_frame, instr));
646 if ( theo_tab_frame != NULL) {
653 &vorderdata, &vsdata, &vsindexdata, &vxthedata, &vythedata, nb_pinhole));
656 else if ( config_model_frame != NULL){
659 p_xs_3=&config_model;
663 check(cfg_name=cpl_frame_get_filename(config_model_frame));
664 check(plist=cpl_propertylist_load(cfg_name,0));
665 check(cfg_tab=cpl_table_load(cfg_name,1,0));
668 sprintf(basename,
"%s.fits",tag);
669 sprintf(new_name,
"local_%s",basename);
671 check(cpl_table_save(cfg_tab,plist,NULL,new_name,CPL_IO_DEFAULT));
673 check(cpl_frame_set_filename(config_model_frame,new_name));
685 &sol_size, &vlambdadata, &vorderdata, &vsdata,
686 &vsndata, &vsindexdata, &vxthedata, &vythedata,
692 "Undefined solution type (POLY or MODEL). See your input sof");
700 if ( wave_tab_guess_frame == NULL){
701 if ( order_tab_recov_frame == NULL){
711 if ( order_tab_recov_frame == NULL){
717 wave_tab_guess->
bin_y ) ;
727 xsh_msg(
"Detection mode : %s", detection_mode_name[detection_mode]);
733 XSH_MALLOC( gaussian_pos_x,
double, sol_size);
734 XSH_MALLOC( gaussian_pos_y,
double, sol_size);
735 XSH_MALLOC( gaussian_sigma_x,
double, sol_size);
736 XSH_MALLOC( gaussian_sigma_y,
double, sol_size);
738 XSH_MALLOC( gaussian_fwhm_x,
double, sol_size);
739 XSH_MALLOC( gaussian_fwhm_y,
double, sol_size);
754 memset(corr_x,0,
sizeof(
double)*sol_size);
755 memset(corr_y,0,
sizeof(
double)*sol_size);
757 memset(gaussian_pos_x,0,
sizeof(
double)*sol_size);
758 memset(gaussian_pos_y,0,
sizeof(
double)*sol_size);
759 memset(gaussian_sigma_x,0,
sizeof(
double)*sol_size);
760 memset(gaussian_sigma_y,0,
sizeof(
double)*sol_size);
761 memset(gaussian_fwhm_x,0,
sizeof(
double)*sol_size);
762 memset(gaussian_fwhm_y,0,
sizeof(
double)*sol_size);
763 memset(gaussian_norm,0,
sizeof(
double)*sol_size);
764 memset(diffx,0,
sizeof(
double)*sol_size);
765 memset(diffy,0,
sizeof(
double)*sol_size);
766 memset(diffxmean,0,
sizeof(
double)*sol_size);
767 memset(diffymean,0,
sizeof(
double)*sol_size);
769 memset(diffxsig,0,
sizeof(
double)*sol_size);
770 memset(diffysig,0,
sizeof(
double)*sol_size);
772 memset(flag,0,
sizeof(
int)*sol_size);
787 for(i=0; i< sol_size; i++){
788 int xpos = 0, ypos = 0;
790 double corrxv = 0.0, corryv = 0.0;
791 double lambda,
order, slit, xthe, ythe,sn=0;
792 double xcor, ycor,
x,
y, sig_x, sig_y, norm, fwhm_x, fwhm_y;
795 lambda = vlambdadata[i];
796 order = vorderdata[i];
799 if(vsndata != NULL) {
803 slit_index = vsindexdata[i];
807 order, slit, xthe, ythe);
815 if ( order_tab_recov != NULL){
817 cpl_polynomial *center_poly_recov = NULL;
820 order_tab_recov,
order));
821 center_poly_recov = order_tab_recov->
list[iorder].
cenpoly;
822 check( xcor = cpl_polynomial_eval_1d( center_poly_recov, ycor, NULL));
826 if ( wave_tab_guess != NULL){
827 double diffxv, diffyv;
843 if ( xcor >=0.5 && ycor >=0.5 &&
844 xcor < (pre->
nx+0.5) && ycor < (pre->
ny+0.5)){
845 int best_med_res = 0;
847 (
int)(xcor+0.5)-1, (
int)(ycor+0.5)-1,
850 if (best_med_res != 0){
851 lines_not_valid_pixels++;
863 &norm, &
x, &
y, &sig_x, &sig_y, &fwhm_x, &fwhm_y);
912 &norm, &
x, &
y, &sig_x, &sig_y, &fwhm_x, &fwhm_y);
930 if (p_xs_3->
arm==2) {
933 else if (p_xs_3->
arm==0) {
938 if( cpl_error_get_code() == CPL_ERROR_NONE ){
940 vlambdadata[i] = lambda;
941 vorderdata[i] =
order;
947 vsindexdata[i] = slit_index;
952 gaussian_pos_x[i] =
x;
953 gaussian_pos_y[i] =
y;
954 gaussian_sigma_x[i] = sig_x;
955 gaussian_sigma_y[i] = sig_y;
956 gaussian_fwhm_x[i] = fwhm_x;
957 gaussian_fwhm_y[i] = fwhm_y;
958 gaussian_norm[i] = norm;
973 lines_not_gauss_fit++;
980 lines_not_in_image++;
992 for (i=1; i<sol_size; i++) {
994 i, vlambdadata[i], vorderdata[i], vsdata[i]);
996 if (vlambdadata[i]!=vlambdadata[i-1] ||
997 vorderdata[i]!=vorderdata[i-1] ||
1001 if (i==sol_size-1) {
1005 starti, i, i-starti);
1007 if (i-starti-nbflag>=min_slit_match) {
1008 for (k=starti; k<=i-1; k++) {
1011 for (j=starti; j<=i-1; j++) {
1012 if (j!=k && flag[k]==0 && flag[j]==0) {
1013 diffxmean[k]+=diffx[j];
1014 diffymean[k]+=diffy[j];
1017 diffxmean[k]/=(float)(i-starti-1);
1018 diffymean[k]/=(float)(i-starti-1);
1020 for (k=starti; k<=i-1; k++) {
1023 for (j=starti; j<=i-1; j++) {
1024 if (j!=k && flag[k]==0 && flag[j]==0) {
1025 diffysig[k]+=(diffy[j]-diffymean[k])*(diffy[j]-diffymean[k]);
1026 diffxsig[k]+=(diffx[j]-diffxmean[k])*(diffx[j]-diffxmean[k]);
1029 diffxsig[k]=sqrt(diffxsig[k]/(
float)(i-starti-1));
1030 diffysig[k]=sqrt(diffysig[k]/(
float)(i-starti-1));
1032 for (j=starti; j<=i-1; j++) {
1034 if (fabs(diffx[j]-diffxmean[j])>line_devs*diffxsig[j] && fabs(diffy[j]-diffymean[j])>line_devs*diffysig[j] && flag[j]==0) {
1039 newi+=i-starti-nbflag;
1042 if (i-starti-nbflag<min_slit_match) {
1043 lines_too_few_ph+=i-starti;
1044 for (j=starti; j<=i-1; j++) {
1055 if (i<sol_size && flag[i]!=0) {
1065 xsh_msg(
"nlinematched / sol_size = %d / %d", nlinematched, sol_size);
1066 assure(nlinematched > 0, CPL_ERROR_ILLEGAL_INPUT,
1067 "No line matched, value of parameter "
1068 "detectarclines-search-win-hsize may be too large or too small "
1069 "detectarclines-fit-win-hsize=%d may be too large or too small "
1070 "detectarclines-running-median-hsize may be too large or too small "
1071 "detectarclines-min-sn may be too small "
1072 "or value of parameter detectarclines-min-sn may be too large",
1080 xsh_msg_dbg_medium(
" %d lines detected in less than %d/9 ph positions", lines_too_few_ph,min_slit_match);
1084 gaussian_sigma_x_arr = cpl_array_wrap_double(gaussian_sigma_x, nlinematched);
1085 gaussian_sigma_y_arr = cpl_array_wrap_double(gaussian_sigma_y, nlinematched);
1086 gaussian_fwhm_x_arr = cpl_array_wrap_double( gaussian_fwhm_x,nlinematched);
1087 gaussian_fwhm_y_arr = cpl_array_wrap_double( gaussian_fwhm_y,nlinematched);
1095 for(i=0;i<nlinematched;i++){
1097 cpl_array_set_invalid(gaussian_sigma_x_arr,i);
1098 cpl_array_set_invalid(gaussian_sigma_y_arr,i);
1099 cpl_array_set_invalid(gaussian_fwhm_x_arr,i);
1100 cpl_array_set_invalid(gaussian_fwhm_y_arr,i);
1104 xsh_msg(
"sigma gaussian median in x %lg",
1105 cpl_array_get_median( gaussian_sigma_x_arr));
1106 xsh_msg(
"sigma gaussian median in y %lg",
1107 cpl_array_get_median( gaussian_sigma_y_arr));
1109 xsh_msg(
"FWHM gaussian median in x %lg",
1110 cpl_array_get_median( gaussian_fwhm_x_arr));
1111 xsh_msg(
"FWHM gaussian median in y %lg",
1112 cpl_array_get_median( gaussian_fwhm_y_arr));
1123 if ( resid_tab_orders_frame != NULL){
1129 vxthedata, vythedata,
1137 gaussian_fwhm_y,flag,
1141 if(resid_tab_name_sw) {
1142 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_ORDERS_",
1145 sprintf(rtag,
"%s%s%s",type,
"RESID_ALL_TAB_ORDERS_",
1149 sprintf(rname,
"%s%s",rtag,
".fits");
1152 rname, instr,rtag));
1166 (wave_tab_frame != NULL)){
1173 vorderdata, vsdata, nlinematched, dac->
niter, dac->
frac,
1174 dac->
sigma, rejected));
1176 for(i=0; i< nlinematched; i++){
1177 if (rejected[i] == 1){
1182 vxthedata[i-nb_rejected] = vxthedata[i];
1183 vythedata[i-nb_rejected] = vythedata[i];
1184 vsindexdata[i-nb_rejected] = vsindexdata[i];
1185 corr_x[i-nb_rejected] = corr_x[i];
1186 corr_y[i-nb_rejected] = corr_y[i];
1187 gaussian_pos_x[i-nb_rejected] = gaussian_pos_x[i];
1188 gaussian_pos_y[i-nb_rejected] = gaussian_pos_y[i];
1189 gaussian_sigma_x[i-nb_rejected] = gaussian_sigma_x[i];
1190 gaussian_sigma_y[i-nb_rejected] = gaussian_sigma_y[i];
1191 gaussian_fwhm_x[i-nb_rejected] = gaussian_fwhm_x[i];
1192 gaussian_fwhm_y[i-nb_rejected] = gaussian_fwhm_y[i];
1193 gaussian_norm[i-nb_rejected] = gaussian_norm[i];
1194 diffx[i-nb_rejected] = diffx[i];
1197 nlinematched = nlinematched-nb_rejected;
1201 nlinematched, diffx,
1203 vlambdadata, vorderdata, vsdata, fit2dx));
1206 sprintf(wave_table_name,
"%s%s.fits",
"WAVE_TAB_GUESS_",
1216 vlambdadata, vorderdata, vsdata, nlinematched, dac->
niter, dac->
frac,
1217 dac->
sigma, rejected));
1219 for(i=0; i< nlinematched; i++){
1220 if (rejected[i] == 1){
1225 vxthedata[i-nb_rejected] = vxthedata[i];
1226 vythedata[i-nb_rejected] = vythedata[i];
1227 vsindexdata[i-nb_rejected] = vsindexdata[i];
1228 corr_x[i-nb_rejected] = corr_x[i];
1229 corr_y[i-nb_rejected] = corr_y[i];
1230 gaussian_pos_x[i-nb_rejected] = gaussian_pos_x[i];
1231 gaussian_sigma_x[i-nb_rejected] = gaussian_sigma_x[i];
1232 gaussian_sigma_y[i-nb_rejected] = gaussian_sigma_y[i];
1233 gaussian_fwhm_x[i-nb_rejected] = gaussian_fwhm_x[i];
1234 gaussian_fwhm_y[i-nb_rejected] = gaussian_fwhm_y[i];
1237 nlinematched = nlinematched-nb_rejected;
1241 &wave_table->
min_x, &wave_table->
max_x, vlambdadata, vorderdata,
1244 sprintf(wave_table_name,
"%s%s.fits",
"WAVE_TAB_2D_",
1256 xsh_msg(
"poly nlinecat=%d",nlinecat);
1263 vsdata,nlinematched));
1266 wave_table_name,wave_table_tag));
1268 check( cpl_frame_set_tag( *wave_tab_frame, wave_table_tag));
1282 if(strcmp(rec_id,
"xsh_predict") == 0) {
1288 sprintf(fname,
"%s%s",tag,
".fits");
1295 vsdata,vsndata,vsindexdata,vxthedata,vythedata,
1296 corr_x,corr_y,gaussian_norm,
1297 gaussian_pos_x,gaussian_pos_y,
1298 gaussian_sigma_x, gaussian_sigma_y,
1299 gaussian_fwhm_x, gaussian_fwhm_y,flag,
1300 wave_table,solution_type));
1302 if(resid_tab_name_sw) {
1303 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_LINES_",
1306 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_ALL_LINES_",
1309 check( tag = cpl_frame_get_tag( frame));
1314 sprintf(rname,
"AFC_CAL_%s%s",rtag,
".fits") ;
1317 sprintf(rname,
"AFC_ATT_%s%s",rtag,
".fits") ;
1320 sprintf(rname,
"%s%s",rtag,
".fits") ;
1407 cpl_frame *theo_tab_frame,
1408 cpl_frame *arc_lines_tab_frame,
1409 cpl_frame* wave_tab_guess_frame,
1410 cpl_frame *order_tab_recov_frame,
1411 cpl_frame *config_model_frame,
1412 cpl_frame *spectralformat_frame,
1413 cpl_frame **resid_tab_orders_frame,
1414 cpl_frame **arc_lines_clean_tab_frame,
1415 cpl_frame **wave_tab_frame,
1416 cpl_frame **resid_tab_frame,
1422 const int clean_tmp,
const int resid_tab_name_sw)
1432 cpl_polynomial *fit2dx = NULL;
1433 cpl_propertylist* header = NULL;
1435 double *vlambdadata = NULL, *vsdata = NULL, *vorderdata = NULL, *vsndata=NULL;
1436 int *vsindexdata = NULL;
1437 double *vxthedata = NULL, *vythedata = NULL;
1438 double *corr_x = NULL, *corr_y = NULL;
1439 double *gaussian_pos_x = NULL, *gaussian_pos_y = NULL,
1440 *gaussian_sigma_x = NULL, *gaussian_sigma_y = NULL,
1441 *gaussian_fwhm_x = NULL, *gaussian_fwhm_y = NULL, *gaussian_norm=NULL;
1442 cpl_vector *gaussian_sigma_x_vect =NULL;
1443 cpl_vector *gaussian_sigma_y_vect =NULL;
1444 cpl_vector *gaussian_fwhm_x_vect =NULL;
1445 cpl_vector *gaussian_fwhm_y_vect =NULL;
1448 double *diffx = NULL, *diffy = NULL;
1449 double *diffxmean = NULL, *diffymean = NULL, *diffxsig = NULL, *diffysig = NULL;
1452 int nlinematched, nlinecat_clean=0, nlinecat;
1453 int i, sol_size = 0;
1455 char wave_table_name[256];
1456 const char* wave_table_tag = NULL;
1461 int lines_not_in_image = 0;
1462 int lines_not_good_sn = 0;
1463 int lines_not_gauss_fit = 0;
1464 int lines_not_valid_pixels = 0;
1465 int lines_too_few_ph=0;
1467 int* rejected = NULL;
1468 int nb_rejected = 0;
1469 int solution_type = 0;
1470 const char* solution_type_name[2] = {
"POLY",
"MODEL"};
1471 int detection_mode = 0;
1472 const char* detection_mode_name[3] = {
"NORMAL",
"CORRECTED",
"RECOVER"};
1477 const char* tag=NULL;
1481 cpl_table* wave_trace=NULL;
1484 cpl_table* cfg_tab=NULL;
1485 const char* cfg_name=NULL;
1490 cpl_propertylist* plist=NULL;
1497 int min_slit_match=7;
1498 int found_temp=
true;
1520 "fail to find number of pinholes info in frame %s",
1521 cpl_frame_get_filename(frame) );
1524 if(strstr(dpr_type,
"FMTCHK") != NULL) {
1525 strcpy(type,
"FMTCHK_");
1526 }
else if(strstr(dpr_type,
"WAVE") != NULL) {
1527 strcpy(type,
"WAVE_");
1528 }
else if(strstr(dpr_type,
"WAVE") != NULL) {
1529 strcpy(type,
"ARC_");
1536 spectralformat_frame, instr));
1543 if ( theo_tab_frame != NULL) {
1549 &vorderdata, &vsdata, &vsindexdata, &vxthedata, &vythedata, nb_pinhole));
1552 else if ( config_model_frame != NULL){
1554 p_xs_3=&config_model;
1558 check(cfg_name=cpl_frame_get_filename(config_model_frame));
1559 check(plist=cpl_propertylist_load(cfg_name,0));
1560 check(cfg_tab=cpl_table_load(cfg_name,1,0));
1563 sprintf(basename,
"%s.fits",tag);
1564 sprintf(new_name,
"local_%s",basename);
1566 check(cpl_table_save(cfg_tab,plist,NULL,new_name,CPL_IO_DEFAULT));
1568 check(cpl_frame_set_filename(config_model_frame,new_name));
1576 instr,&found_temp));
1579 &sol_size, &vlambdadata, &vorderdata, &vsdata,
1580 &vsndata, &vsindexdata, &vxthedata, &vythedata,
1581 instr, nb_pinhole));
1585 "Undefined solution type (POLY or MODEL). See your input sof");
1595 if ( wave_tab_guess_frame == NULL){
1596 if ( order_tab_recov_frame == NULL){
1606 if ( order_tab_recov_frame == NULL){
1612 wave_tab_guess->
bin_y ) ;
1615 detection_mode = -1;
1622 xsh_msg(
"Detection mode : %s", detection_mode_name[detection_mode]);
1624 xsh_msg(
"Solution size %d", sol_size);
1630 XSH_MALLOC( gaussian_pos_x,
double, sol_size);
1631 XSH_MALLOC( gaussian_pos_y,
double, sol_size);
1632 XSH_MALLOC( gaussian_sigma_x,
double, sol_size);
1633 XSH_MALLOC( gaussian_sigma_y,
double, sol_size);
1635 XSH_MALLOC( gaussian_fwhm_x,
double, sol_size);
1636 XSH_MALLOC( gaussian_fwhm_y,
double, sol_size);
1637 XSH_MALLOC( gaussian_norm,
double, sol_size);
1660 FILE* regfile = NULL;
1662 regfile = fopen(
"FIT.reg",
"w");
1663 fprintf( regfile,
"# Region file format: DS9 version 4.0\n"\
1664 "global color=red font=\"helvetica 4 normal\""\
1665 "select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 "\
1668 regfile = fopen(
"NOFIT.reg",
"w");
1669 fprintf( regfile,
"# Region file format: DS9 version 4.0\n"\
1670 "global color=red font=\"helvetica 4 normal\""\
1671 "select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 "\
1676 for(i=0; i< sol_size; i++){
1677 int xpos = 0, ypos = 0;
1679 double corrxv = 0.0, corryv = 0.0;
1680 double lambda,
order, slit, xthe, ythe,sn=0;
1681 double xcor, ycor,
x,
y, sig_x, sig_y, norm, fwhm_x, fwhm_y;
1684 lambda = vlambdadata[i];
1685 order = vorderdata[i];
1688 if(vsndata != NULL) {
1692 slit_index = vsindexdata[i];
1693 xthe = vxthedata[i];
1694 ythe = vythedata[i];
1696 order, slit, xthe, ythe);
1704 if ( order_tab_recov != NULL){
1706 cpl_polynomial *center_poly_recov = NULL;
1709 order_tab_recov,
order));
1710 center_poly_recov = order_tab_recov->
list[iorder].
cenpoly;
1711 check( xcor = cpl_polynomial_eval_1d( center_poly_recov, ycor, NULL));
1715 if ( wave_tab_guess != NULL){
1716 double diffxv, diffyv;
1732 if ( xcor >=0.5 && ycor >=0.5 &&
1733 xcor < (pre->
nx+0.5) && ycor < (pre->
ny+0.5)){
1734 int best_med_res = 0;
1736 (
int)(xcor+0.5)-1, (
int)(ycor+0.5)-1,
1739 if (best_med_res != 0){
1740 lines_not_valid_pixels++;
1750 &norm, &
x, &
y, &sig_x, &sig_y, &fwhm_x, &fwhm_y);
1799 &norm, &
x, &
y, &sig_x, &sig_y, &fwhm_x, &fwhm_y);
1817 if (p_xs_3->
arm==2) {
1820 else if (p_xs_3->
arm==0) {
1826 const char* fit = NULL;
1827 const char* color = NULL;
1828 FILE* regfile = NULL;
1830 if (cpl_error_get_code() == CPL_ERROR_NONE){
1838 regfile = fopen( fit,
"a");
1839 fprintf( regfile,
"point(%d,%d) #point=cross color=blue\n", (
int)(xcor), (
int)(ycor));
1840 fprintf( regfile,
"box(%d,%d,%d,%d) #color=blue\n", (
int)(xcor), (
int)(ycor),
1842 fprintf( regfile,
"point(%d,%d) #point=cross color=%s font=\"helvetica 10 normal\""\
1843 " text={%.3f}\n", xpos, ypos, color, lambda);
1844 fprintf( regfile,
"box(%d,%d,%d,%d) #color=%s\n", (
int)xpos, (
int)ypos,
1849 if( cpl_error_get_code() == CPL_ERROR_NONE ){
1851 vlambdadata[nlinematched] = lambda;
1852 vorderdata[nlinematched] =
order;
1853 vsdata[nlinematched] = slit;
1855 vsndata[nlinematched] = sn;
1858 vsindexdata[nlinematched] = slit_index;
1859 vxthedata[nlinematched] = xthe;
1860 vythedata[nlinematched] = ythe;
1861 corr_x[nlinematched] = corrxv;
1862 corr_y[nlinematched] = corryv;
1863 gaussian_pos_x[nlinematched] =
x;
1864 gaussian_pos_y[nlinematched] =
y;
1865 gaussian_sigma_x[nlinematched] = sig_x;
1866 gaussian_sigma_y[nlinematched] = sig_y;
1867 gaussian_fwhm_x[nlinematched] = fwhm_x;
1868 gaussian_fwhm_y[nlinematched] = fwhm_y;
1869 gaussian_norm[nlinematched] = norm;
1870 diffx[nlinematched] =
x-xthe;
1871 diffy[nlinematched] =
y-ythe;
1882 lines_not_good_sn++;
1886 int xpix, ypix, rej;
1887 float flux, noise, sn;
1888 FILE* regfile = NULL;
1891 xpix =(int) rint(
x);
1892 ypix = (int)rint(
y);
1894 check( flux = cpl_image_get( pre->
data, xpix, ypix, &rej));
1895 check( noise = cpl_image_get( pre->
errs, xpix, ypix, &rej));
1897 sprintf( sn_name,
"bad_sn_%.3f.reg", da->
min_sn);
1898 regfile = fopen( sn_name,
"a");
1899 fprintf( regfile,
"point(%d,%d) #point=cross color=red font=\"helvetica 10 normal\""\
1900 " text={%.3f [%.3f}\n", xpix, ypix, lambda, sn);
1906 lines_not_gauss_fit++;
1912 lines_not_in_image++;
1922 for (i=1; i<nlinematched; i++) {
1923 xsh_msg_dbg_high(
"filter 7 pinhole : line %d : lambda %f order %f slit %f",
1924 i, vlambdadata[i], vorderdata[i], vsdata[i]);
1926 if (vlambdadata[i]!=vlambdadata[i-1] || vorderdata[i]!=vorderdata[i-1] || i==nlinematched-1) {
1929 if (i==nlinematched-1) {
1933 starti, i, i-starti);
1935 if (i-starti>=min_slit_match) {
1936 for (k=starti; k<=i-1; k++) {
1939 for (j=starti; j<=i-1; j++) {
1941 diffxmean[k]+=diffx[j];
1942 diffymean[k]+=diffy[j];
1945 diffxmean[k]/=(float)(i-starti-1);
1946 diffymean[k]/=(float)(i-starti-1);
1948 for (k=starti; k<=i-1; k++) {
1951 for (j=starti; j<=i-1; j++) {
1953 diffysig[k]+=(diffy[j]-diffymean[k])*(diffy[j]-diffymean[k]);
1954 diffxsig[k]+=(diffx[j]-diffxmean[k])*(diffx[j]-diffxmean[k]);
1957 diffxsig[k]=sqrt(diffxsig[k]/(
float)(i-starti-1));
1958 diffysig[k]=sqrt(diffysig[k]/(
float)(i-starti-1));
1960 for (j=starti; j<=i-1; j++) {
1963 vlambdadata[newi] = vlambdadata[j];
1964 vorderdata[newi] = vorderdata[j];
1965 vsdata[newi] =vsdata[j];
1966 vsindexdata[newi] = vsindexdata[j];
1967 vxthedata[newi] =vxthedata[j];
1968 vythedata[newi] =vythedata[j];
1969 corr_x[newi] = corr_x[j];
1970 corr_y[newi] = corr_y[j];
1971 gaussian_pos_x[newi] = gaussian_pos_x[j];
1972 gaussian_pos_y[newi] = gaussian_pos_y[j];
1973 gaussian_sigma_x[newi] = gaussian_sigma_x[j];
1974 gaussian_sigma_y[newi] = gaussian_sigma_y[j];
1975 gaussian_fwhm_x[newi] = gaussian_fwhm_x[j];
1976 gaussian_fwhm_y[newi] = gaussian_fwhm_y[j];
1977 gaussian_norm[newi] = gaussian_norm[j];
1978 diffx[newi] = diffx[j];
1979 diffy[newi] = diffy[j];
1989 lines_too_few_ph+=i-starti;
1997 xsh_msg(
"nlinematched / sol_size = %d / %d", nlinematched, sol_size);
1998 assure(nlinematched > 0, CPL_ERROR_ILLEGAL_INPUT,
2000 "detectarclines-search-win-hsize, "
2001 "detectarclines-fit-win-hsize=%d, "
2002 "detectarclines-running-median-hsize too large or too small "
2003 "or detectarclines-min-sn may be too large",
2010 xsh_msg_dbg_medium(
" %d lines detected in less than %d/9 ph positions", lines_too_few_ph,min_slit_match);
2011 check( gaussian_sigma_x_vect = cpl_vector_wrap( nlinematched, gaussian_sigma_x));
2012 check( gaussian_sigma_y_vect = cpl_vector_wrap( nlinematched, gaussian_sigma_y));
2013 check( gaussian_fwhm_x_vect = cpl_vector_wrap( nlinematched, gaussian_fwhm_x));
2014 check( gaussian_fwhm_y_vect = cpl_vector_wrap( nlinematched, gaussian_fwhm_y));
2015 xsh_msg(
"sigma gaussian median in x %lg",
2016 cpl_vector_get_median_const( gaussian_sigma_x_vect));
2017 xsh_msg(
"sigma gaussian median in y %lg",
2018 cpl_vector_get_median_const( gaussian_sigma_y_vect));
2020 xsh_msg(
"FWHM gaussian median in x %lg",
2021 cpl_vector_get_median_const( gaussian_fwhm_x_vect));
2022 xsh_msg(
"FWHM gaussian median in y %lg",
2023 cpl_vector_get_median_const( gaussian_fwhm_y_vect));
2035 if ( resid_tab_orders_frame != NULL){
2037 vsdata, vsndata,vsindexdata,
2038 vxthedata, vythedata,
2041 gaussian_pos_x, gaussian_pos_y,
2042 gaussian_sigma_x, gaussian_sigma_y,
2043 gaussian_fwhm_x, gaussian_fwhm_y,flag,
2044 wave_table, solution_type));
2047 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_ORDERS_",
2050 sprintf(rname,
"%s%s",rtag,
".fits");
2053 rname, instr,rtag));
2063 (wave_tab_frame != NULL)){
2070 vorderdata, vsdata, nlinematched, dac->
niter, dac->
frac,
2071 dac->
sigma, rejected));
2073 for(i=0; i< nlinematched; i++){
2074 if (rejected[i] == 1){
2079 vxthedata[i-nb_rejected] = vxthedata[i];
2080 vythedata[i-nb_rejected] = vythedata[i];
2081 vsindexdata[i-nb_rejected] = vsindexdata[i];
2082 corr_x[i-nb_rejected] = corr_x[i];
2083 corr_y[i-nb_rejected] = corr_y[i];
2084 gaussian_pos_x[i-nb_rejected] = gaussian_pos_x[i];
2085 gaussian_pos_y[i-nb_rejected] = gaussian_pos_y[i];
2086 gaussian_sigma_x[i-nb_rejected] = gaussian_sigma_x[i];
2087 gaussian_sigma_y[i-nb_rejected] = gaussian_sigma_y[i];
2088 gaussian_fwhm_x[i-nb_rejected] = gaussian_fwhm_x[i];
2089 gaussian_fwhm_y[i-nb_rejected] = gaussian_fwhm_y[i];
2090 gaussian_norm[i-nb_rejected] = gaussian_norm[i];
2091 diffx[i-nb_rejected] = diffx[i];
2094 nlinematched = nlinematched-nb_rejected;
2098 nlinematched, diffx,
2100 vlambdadata, vorderdata, vsdata, fit2dx));
2103 sprintf(wave_table_name,
"%s%s.fits",
"WAVE_TAB_GUESS_",
2113 vlambdadata, vorderdata, vsdata, nlinematched, dac->
niter, dac->
frac,
2114 dac->
sigma, rejected));
2116 for(i=0; i< nlinematched; i++){
2117 if (rejected[i] == 1){
2122 vxthedata[i-nb_rejected] = vxthedata[i];
2123 vythedata[i-nb_rejected] = vythedata[i];
2124 vsindexdata[i-nb_rejected] = vsindexdata[i];
2125 corr_x[i-nb_rejected] = corr_x[i];
2126 corr_y[i-nb_rejected] = corr_y[i];
2127 gaussian_pos_x[i-nb_rejected] = gaussian_pos_x[i];
2128 gaussian_sigma_x[i-nb_rejected] = gaussian_sigma_x[i];
2129 gaussian_sigma_y[i-nb_rejected] = gaussian_sigma_y[i];
2130 gaussian_fwhm_x[i-nb_rejected] = gaussian_fwhm_x[i];
2131 gaussian_fwhm_y[i-nb_rejected] = gaussian_fwhm_y[i];
2134 nlinematched = nlinematched-nb_rejected;
2138 &wave_table->
min_x, &wave_table->
max_x, vlambdadata, vorderdata,
2141 sprintf(wave_table_name,
"%s%s.fits",
"WAVE_TAB_2D_",
2151 xsh_msg(
"nlinecat=%d",nlinecat);
2158 vsdata,nlinematched));
2161 wave_table_name,wave_table_tag));
2163 check( cpl_frame_set_tag( *wave_tab_frame, wave_table_tag));
2171 xsh_msg(
"nlinecat=%d",nlinecat);
2176 if(strcmp(rec_id,
"xsh_predict") == 0) {
2181 sprintf(fname,
"%s%s",tag,
".fits");
2188 vsdata,vsndata,vsindexdata,vxthedata,vythedata,
2189 corr_x,corr_y,gaussian_norm,
2190 gaussian_pos_x,gaussian_pos_y,
2191 gaussian_sigma_x, gaussian_sigma_y,
2192 gaussian_fwhm_x, gaussian_fwhm_y,flag,
2193 wave_table,solution_type));
2195 if(resid_tab_name_sw) {
2196 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_DRL_LINES_",
2199 sprintf(rtag,
"%s%s%s",type,
"RESID_TAB_LINES_",
2202 check( tag = cpl_frame_get_tag( frame));
2207 sprintf(rname,
"AFC_CAL_%s%s",rtag,
".fits") ;
2210 sprintf(rname,
"AFC_ATT_%s%s",rtag,
".fits") ;
2213 sprintf(rname,
"%s%s",rtag,
".fits") ;
2216 if(clean_tmp || resid_tab_name_sw) {
void xsh_arclist_lambda_sort(xsh_arclist *list)
sort arcline list by increasing lambda
void xsh_arclist_clean_from_list_not_flagged(xsh_arclist *list, double *lambda, int *flag, int size)
float xsh_arclist_get_wavelength(xsh_arclist *list, int idx)
get wavelength of a line in the arcline list
void xsh_arclist_clean_from_list(xsh_arclist *list, double *lambda, int size)
Clean an arclist according to a list of valid lambda.
void xsh_arclist_free(xsh_arclist **list)
free memory associated to a arclist
int xsh_arclist_get_size(xsh_arclist *list)
get size of arcline list
void xsh_arclist_reject(xsh_arclist *list, int idx)
reject a line from the list
xsh_arclist * xsh_arclist_load(cpl_frame *frame)
load an arcline list frame in arclist structure
cpl_propertylist * xsh_arclist_get_header(xsh_arclist *list)
get header of the table
cpl_frame * xsh_arclist_save(xsh_arclist *list, const char *filename, const char *tag)
save a arclist to a frame
int xsh_order_list_get_index_by_absorder(xsh_order_list *list, double absorder)
xsh_order_list * xsh_order_list_load(cpl_frame *frame, xsh_instrument *instr)
load an order list from a frame
void xsh_order_list_free(xsh_order_list **list)
free memory associated to an order_list
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
int xsh_pre_window_best_median_flux_pos(xsh_pre *pre, int xcen, int ycen, int search_window_hsize, int running_median_hsize, int *xadj, int *yadj)
Search pixel position of best running median flux in the search window.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
void xsh_resid_tab_free(xsh_resid_tab **resid)
Free memory associated to a resid_tab.
xsh_resid_tab * xsh_resid_tab_create(int size, double *lambda, double *order, double *slit, double *sn, int *slit_index, double *thpre_x, double *thpre_y, double *corr_x, double *corr_y, double *gaussian_norm, double *gaussian_fit_x, double *gaussian_fit_y, double *gaussian_sigma_x, double *gaussian_sigma_y, double *gaussian_fwhm_x, double *gaussian_fwhm_y, int *flag, xsh_wavesol *wavesol, int wavesol_type)
Create a residual tab structure.
xsh_resid_tab * xsh_resid_tab_create_not_flagged(int size, double *lambda, double *order, double *slit, double *sn, int *slit_index, double *thpre_x, double *thpre_y, double *corr_x, double *corr_y, double *gaussian_norm, double *gaussian_fit_x, double *gaussian_fit_y, double *gaussian_sigma_x, double *gaussian_sigma_y, double *gaussian_fwhm_x, double *gaussian_fwhm_y, int *flag, xsh_wavesol *wavesol, int wavesol_type)
cpl_frame * xsh_resid_tab_save(xsh_resid_tab *resid, const char *filename, xsh_instrument *instr, const char *tag)
Save a residual tab to a frame.
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
int xsh_the_map_get_slit_index(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
int xsh_the_map_get_order(xsh_the_map *list, int idx)
get order of the map list
int xsh_the_map_get_size(xsh_the_map *list)
get size of the map list
void xsh_the_map_lambda_order_slit_sort(xsh_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...
cpl_table * xsh_wavesol_trace(xsh_wavesol *wsol, double *lambda, double *order, double *slit, int size)
void xsh_wavesol_compute(xsh_wavesol *sol, int size, double *pos, double *posmin, double *posmax, double *lambda, double *order, double *slit, cpl_polynomial *result)
compute a wavelength solution
cpl_polynomial * xsh_wavesol_get_polx(xsh_wavesol *sol)
get the solution in X
xsh_wavesol * xsh_wavesol_load(cpl_frame *frame, xsh_instrument *instrument)
load a wavelength solution
double xsh_wavesol_eval_poly(xsh_wavesol *sol, double lambda, double order, double slit)
eval the polynomial solution in Y
xsh_wavesol * xsh_wavesol_create(cpl_frame *spectral_format_frame, xsh_detect_arclines_param *params, xsh_instrument *instrument)
Create a new wavelength solution structure.
cpl_polynomial * xsh_wavesol_get_poly(xsh_wavesol *sol)
get the solution in Y
void xsh_wavesol_free(xsh_wavesol **w)
free wavelength solution structure
double xsh_wavesol_eval_polx(xsh_wavesol *sol, double lambda, double order, double slit)
eval the polynomial solution in X
void xsh_wavesol_set_type(xsh_wavesol *wsol, enum wavesol_type type)
set the type of the wave table
cpl_propertylist * xsh_wavesol_get_header(xsh_wavesol *sol)
get header of the table
cpl_frame * xsh_wavesol_save(xsh_wavesol *w, cpl_table *trace, const char *filename, const char *tag)
save a wavelength solution
void xsh_detect_arclines_dan(cpl_frame *frame, cpl_frame *theo_tab_frame, cpl_frame *arc_lines_tab_frame, cpl_frame *wave_tab_guess_frame, cpl_frame *order_tab_recov_frame, cpl_frame *config_model_frame, cpl_frame *spectralformat_frame, cpl_frame **resid_tab_orders_frame, cpl_frame **arc_lines_clean_tab_frame, cpl_frame **wave_tab_frame, cpl_frame **resid_tab_frame, xsh_sol_wavelength solwave_type, xsh_detect_arclines_param *da, xsh_clipping_param *dac, xsh_instrument *instr, const char *rec_id, const int clean_tmp, const int resid_tab_name_sw)
detect the position on the detector of emission lines listed in a catalogue, from expected position v...
static int lines_filter_by_sn(xsh_pre *pre, double sn_ref, double x, double y, double *sn)
static void theo_tab_model(xsh_xs_3 *config_model, xsh_arclist *arclist, xsh_spectralformat_list *spectralformat_list, int *size, double **lambda, double **n, double **s, double **sn, int **s_index, double **xthe, double **ythe, xsh_instrument *instr, int nb_pinhole)
static void theo_tab_filter(xsh_the_map *the_tab, xsh_arclist *arclist, int *size, double **lambda, double **n, double **s, int **s_index, double **xthe, double **ythe, int nb_pinhole)
void xsh_detect_arclines(cpl_frame *frame, cpl_frame *theo_tab_frame, cpl_frame *arc_lines_tab_frame, cpl_frame *wave_tab_guess_frame, cpl_frame *order_tab_recov_frame, cpl_frame *config_model_frame, cpl_frame *spectralformat_frame, cpl_frame **resid_tab_orders_frame, cpl_frame **arc_lines_clean_tab_frame, cpl_frame **wave_tab_frame, cpl_frame **resid_tab_frame, xsh_sol_wavelength solwave_type, xsh_detect_arclines_param *da, xsh_clipping_param *dac, xsh_instrument *instr, const char *rec_id, const int clean_tmp, const int resid_tab_name_sw)
detect the position on the detector of emission lines listed in a catalogue, from expected position v...
static void data_wavesol_fit_with_sigma(xsh_wavesol *wavesol, double *A, double *lambda, double *n, double *s, int size, int max_iter, double min_frac, double sigma, int *rejected)
#define XSH_REGDEBUG(...)
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define assure(CONDITION, ERROR_CODE,...)
#define check_msg(COMMAND,...)
#define xsh_error_reset()
#define XSH_ASSURE_NOT_ILLEGAL_MSG(cond, msg)
#define XSH_ASSURE_NOT_NULL(pointer)
cpl_error_code xsh_image_find_barycenter(const cpl_image *im, int xpos, int ypos, int size, double *norm, double *xcen, double *ycen, double *sig_x, double *sig_y, double *fwhm_x, double *fwhm_y)
Apply a gaussian fit on an image sub window.
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
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.
#define xsh_msg_dbg_medium(...)
#define xsh_msg(...)
Print a message on info level.
#define xsh_msg_dbg_high(...)
const char * xsh_pfits_get_dpr_type(const cpl_propertylist *plist)
find out the DPR TECH
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
int xsh_pfits_get_nb_pinhole(const cpl_propertylist *plist)
Get the number of pinhole.
void xsh_pfits_set_qc_nlinecat(cpl_propertylist *plist, double value)
void xsh_pfits_set_qc_nlinecat_clean(cpl_propertylist *plist, double value)
void xsh_pfits_set_qc_nlinefound_clean(cpl_propertylist *plist, double value)
void xsh_pfits_set_qc_nlinefound(cpl_propertylist *plist, double value)
void xsh_unwrap_vector(cpl_vector **v)
Unwrap a vector and set the pointer to NULL.
void xsh_free_vector(cpl_vector **v)
Deallocate a vector and set the pointer to NULL.
int xsh_debug_level_get(void)
get 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.
void xsh_unwrap_array(cpl_array **a)
Unwrap an array and set the pointer to NULL.
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
xsh_find_center_method find_center_method
cpl_propertylist * data_header
#define XSH_ARC_LINE_LIST_2DMAP
#define XSH_WAVE_TAB_GUESS
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_ARC_LINE_LIST_PREDICT
#define WAVELENGTH_PRECISION
#define XSH_DETECT_ARCLINES_MODE_RECOVER
#define XSH_DETECT_ARCLINES_MODE_NORMAL
#define XSH_DETECT_ARCLINES_TYPE_POLY
#define XSH_DETECT_ARCLINES_MODE_CORRECTED
#define XSH_DETECT_ARCLINES_TYPE_MODEL
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
cpl_error_code xsh_model_temperature_update_structure(struct xs_3 *p_xs_3_config, cpl_frame *ref_frame, xsh_instrument *instrument)
#define XSH_FREE(POINTER)
#define XSH_MALLOC(POINTER, TYPE, SIZE)
#define XSH_CALLOC(POINTER, TYPE, SIZE)