150 #include <uves_wavecal_identify.h>
152 #include <uves_wavecal_utils.h>
153 #include <uves_utils.h>
154 #include <uves_utils_wrappers.h>
155 #include <uves_error.h>
156 #include <uves_msg.h>
158 #include <uves_qclog.h>
167 const cpl_table *linetable,
169 double red_chisq,cpl_table* qclog);
176 const cpl_table *line_refer,
180 cpl_table **selected,
181 int degree,
bool verbose,
235 const cpl_table *line_refer,
237 int DEGREE,
double TOLERANCE,
238 double ALPHA,
double MAXERROR,
240 const int trace,
const int window,cpl_table* qclog)
251 cpl_table *selected = NULL;
254 passure( linetable != NULL,
" ");
255 passure( line_refer != NULL,
" ");
256 passure( guess_dispersion != NULL,
" ");
258 assure( 0 < ALPHA && ALPHA <= 1, CPL_ERROR_ILLEGAL_INPUT,
259 "Illegal alpha = %e", ALPHA);
263 cpl_table_new_column(linetable, LINETAB_LAMBDAC , CPL_TYPE_DOUBLE);
264 cpl_table_new_column(linetable,
"dLambdaC" , CPL_TYPE_DOUBLE);
265 cpl_table_new_column(linetable, LINETAB_PIXELSIZE , CPL_TYPE_DOUBLE);
266 cpl_table_new_column(linetable, LINETAB_RESIDUAL , CPL_TYPE_DOUBLE);
267 cpl_table_new_column(linetable,
"Residual_pix" , CPL_TYPE_DOUBLE);
268 cpl_table_new_column(linetable,
"Lambda_candidate" , CPL_TYPE_DOUBLE);
269 cpl_table_new_column(linetable,
"dLambda_candidate", CPL_TYPE_DOUBLE);
270 cpl_table_new_column(linetable,
"dLambda_cat_sq" , CPL_TYPE_DOUBLE);
271 cpl_table_new_column(linetable,
"dLambda_nn_sq" , CPL_TYPE_DOUBLE);
275 cpl_table_new_column(linetable,
"Ident", CPL_TYPE_DOUBLE);
276 cpl_table_new_column(linetable,
"dIdent",CPL_TYPE_DOUBLE);
277 cpl_table_set_column_invalid(linetable,
"Ident", 0, cpl_table_get_nrow(linetable));
278 cpl_table_set_column_invalid(linetable,
"dIdent",0, cpl_table_get_nrow(linetable));
282 "Error applying dispersion relation");
287 for (idloop = 2; idloop <= 2; idloop += 1)
289 for (idloop = 1; idloop <= 2; idloop += 1)
299 bool reject = (idloop == 2);
304 previous_id = current_id;
309 "Error identifying lines");
315 "Error during point pattern matching");
317 cpl_table_erase_column(linetable,
"Ident");
318 cpl_table_duplicate_column(linetable,
"Ident", linetable,
"Ident_ppm");
319 current_id = nident_ppm;
323 cpl_table_fill_column_window(linetable,
"dIdent",
324 0, cpl_table_get_nrow(linetable),
325 cpl_table_get_column_mean(linetable,
"dIdent"));
342 &dispersion_variance,
346 "Could not perform global calibration");
351 uves_msg(
"%d identifications made. RMS = %.5f wlu = %.3f "
352 "pixels (no rejection)",
353 current_id, rms_wlu, rms_pixels);
361 uves_msg(
"%d identifications made. RMS = %.5f wlu = %.3f "
362 "pixels (%f %s rejection, kappa = %.1f)",
363 current_id, rms_wlu, rms_pixels,
364 fabs(TOLERANCE), (TOLERANCE > 0) ?
"pixels" :
"wlu",
368 sprintf(qc_key,
"QC TRACE%d WIN%d NLINID%d",trace,window,idloop);
370 "ThAr lamp identified lines",
374 uves_msg(
"%d identifications from point pattern matching",
378 assure( rms_pixels < MAXERROR, CPL_ERROR_CONTINUE,
379 "Wavelength calibration did not converge. "
380 "After %d iterations the RMS was %f pixels. "
381 "Try to improve on the initial solution", n, rms_pixels);
387 "Error applying dispersion relation");
391 while (current_id > previous_id) ;
393 sprintf(qc_key,
"QC TRACE%d WIN%d NLINID NITERS",trace,window);
395 "Number of iterations",
406 uves_msg(
"Identification loop converged. Resetting identifications");
407 cpl_table_set_column_invalid(linetable,
"Ident", 0,
408 cpl_table_get_nrow(linetable));
416 uves_free_table(&selected);
425 &dispersion_variance,
427 "Could not perform global calibration");
432 "Error applying dispersion relation");
442 cpl_table_new_column(linetable,
"NLinSol", CPL_TYPE_INT);
443 cpl_table_new_column(linetable,
"Select", CPL_TYPE_INT);
445 cpl_table_fill_column_window_int(linetable,
"NLinSol",
446 0, cpl_table_get_nrow(linetable),
448 cpl_table_fill_column_window_int(linetable,
"Select",
449 0, cpl_table_get_nrow(linetable),
453 for (i = 0; i < cpl_table_get_nrow(selected); i++) {
454 int order = cpl_table_get_int(selected,
"Order", i, NULL);
455 double x = cpl_table_get_double(selected,
"X", i, NULL);
460 passure( j < cpl_table_get_nrow(linetable),
"%d %" CPL_SIZE_FORMAT
"",
461 j, cpl_table_get_nrow(linetable));
463 order2 = cpl_table_get_int(linetable,
"Order", j, NULL);
464 x2 = cpl_table_get_double(linetable,
"X", j, NULL);
465 if (cpl_table_is_valid(linetable,
"Ident", j))
467 cpl_table_set_int(linetable,
"Select", j, 1);
471 }
while (order2 < order || x2 < x - 0.1);
473 passure( order2 == order && fabs(x2 - x) < 0.1,
474 "%d %d %g %g", order2, order, x2, x);
476 cpl_table_set_int(linetable,
"NLinSol", j-1, 1);
482 "Error verifying calibration");
485 uves_free_table(&selected);
487 return dispersion_relation;
505 static cpl_error_code
507 const cpl_table *linetable,
double TOLERANCE,
508 double red_chisq, cpl_table* qclog)
510 cpl_table *brightest = NULL;
511 double median_intensity;
523 check(( mean = cpl_table_get_column_mean (selected, LINETAB_RESIDUAL),
524 stdev= cpl_table_get_column_stdev(selected, LINETAB_RESIDUAL),
525 rms_wlu = sqrt(mean*mean + stdev*stdev),
527 mean = cpl_table_get_column_mean (selected,
"Residual_pix"),
528 stdev= cpl_table_get_column_stdev(selected,
"Residual_pix"),
529 rms_pixels = sqrt(mean*mean + stdev*stdev)),
530 "Error reading RMS of fit");
532 rms_speed=rms_wlu * SPEED_OF_LIGHT/
533 cpl_table_get_column_mean(selected,LINETAB_LAMBDAC);
534 uves_msg(
"%" CPL_SIZE_FORMAT
" lines accepted", cpl_table_get_nrow(selected));
535 uves_msg(
"Average RMS of calibration (tolerance = %.3f %s) = %.5f wlu = %.4f pixels ~ %.1f m/s",
537 (TOLERANCE > 0) ?
"pixels" :
"wlu",
538 rms_wlu, rms_pixels, rms_speed);
540 sprintf(qc_key,
"QC LINE RESIDRMS WLU");
542 "Line ID RMS TRACE0 WIN2 [Angstrom]",
544 sprintf(qc_key,
"QC LINE RESIDRMS PIX");
546 "Line ID RMS TRACE0 WIN2 [pix]",
548 sprintf(qc_key,
"QC LINE RESIDRMS SPEED");
550 "Line ID RMS TRACE0 WIN2 [m/s]",
554 uves_msg(
"Reduced chi^2 of calibration = %f", red_chisq);
555 sprintf(qc_key,
"QC LINE IDCHI2");
557 "Reduced chi^2 of line ID TRACE0 WIN2",
571 check(( median_intensity = cpl_table_get_column_median(linetable,
"Peak"),
572 brightest = uves_extract_table_rows(linetable,
"Peak",
575 ninvalid = cpl_table_count_invalid(brightest,
"Ident")),
576 "Error counting identifications");
578 ratio = 1 - ((double) ninvalid)/cpl_table_get_nrow(brightest);
579 uves_msg(
"Percentage of identifications among the half brighter lines : %.2f %%",
582 sprintf(qc_key,
"QC LINE HALFBRIG");
584 "Half brighter lines frac TRACE0 WIN2",
588 uves_free_table(&brightest);
590 return cpl_error_get_code();
608 static cpl_error_code
615 bool printed_warning =
false;
618 passure(linetable != NULL,
" ");
619 passure(dispersion_relation != NULL,
" ");
626 passure(cpl_table_has_column(linetable,
"X") ,
" ");
627 passure(cpl_table_has_column(linetable,
"Order") ,
" ");
628 passure(cpl_table_has_column(linetable,
"Ident") ,
" ");
630 passure(cpl_table_has_column(linetable, LINETAB_LAMBDAC) ,
" ");
632 passure(cpl_table_has_column(linetable,
"dLambdaC") ,
" ");
633 passure(cpl_table_has_column(linetable,
"dIdent") ,
" ");
634 passure(cpl_table_has_column(linetable, LINETAB_RESIDUAL),
" ");
635 passure(cpl_table_has_column(linetable,
"Residual_pix"),
" ");
636 passure(cpl_table_has_column(linetable, LINETAB_PIXELSIZE) ,
" ");
640 for(i = 0; i < cpl_table_get_nrow(linetable); i++)
644 double lambdac, dlambdac, pixelsize;
645 order = cpl_table_get_int(linetable,
"Order", i, NULL);
647 x = cpl_table_get_double(linetable,
"X", i, NULL);
658 if (!printed_warning && verbose) {
660 "(x, order) = (%f, %d)", x, order);
661 printed_warning =
true;
665 "(x, order) = (%f, %d)", x, order);
668 pixelsize = dfdx / order;
670 check(( cpl_table_set_double(linetable, LINETAB_LAMBDAC , i, lambdac),
671 cpl_table_set_double(linetable, LINETAB_PIXELSIZE, i, pixelsize)),
672 "Error writing table");
674 if (dispersion_variance != NULL)
682 cpl_table_set_double(linetable,
"dLambdaC" , i, dlambdac);
690 cpl_table_set_double(linetable,
"dLambdaC" , i, 1.0);
694 if (cpl_table_is_valid(linetable,
"Ident", i))
696 double ident = cpl_table_get_double(linetable,
"Ident", i, NULL);
697 cpl_table_set_double(linetable, LINETAB_RESIDUAL, i,
699 cpl_table_set_double(linetable,
"Residual_pix", i,
700 (ident - lambdac)/pixelsize);
704 cpl_table_set_invalid(linetable, LINETAB_RESIDUAL, i);
705 cpl_table_set_invalid(linetable,
"Residual_pix", i);
710 check( uves_sort_table_2(linetable,
"Order",
"X",
false,
false),
711 "Error sorting table");
714 return cpl_error_get_code();
760 int number_identifications = 0;
764 int *histogram = NULL;
765 const double minlog = -5.0;
768 const double maxlog = 15.0;
769 const int nbins = 400;
772 double average_dlambda_com = 0;
776 passure( linetable != NULL,
" ");
778 passure( cpl_table_has_column(linetable, LINETAB_LAMBDAC ),
" ");
780 passure( cpl_table_has_column(linetable,
"dLambdaC" ),
" ");
782 passure( cpl_table_has_column(linetable,
"X" ),
" ");
784 passure( cpl_table_has_column(linetable,
"Order" ),
" ");
786 passure( cpl_table_has_column(linetable,
"Xwidth" ),
" ");
787 passure( cpl_table_has_column(linetable, LINETAB_PIXELSIZE),
" ");
790 passure( cpl_table_has_column(linetable,
"Ident" ),
" ");
792 passure( cpl_table_has_column(linetable,
"dIdent" ),
" ");
796 passure( line_refer != NULL,
" ");
797 passure( cpl_table_has_column(line_refer,
"Wave" ),
" ");
798 passure( cpl_table_has_column(line_refer,
"dWave"),
" ");
801 linetable_size = cpl_table_get_nrow(linetable);
802 linerefer_size = cpl_table_get_nrow(line_refer);
803 assure(linerefer_size >= 1, CPL_ERROR_ILLEGAL_INPUT,
"Empty line reference table");
806 passure( 0 < ALPHA && ALPHA <= 1,
"%e", ALPHA);
809 average_dlambda_com = cpl_table_get_column_median(linetable,
"dLambdaC");
812 histogram = cpl_calloc(nbins,
sizeof(
int));
819 for (row = 0; row < linetable_size; row++) {
825 double lambda_cat_sigma;
826 double distance_cat_sq;
827 double nn_distance_sq;
831 lambda_com = cpl_table_get_double(linetable, LINETAB_LAMBDAC , row, NULL);
832 order = cpl_table_get_int (linetable,
"Order" , row, NULL);
836 cpl_table_get_double(linetable,
"Xwidth" , row, NULL) *
837 fabs(cpl_table_get_double(linetable, LINETAB_PIXELSIZE , row, NULL));
840 line_fwhm = TWOSQRT2LN2 * line_width;
844 line_refer, lambda_com, 0, linerefer_size - 1);
845 lambda_cat = cpl_table_get_double(line_refer,
"Wave", row_cat, NULL);
846 lambda_cat_sigma = cpl_table_get_double(line_refer,
"dWave",row_cat, NULL);
849 distance_cat_sq = (lambda_com - lambda_cat)*(lambda_com - lambda_cat);
856 double lambda_com_prev, lambda_com_next;
857 int order_prev, order_next;
858 double lambda_cat_prev, lambda_cat_next;
860 nn_distance_sq = DBL_MAX;
865 order_prev = cpl_table_get_int (
866 linetable,
"Order" , row - 1, NULL);
867 lambda_com_prev = cpl_table_get_double(
868 linetable, LINETAB_LAMBDAC, row - 1, NULL);
870 if (order == order_prev)
872 nn_distance_sq = uves_min_double(nn_distance_sq,
873 (lambda_com_prev - lambda_com)*
874 (lambda_com_prev - lambda_com)
879 if (row <= linetable_size - 2)
881 order_next = cpl_table_get_int (linetable,
"Order",
883 lambda_com_next = cpl_table_get_double(linetable, LINETAB_LAMBDAC,
886 if (order == order_next)
888 nn_distance_sq = uves_min_double(nn_distance_sq,
889 (lambda_com_next - lambda_com)*
890 (lambda_com_next - lambda_com)
898 lambda_cat_prev = cpl_table_get_double(
899 line_refer,
"Wave", row_cat - 1, NULL);
901 nn_distance_sq = uves_min_double(
903 (lambda_cat_prev - lambda_cat)*
904 (lambda_cat_prev - lambda_cat)
907 if (row_cat <= linerefer_size - 2)
909 lambda_cat_next = cpl_table_get_double(
910 line_refer,
"Wave", row_cat + 1, NULL);
912 nn_distance_sq = uves_min_double(
914 (lambda_cat_next - lambda_cat)*
915 (lambda_cat_next - lambda_cat)
921 if (nn_distance_sq < DBL_MAX)
923 nn_distance_sq *= ALPHA*ALPHA;
929 cpl_table_set_double(linetable,
"Lambda_candidate", row, lambda_cat);
930 cpl_table_set_double(linetable,
"dLambda_candidate",row, lambda_cat_sigma);
931 cpl_table_set_double(linetable,
"dLambda_cat_sq", row, distance_cat_sq);
932 cpl_table_set_double(linetable,
"dLambda_nn_sq", row, nn_distance_sq);
937 int ilow = uves_round_double((0.5*log(distance_cat_sq/(line_fwhm*line_fwhm))
938 - minlog)/(maxlog - minlog) * nbins);
939 int ihigh = uves_round_double((0.5*log(nn_distance_sq /(line_fwhm*line_fwhm))
940 - minlog)/(maxlog - minlog) * nbins);
943 for (i = uves_max_int(ilow, 0); i < uves_min_int(ihigh, nbins); i++)
954 for (i = 0; i < nbins; i++)
957 if (histogram[i] > maxfreq)
959 maxfreq = histogram[i];
960 error = exp( i / ((
double)nbins) * (maxlog - minlog) + minlog ) ;
999 for (row = 0; row < linetable_size; row++)
1001 double distance_cat_sq;
1002 double nn_distance_sq;
1003 double tolerance_sq;
1008 double lambda_cat_sigma;
1010 lambda_cat = cpl_table_get_double(linetable,
"Lambda_candidate", row, NULL);
1011 lambda_cat_sigma = cpl_table_get_double(linetable,
"dLambda_candidate", row, NULL);
1021 uves_max_double(1, cpl_table_get_double(linetable,
"Xwidth" , row, NULL)) *
1022 fabs(cpl_table_get_double(linetable, LINETAB_PIXELSIZE , row, NULL));
1025 line_fwhm = TWOSQRT2LN2 * line_width;
1037 dlambda_com = line_fwhm
1038 * cpl_table_get_double(linetable,
"dLambdaC" , row, NULL)
1039 / average_dlambda_com;
1041 tolerance_sq = line_fwhm*line_fwhm * error*error;
1043 distance_cat_sq = cpl_table_get_double(linetable,
"dLambda_cat_sq", row, NULL);
1044 nn_distance_sq = cpl_table_get_double(linetable,
"dLambda_nn_sq" , row, NULL);
1046 #if WANT_BIG_LOGFILE
1048 "dist_cat = %f (%f pixels) tolerance = %.3f error = %f "
1049 "nn = %f (%f pixels)",
1050 cpl_table_get_int (linetable,
"Order" , row, NULL),
1051 cpl_table_get_double(linetable,
"X" , row, NULL),
1052 cpl_table_get_double(linetable, LINETAB_LAMBDAC, row, NULL),
1055 sqrt(distance_cat_sq),
1056 sqrt(distance_cat_sq)
1057 /cpl_table_get_double(linetable, LINETAB_PIXELSIZE, row, NULL),
1060 sqrt(nn_distance_sq),
1061 sqrt(nn_distance_sq)
1062 /cpl_table_get_double(linetable, LINETAB_PIXELSIZE, row, NULL));
1066 if (distance_cat_sq < (dlambda_com)*(dlambda_com)
1067 && tolerance_sq < nn_distance_sq
1068 && distance_cat_sq < nn_distance_sq)
1070 number_identifications++;
1071 cpl_table_set_double(linetable,
"Ident", row, lambda_cat);
1072 cpl_table_set_double(linetable,
"dIdent",row, lambda_cat_sigma);
1073 #if WANT_BIG_LOGFILE
1079 if (cpl_table_is_valid(linetable,
"Ident", row)) {
1080 number_identifications++;
1082 uves_msg_debug(
"Line at (%d,%f) does not match ID criterion anymore",
1083 cpl_table_get_int (linetable,
"Order", row, NULL),
1084 cpl_table_get_double(linetable,
"X", row, NULL)
1091 cpl_free(histogram);
1092 return number_identifications;
1124 cpl_table **selected,
1125 int degree,
bool verbose,
1129 double *red_chisq,
polynomial **dispersion_variance,
1135 cpl_table *identified = NULL;
1137 cpl_table_get_nrow(linetable) -
1138 cpl_table_count_invalid(linetable,
"Ident");
1141 passure( (pixelsize == NULL) == (rms_wlu == NULL) &&
1142 (pixelsize == NULL) == (rms_pixels == NULL),
" ");
1144 assure( degree < 0 ||
1145 valid_ids >= (degree + 1)*(degree + 1), CPL_ERROR_ILLEGAL_INPUT,
1146 "There are not enough identifications to create a %d.-degree global fit. "
1147 "%d needed. %d found", degree, (degree + 1)*(degree + 1), valid_ids);
1149 identified = cpl_table_duplicate(linetable);
1156 uves_msg_debug(
"%d lines rejected %f %f", rejected, TOLERANCE, kappa);
1160 check( uves_erase_invalid_table_rows(identified,
"Ident"),
1161 "Error erasing un-identified lines");
1166 check(( cpl_table_duplicate_column(identified,
"Aux", identified,
"Ident"),
1167 cpl_table_multiply_columns(identified,
"Aux",
"Order"),
1170 cpl_table_duplicate_column(identified,
"dAux", identified,
"dIdent"),
1171 cpl_table_multiply_columns(identified,
"dAux",
"Order")),
1172 "Error setting up temporary table");
1177 check( dispersion_relation =
1179 "X",
"Order",
"Aux",
1191 dispersion_variance,
1192 reject ? kappa : -1, -1),
1193 "Error fitting polynomial. Possible cause: too few (%d) "
1194 "line identifications", valid_ids);
1198 double min_rms = -1;
1199 double min_reject = -1;
1200 check( dispersion_relation =
1202 "X",
"Order",
"Aux",
1207 dispersion_variance,
1208 reject ? kappa : -1,
1209 max_degree, max_degree,
1210 min_rms, min_reject,
1212 NULL, NULL, 0, NULL),
1213 "Error fitting polynomial. Possible cause: too few (%d) "
1214 "line identifications", valid_ids);
1217 if (pixelsize != NULL)
1223 "Error applying dispersion relation");
1225 *pixelsize = cpl_table_get_column_median(identified, LINETAB_PIXELSIZE);
1226 *rms_wlu = cpl_table_get_column_stdev (identified, LINETAB_RESIDUAL);
1227 *rms_pixels= cpl_table_get_column_stdev (identified,
"Residual_pix");
1230 if (selected != NULL) {
1231 *selected = cpl_table_duplicate(identified);
1235 uves_free_table(&identified);
1236 if (cpl_error_get_code() != CPL_ERROR_NONE)
1241 return dispersion_relation;
1259 int minorder, maxorder;
1261 cpl_table *lt_order = NULL;
1262 cpl_table *refer_order = NULL;
1263 cpl_vector *peaks = NULL;
1264 cpl_vector *lines = NULL;
1265 cpl_bivector *ids = NULL;
1267 assure( cpl_table_has_column(linetable, LINETAB_LAMBDAC), CPL_ERROR_DATA_NOT_FOUND,
1268 "Missing column %s", LINETAB_LAMBDAC);
1270 assure( cpl_table_has_column(linetable, LINETAB_PIXELSIZE), CPL_ERROR_DATA_NOT_FOUND,
1271 "Missing column %s", LINETAB_PIXELSIZE);
1273 assure( cpl_table_has_column(linetable,
"Order"), CPL_ERROR_DATA_NOT_FOUND,
1274 "Missing column %s",
"Order");
1276 minorder = uves_round_double( cpl_table_get_column_min(linetable,
"Order"));
1277 maxorder = uves_round_double( cpl_table_get_column_max(linetable,
"Order"));
1280 if (cpl_table_has_column(linetable,
"Ident_ppm"))
1282 cpl_table_erase_column(linetable,
"Ident_ppm");
1285 cpl_table_new_column(linetable,
"Ident_ppm", CPL_TYPE_DOUBLE);
1287 for (order = minorder; order <= maxorder; order++)
1289 const double tolerance = 0.05;
1290 double min_lambda, max_lambda;
1291 double min_disp, max_disp;
1295 uves_free_table(<_order);
1296 lt_order = uves_extract_table_rows(linetable,
"Order",
1297 CPL_EQUAL_TO, order);
1299 check_nomsg((min_lambda = cpl_table_get_column_min(lt_order, LINETAB_LAMBDAC),
1300 max_lambda = cpl_table_get_column_max(lt_order, LINETAB_LAMBDAC),
1301 min_disp = cpl_table_get_column_min(lt_order, LINETAB_PIXELSIZE)*0.99,
1302 max_disp = cpl_table_get_column_max(lt_order, LINETAB_PIXELSIZE)*1.01));
1304 uves_free_table(&refer_order);
1305 refer_order = uves_extract_table_rows(line_refer,
"Wave", CPL_GREATER_THAN,
1307 uves_extract_table_rows_local(refer_order,
"Wave", CPL_LESS_THAN,
1313 uves_free_vector(&peaks);
1314 peaks = cpl_vector_new(cpl_table_get_nrow(lt_order));
1315 for (i = 0; i < cpl_vector_get_size(peaks); i++)
1317 cpl_vector_set(peaks, i, cpl_table_get_double(lt_order,
"X", i, NULL));
1320 uves_free_vector(&lines);
1321 lines = cpl_vector_new(cpl_table_get_nrow(refer_order));
1322 for (i = 0; i < cpl_vector_get_size(lines); i++)
1324 cpl_vector_set(lines, i, cpl_table_get_double(refer_order,
"Wave", i, NULL));
1329 cpl_vector_sort(peaks, 1);
1330 cpl_vector_sort(lines, 1);
1332 uves_msg_debug(
"Call ppm with %" CPL_SIZE_FORMAT
" peaks, %" CPL_SIZE_FORMAT
" lines, dispersion range = %f - %f A/pixel",
1333 cpl_vector_get_size(peaks),
1334 cpl_vector_get_size(lines),
1335 min_disp, max_disp);
1337 uves_free_bivector(&ids);
1339 ids = cpl_ppm_match_positions(peaks, lines,
1348 if (cpl_error_get_code() != CPL_ERROR_NONE)
1351 cpl_error_get_where());
1359 uves_msg_debug(
"%" CPL_SIZE_FORMAT
" identifications from point pattern matching (order %d)",
1360 cpl_bivector_get_size(ids), order);
1362 result += cpl_bivector_get_size(ids);
1364 for (i = 0; i < cpl_table_get_nrow(linetable); i++) {
1366 if (cpl_table_get_int(linetable,
"Order", i, NULL) == order)
1367 for (j = 0; j < cpl_bivector_get_size(ids); j++)
1369 if (fabs(cpl_table_get_double(linetable,
"X", i, NULL) -
1370 cpl_bivector_get_x_data(ids)[j]) < 0.001)
1371 cpl_table_set_double(linetable,
"Ident_ppm", i,
1372 cpl_bivector_get_y_data(ids)[j]);
1379 uves_free_table(<_order);
1380 uves_free_table(&refer_order);
1381 uves_free_vector(&peaks);
1382 uves_free_vector(&lines);
1383 uves_free_bivector(&ids);