32 #include <fors_std_star.h>
33 #include <fors_utils.h>
34 #include <fors_instrument.h>
40 const char *
const FORS_STD_CAT_COLUMN_RA =
"RA";
41 const char *
const FORS_STD_CAT_COLUMN_DEC =
"DEC";
42 const char *
const FORS_STD_CAT_COLUMN_NAME =
"OBJECT";
51 fors_std_cat_propagate_uncorrelated_inputs(
const double *in,
53 const double *jacobi_A,
54 const double *jacobi_B,
63 fors_std_cat_import_generic_star(
const double *band_values,
64 const double *band_errors,
73 double *cov_catmag_color);
76 fors_std_cat_check_band_support( cpl_error_code (*import_func)(
89 fors_std_cat_determine_required_columns( cpl_error_code (*import_func)(
101 static cpl_error_code
102 fors_std_cat_reject_not_required_columns( cpl_array *column_names,
103 cpl_error_code (*import_func)(
115 fors_std_cat_table_check_columns(
const cpl_table *cat_table,
116 const cpl_array *columns);
119 fors_std_cat_create_error_column_names(
const cpl_array *colnames);
121 static cpl_error_code
122 fors_std_cat_landolt_star_import(
double v_bv_ub_vr_vi[5],
123 double ERR_v_bv_ub_vr_vi[5],
129 double *cov_catmag_color);
132 fors_std_cat_landolt_get_column_names(
void);
134 static cpl_error_code
135 fors_std_cat_stetson_star_import(
double u_b_v_r_i[5],
136 double ERR_u_b_v_r_i[5],
142 double *cov_catmag_color);
145 fors_std_cat_stetson_get_column_names(
void);
148 fors_std_cat_check_method_and_columns( cpl_table *catalogue,
150 cpl_error_code (*import_func)(
161 cpl_array **err_colnames,
162 bool *method_supports_band);
181 fors_std_cat_propagate_uncorrelated_inputs(
const double *in,
183 const double *jacobi_A,
184 const double *jacobi_B,
200 for (n = 0; n < size; n++)
203 *out_A += (*jacobi_A) * (*in);
204 *out_B += (*jacobi_B) * (*in);
205 *dout_A += (*jacobi_A)*(*jacobi_A) * (*din)*(*din);
206 *dout_B += (*jacobi_B)*(*jacobi_B) * (*din)*(*din);
207 *cov_AB += (*jacobi_A)*(*jacobi_B) * (*din)*(*din);
214 *dout_A = sqrt(*dout_A);
215 *dout_B = sqrt(*dout_B);
247 static cpl_error_code
248 fors_std_cat_import_generic_star(
const double *band_values,
249 const double *band_errors,
258 double *cov_catmag_color)
261 for (ib = 0; ib <= nbands; ib++)
263 if (jacobians[ib].band == band)
265 fors_std_cat_propagate_uncorrelated_inputs(
277 *cat_mag += jacobians[ib].mag[nband_values];
278 *color += jacobians[ib].col[nband_values];
280 return CPL_ERROR_NONE;
284 cpl_error_set_message( cpl_func,
285 CPL_ERROR_UNSUPPORTED_MODE,
286 "unknown band \'%c\'",
288 return cpl_error_get_code();
294 cpl_free(values); values = NULL; \
295 cpl_free(errors); errors = NULL; \
305 fors_std_cat_check_band_support( cpl_error_code (*import_func)(
317 double *values = NULL,
320 cpl_errorstate errstat = cpl_errorstate_get();
323 values = cpl_calloc(nvalues,
sizeof(*values));
324 errors = cpl_calloc(nvalues,
sizeof(*errors));
325 (*import_func)( values, errors, band,
326 out + 0, out + 1, out + 2, out + 3, out + 4);
330 if (!cpl_errorstate_is_equal(errstat))
332 if (cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE)
334 cpl_errorstate_set(errstat);
338 cpl_error_set_where(cpl_func);
349 cpl_free(required); required = NULL; \
350 cpl_free(values); values = NULL; \
351 cpl_free(errors); errors = NULL; \
365 fors_std_cat_determine_required_columns( cpl_error_code (*import_func)(
377 bool *required = NULL;
378 double *values = NULL,
380 double out_offset[5];
382 cpl_errorstate errstat = cpl_errorstate_get();
384 values = cpl_calloc(nvalues,
sizeof(*values));
385 errors = cpl_calloc(nvalues,
sizeof(*errors));
386 required = cpl_calloc(nvalues,
sizeof(*required));
389 (*import_func)( values,
400 for (n = 0; n < nvalues; n++)
413 (*import_func)( values,
421 if (!cpl_errorstate_is_equal(errstat))
423 cpl_error_set_where(cpl_func);
428 for (i = 0; i < 5; i++)
429 if (fabs(out[i] - out_offset[i]) > 10*DBL_EPSILON)
442 cpl_free(required); required = NULL; \
451 static cpl_error_code
452 fors_std_cat_reject_not_required_columns( cpl_array *column_names,
453 cpl_error_code (*import_func)(
464 bool *required = NULL;
467 cpl_errorstate errstat = cpl_errorstate_get();
469 cassure_automsg( import_func != NULL,
470 CPL_ERROR_NULL_INPUT,
471 return cpl_error_get_code());
472 cassure_automsg( column_names != NULL,
473 CPL_ERROR_NULL_INPUT,
474 return cpl_error_get_code());
475 cassure_automsg( cpl_array_get_type(column_names)
477 CPL_ERROR_NULL_INPUT,
478 return cpl_error_get_code());
480 ncolumns = cpl_array_get_size(column_names);
481 required = fors_std_cat_determine_required_columns(
485 assure( cpl_errorstate_is_equal(errstat),
486 return cpl_error_get_code(),
489 for (n = 0; n < ncolumns; n++)
493 cpl_array_set_invalid(column_names, n);
498 name = cpl_array_get_string(column_names, n);
499 if (name == NULL || name[0] ==
'\0')
501 cpl_error_set_message( cpl_func,
502 CPL_ERROR_DATA_NOT_FOUND,
503 "column %d required, but name not "
507 return cpl_error_get_code();
513 return (cpl_errorstate_is_equal(errstat) ?
515 cpl_error_get_code());
529 fors_std_cat_table_check_columns(
const cpl_table *cat_table,
530 const cpl_array *columns)
534 cassure_automsg( cat_table != NULL,
535 CPL_ERROR_NULL_INPUT,
537 cassure_automsg( columns != NULL,
538 CPL_ERROR_NULL_INPUT,
540 cassure_automsg( cpl_array_get_type(columns)
542 CPL_ERROR_NULL_INPUT,
545 ncols = cpl_array_get_size(columns);
546 for (n = 0; n < ncols; n++)
549 cs = cpl_array_get_string(columns, n);
551 && (!cpl_table_has_column(cat_table, cs)))
562 cpl_array_delete(errcolnames); errcolnames = NULL; \
572 fors_std_cat_create_error_column_names(
const cpl_array *colnames)
574 cpl_array *errcolnames = NULL;
578 cassure_automsg( colnames != NULL,
579 CPL_ERROR_NULL_INPUT,
581 cassure_automsg( cpl_array_get_type(colnames)
583 CPL_ERROR_NULL_INPUT,
586 size = cpl_array_get_size(colnames);
588 errcolnames = cpl_array_new(size, CPL_TYPE_STRING);
589 for (n = 0; n < size; n++)
593 cs = cpl_array_get_string(colnames, n);
596 snprintf(estr, 9,
"ERR_%s", cs);
597 cpl_array_set_string(errcolnames, n, estr);
621 static cpl_error_code
622 fors_std_cat_landolt_star_import(
double v_bv_ub_vr_vi[5],
623 double ERR_v_bv_ub_vr_vi[5],
629 double *cov_catmag_color)
635 {
'U', { 1, 1, 1, 0, 0, 0,},
636 { 0, 0, 1, 0, 0, 0,}, },
637 {
'B', { 1, 1, 0, 0, 0, 0,},
638 { 0, 1, 0, 0, 0, 0,}, },
640 {
'G', { 1, 0.56, 0, 0, 0,-0.12,},
641 { 0, 1, 0, 0, 0, 0,}, },
642 {
'V', { 1, 0, 0, 0, 0, 0,},
643 { 0, 1, 0, 0, 0, 0,}, },
644 {
'R', { 1, 0, 0, -1, 0, 0,},
645 { 0, 0, 0, 1, 0, 0,}, },
646 {
'I', { 1, 0, 0, 0, -1, 0,},
647 { 0, 0, 0, 1, 0, 0,}, },
650 errc = fors_std_cat_import_generic_star(v_bv_ub_vr_vi,
661 if (errc != CPL_ERROR_NONE)
662 cpl_error_set_where(cpl_func);
676 fors_std_cat_landolt_get_column_names(
void)
678 const char landolt_columns[5][4] = {
"V",
"B_V",
"U_B",
"V_R",
"V_I" };
679 cpl_array *columns = NULL;
682 columns = cpl_array_new(5, CPL_TYPE_STRING);
684 for (c = 0; c < 5; c++)
685 cpl_array_set_string(columns, c, landolt_columns[c]);
708 static cpl_error_code
709 fors_std_cat_stetson_star_import(
double u_b_v_r_i[5],
710 double ERR_u_b_v_r_i[5],
716 double *cov_catmag_color)
722 {
'U', { 1, 0, 0, 0, 0, 0,},
723 { 1, -1, 0, 0, 0, 0,}, },
724 {
'B', { 0, 1, 0, 0, 0, 0,},
725 { 0, 1, -1, 0, 0, 0,}, },
727 {
'G', { 0, 0.56,(1.0-0.56),0, 0,-0.12,},
728 { 0, 1, -1, 0, 0, 0,}, },
729 {
'V', { 0, 0, 1, 0, 0, 0,},
730 { 0, 1, -1, 0, 0, 0,}, },
731 {
'R', { 0, 0, 0, 1, 0, 0,},
732 { 0, 0, 1, -1, 0, 0,}, },
733 {
'I', { 0, 0, 0, 0, 1, 0,},
734 { 0, 0, 1, -1, 0, 0,}, },
737 errc = fors_std_cat_import_generic_star(u_b_v_r_i,
748 if (errc != CPL_ERROR_NONE)
749 cpl_error_set_where(cpl_func);
763 fors_std_cat_stetson_get_column_names(
void)
765 const char stetson_columns[5][2] = {
"U",
"B",
"V",
"R",
"I" };
766 cpl_array *columns = NULL;
769 columns = cpl_array_new(5, CPL_TYPE_STRING);
771 for (c = 0; c < 5; c++)
772 cpl_array_set_string(columns, c, stetson_columns[c]);
780 if (err_colnames != NULL) \
781 { cpl_array_delete(*err_colnames); *err_colnames = NULL; } \
782 cat_type_detected = false; \
800 fors_std_cat_check_method_and_columns( cpl_table *catalogue,
802 cpl_error_code (*import_func)(
813 cpl_array **err_colnames,
814 bool *method_supports_band)
816 bool band_supported =
false,
817 cat_type_detected =
false;
819 cpl_errorstate errstat = cpl_errorstate_get();
821 cassure_automsg( catalogue != NULL,
822 CPL_ERROR_NULL_INPUT,
823 return cat_type_detected);
824 cassure_automsg( colnames != NULL,
825 CPL_ERROR_NULL_INPUT,
826 return cat_type_detected);
827 cassure_automsg( cpl_array_get_type(colnames)
829 CPL_ERROR_NULL_INPUT,
830 return cat_type_detected);
831 cassure_automsg( import_func != NULL,
832 CPL_ERROR_NULL_INPUT,
833 return cat_type_detected);
834 cassure_automsg( method != NULL,
835 CPL_ERROR_NULL_INPUT,
836 return cat_type_detected);
837 cassure_automsg( err_colnames != NULL,
838 CPL_ERROR_NULL_INPUT,
839 return cat_type_detected);
843 ncols = cpl_array_get_size(colnames);
844 band_supported = fors_std_cat_check_band_support(
853 fors_std_cat_reject_not_required_columns(
859 *err_colnames = fors_std_cat_create_error_column_names(colnames);
861 for (n = 0; n < ncols; n++)
865 s[0] = cpl_array_get_string(colnames, n);
866 s[1] = cpl_array_get_string(*err_colnames, n);
868 for (i = 0; i < 2; i++)
870 cpl_msg_debug(cpl_func,
"Required %s column for band %c: "
873 ( cpl_table_has_column(
881 cat_type_detected = ( fors_std_cat_table_check_columns(
884 && fors_std_cat_table_check_columns(
888 if (method_supports_band != NULL)
889 *method_supports_band = band_supported;
891 assure(cpl_errorstate_is_equal(errstat),
return cat_type_detected, NULL);
893 return cat_type_detected;
899 fors_std_star_list_delete(&stdlist, fors_std_star_delete); \
900 fors_std_star_delete(&std_star); \
901 cpl_array_delete(columns); columns = NULL; \
902 cpl_array_delete(err_columns); err_columns = NULL; \
903 cpl_array_delete(frame_error_messages); frame_error_messages = NULL; \
904 cpl_table_delete(cat_table); cat_table = NULL; \
905 cpl_free(band_values); band_values = NULL; \
906 cpl_free(band_errors); band_errors = NULL; \
916 fors_std_cat_load(
const cpl_frameset *cat_frames,
918 bool require_all_frames,
922 fors_std_star_list *stdlist = NULL;
923 fors_std_star *std_star = NULL;
924 cpl_array *columns = NULL,
926 *frame_error_messages = NULL;
927 char **frame_error_strings = NULL;
928 cpl_table *cat_table = NULL;
929 const cpl_frame *cat_frame;
930 double *band_values = NULL,
935 bool printed_warning =
false,
936 checked_support =
false,
937 printed_supported =
false;
938 cpl_errorstate errstat = cpl_errorstate_get();
941 cpl_array* (*get_column_names_func)(void);
942 cpl_error_code (*star_import_func)(
950 double *cov_catmag_color);
953 } methods[2] = { { fors_std_cat_landolt_get_column_names,
954 fors_std_cat_landolt_star_import,
957 { fors_std_cat_stetson_get_column_names,
958 fors_std_cat_stetson_star_import,
964 cassure_automsg( cat_frames != NULL,
965 CPL_ERROR_NULL_INPUT,
968 cassure( !fors_instrument_filterband_is_none(
970 CPL_ERROR_ILLEGAL_INPUT,
972 "no optical/filter band specified");
973 cassure( !fors_instrument_filterband_is_unknown(
975 CPL_ERROR_ILLEGAL_INPUT,
977 "optical/filter band is unknown");
979 stdlist = fors_std_star_list_new();
982 frame_error_messages = cpl_array_new( cpl_frameset_get_size(cat_frames),
984 frame_error_strings = cpl_array_get_data_string(frame_error_messages);
987 for (cat_frame = cpl_frameset_get_first_const(cat_frames), iframe = 0;
989 cat_frame = cpl_frameset_get_next_const(cat_frames), iframe++)
996 const char **column_value_names,
997 **column_error_names;
998 const char *filename;
999 bool cat_type_detected =
false;
1001 filename = cpl_frame_get_filename(cat_frame);
1002 cassure( filename != NULL,
1003 CPL_ERROR_NULL_INPUT,
1005 "filename of frame %d is NULL",
1008 cpl_table_delete(cat_table);
1009 cat_table = cpl_table_load(filename, 1, 1);
1010 if (!cpl_errorstate_is_equal(errstat))
1012 frame_error_strings[iframe] = cpl_sprintf(
1013 "could not load FITS table");
1014 if (require_all_frames)
1017 CPL_ERROR_DATA_NOT_FOUND,
1021 frame_error_strings[iframe]);
1026 cpl_errorstate_set(errstat);
1027 cpl_msg_warning( cpl_func,
"Skipping %s (%s)",
1029 frame_error_strings[iframe]);
1039 nmethods =
sizeof(methods)/
sizeof(*methods);
1040 for (imethod = 0; imethod < nmethods; imethod++)
1042 cpl_array_delete(columns);
1043 columns = methods[imethod].get_column_names_func();
1045 cat_type_detected = fors_std_cat_check_method_and_columns(
1048 methods[imethod].star_import_func,
1050 methods[imethod].name,
1052 &(methods[imethod].band_supported));
1053 passure(cpl_errorstate_is_equal(errstat),
return stdlist);
1054 if (cat_type_detected)
1057 if (!cat_type_detected)
1059 if (!checked_support)
1063 bool band_generally_supported =
false;
1064 for (imethod = 0; imethod < nmethods; imethod++)
1066 band_generally_supported |= methods[imethod].band_supported;
1068 if (!band_generally_supported)
1070 cpl_error_set_message( cpl_func,
1071 CPL_ERROR_UNSUPPORTED_MODE,
1072 "Optical band %c not supported",
1077 checked_support =
true;
1081 if (!printed_supported)
1083 char *supported_methods = NULL;
1084 for (imethod = 0; imethod < nmethods; imethod++)
1086 if (methods[imethod].band_supported)
1088 if (supported_methods == NULL)
1090 supported_methods = cpl_sprintf(
1092 methods[imethod].name);
1097 s = cpl_sprintf(
"%s, %s",
1099 methods[imethod].name);
1100 cpl_free(supported_methods);
1101 supported_methods = s;
1105 cpl_msg_warning( cpl_func,
1106 "Import of band %c supported for: "
1110 cpl_free(supported_methods);
1111 printed_supported =
true;
1114 frame_error_strings[iframe] = cpl_sprintf(
1115 "no cat. data for band %c found",
1117 if (require_all_frames)
1119 cpl_error_set_message( cpl_func,
1120 CPL_ERROR_DATA_NOT_FOUND,
1123 frame_error_strings[iframe]);
1129 cpl_msg_warning( cpl_func,
"Skipping %s (%s)",
1131 frame_error_strings[iframe]);
1137 cpl_msg_info( cpl_func,
1138 "Loading %s catalogue from %s",
1139 methods[imethod].name,
1142 if (last_imethod >= 0 && last_imethod != imethod && !printed_warning)
1144 cpl_msg_warning( cpl_func,
1145 "Merging different types of "
1147 printed_warning =
true;
1149 last_imethod = imethod;
1152 ncolumns = cpl_array_get_size(columns);
1154 cpl_free(band_values);
1155 band_values = cpl_calloc(ncolumns,
sizeof(*band_values));
1156 cpl_free(band_errors);
1157 band_errors = cpl_calloc(ncolumns,
sizeof(*band_errors));
1159 column_value_names = cpl_array_get_data_string_const(columns);
1160 column_error_names = cpl_array_get_data_string_const(err_columns);
1161 passure(cpl_errorstate_is_equal(errstat),
return stdlist);
1164 nrows = cpl_table_get_nrow(cat_table);
1165 n_cat_entries += nrows;
1166 for (row = 0; row < nrows; row++)
1177 for (ib = 0; ib < ncolumns; ib++)
1179 if (column_value_names[ib] != NULL)
1181 band_values[ib] = cpl_table_get(
1183 column_value_names[ib],
1186 valid &= (isnull == 0);
1188 passure(column_error_names[ib] != NULL,
return stdlist);
1189 band_errors[ib] = cpl_table_get(
1191 column_error_names[ib],
1194 valid &= (isnull == 0);
1201 std_star = fors_std_star_new_from_table(
1204 FORS_STD_CAT_COLUMN_RA,
1205 FORS_STD_CAT_COLUMN_DEC,
1211 FORS_STD_CAT_COLUMN_NAME);
1212 assure( std_star != NULL,
1216 methods[imethod].star_import_func(
1220 &(std_star->cat_magnitude),
1221 &(std_star->dcat_magnitude),
1223 &(std_star->dcolor),
1224 &(std_star->cov_catm_color));
1225 assure( cpl_errorstate_is_equal(errstat),
1229 fors_std_star_compute_corrected_mag(
1234 fors_std_star_list_insert(stdlist, std_star);
1239 if (!require_all_frames)
1241 cassure( cpl_array_has_invalid(
1242 frame_error_messages),
1243 CPL_ERROR_DATA_NOT_FOUND,
1245 "No valid catalogue frame found");
1251 cpl_msg_info( cpl_func,
1252 "Found %d catalogue standard stars "
1253 "for band %c (of %d catalogue "
1255 fors_std_star_list_size(stdlist),
1259 fors_std_star_list *retval = stdlist;
1301 const char *
const FORS_DATA_STD_MAG[FORS_NUM_FILTER] =
1311 const char *
const FORS_DATA_STD_DMAG[FORS_NUM_FILTER] =
1321 const char *
const FORS_DATA_STD_COL[FORS_NUM_FILTER] =
1330 const char *
const FORS_DATA_STD_RA =
"RA";
1331 const char *
const FORS_DATA_STD_DEC =
"DEC";
1332 const char *
const FORS_DATA_STD_NAME =
"OBJECT";
1337 cpl_table_delete(t); \
1338 cpl_free((void *)ERR_B1); \
1339 cpl_free((void *)ERR_C1); \
1340 cpl_free((void *)ERR_C2); \
1354 fors_std_star_list *
1355 fors_std_cat_load_old(
const cpl_frameset *cat_frames,
1358 double color_term,
double dcolor_term)
1360 fors_std_star_list *c = NULL;
1361 cpl_table *t = NULL;
1362 const char *filename;
1363 const char *ERR_B1 = NULL;
1364 const char *ERR_C1 = NULL;
1365 const char *ERR_C2 = NULL;
1367 assure( cat_frames != NULL,
return c, NULL );
1373 c = fors_std_star_list_new();
1375 const cpl_frame *cat_frame;
1377 for (cat_frame = cpl_frameset_get_first_const(cat_frames);
1379 cat_frame = cpl_frameset_get_next_const(cat_frames)) {
1382 filename = cpl_frame_get_filename(cat_frame);
1383 assure( filename != NULL,
return c, NULL );
1385 cpl_table_delete(t);
1386 t = cpl_table_load(filename, 1, 1);
1387 assure( !cpl_error_get_code(),
return c,
"Could not load FITS catalogue %s",
1390 assure( cpl_table_has_column(t, FORS_DATA_STD_RA),
return c,
1391 "%s: Missing column %s", filename, FORS_DATA_STD_RA);
1393 assure( cpl_table_get_column_type(t, FORS_DATA_STD_RA) == CPL_TYPE_DOUBLE,
1395 "%s: Column %s type is %s, double expected", filename, FORS_DATA_STD_RA,
1399 assure( cpl_table_has_column(t, FORS_DATA_STD_DEC),
return c,
1400 "%s: Missing column %s", filename, FORS_DATA_STD_DEC);
1402 assure( cpl_table_get_column_type(t, FORS_DATA_STD_DEC) == CPL_TYPE_DOUBLE,
1404 "%s: Column %s type is %s, double expected", filename, FORS_DATA_STD_DEC,
1408 assure( cpl_table_has_column(t, FORS_DATA_STD_NAME),
return c,
1409 "%s: Missing column %s", filename, FORS_DATA_STD_NAME);
1411 assure( cpl_table_get_column_type(t, FORS_DATA_STD_NAME) == CPL_TYPE_STRING,
1413 "%s: Column %s type is %s, string expected", filename,
1420 char B1[2] = {
'\0',
'\0'};
1424 if ( cpl_table_has_column(t, B1) ) {
1489 case 'U': col =
"U_B";
break;
1490 case 'B': col =
"B_V";
break;
1491 case 'G': col =
"B_V";
break;
1492 case 'V': col =
"B_V";
break;
1493 case 'R': col =
"V_R";
break;
1494 case 'I': col =
"V_R";
break;
1495 case 'Z': col =
"?Z?";
break;
1498 double coeff = -color_term;
1499 double dcoeff = dcolor_term;
1501 assure( strlen(col) == strlen(
"X_Y"),
return c,
1502 "Color term column must have format 'X_Y', is '%s'",
1505 assure( col[1] ==
'_',
return c,
1506 "Color term column must have format 'X_Y', is '%s'",
1509 char C1[2] = {
'\0',
'\0'};
1510 char C2[2] = {
'\0',
'\0'};
1515 ERR_B1 = cpl_sprintf(
"ERR_%s", B1);
1516 ERR_C1 = cpl_sprintf(
"ERR_%s", C1);
1517 ERR_C2 = cpl_sprintf(
"ERR_%s", C2);
1520 double cat_mag, dcat_mag, color;
1526 for (i = 0; i < cpl_table_get_nrow(t); i++) {
1527 if (cpl_table_has_column(t, ERR_B1) &&
1528 cpl_table_has_column(t, ERR_C1) &&
1529 cpl_table_has_column(t, ERR_C2)) {
1534 if (cpl_table_is_valid(t,
"V", i) &&
1535 cpl_table_is_valid(t,
"B", i) &&
1536 cpl_table_is_valid(t,
"ERR_B", i) &&
1537 cpl_table_is_valid(t,
"ERR_V", i)) {
1538 double v = cpl_table_get_float(t,
"V", i, NULL);
1539 double b = cpl_table_get_float(t,
"B", i, NULL);
1540 double err_b = cpl_table_get_float(t,
"ERR_B", i, NULL);
1541 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1544 mag = (1-0.56-coeff) * v + (0.56+coeff)*b - 0.12;
1545 cat_mag = (1-0.56 ) * v + (0.56 )*b - 0.12;
1549 (1-0.56-coeff)*(1-0.56-coeff)*err_v*err_v +
1550 (0.56 +coeff)*(0.56 +coeff)*err_b*err_b +
1552 dcoeff*dcoeff*color*color);
1555 (1-0.56-0)*(1-0.56-0)*err_v*err_v +
1556 (0.56 +0)*(0.56 +0)*err_b*err_b);
1559 else if (*B1 == *C2) {
1560 if (cpl_table_is_valid(t, B1, i) &&
1561 cpl_table_is_valid(t, C1, i) &&
1562 cpl_table_is_valid(t, ERR_B1, i) &&
1563 cpl_table_is_valid(t, ERR_C1, i)) {
1564 double b1 = cpl_table_get_float(t, B1, i, NULL);
1565 double c1 = cpl_table_get_float(t, C1, i, NULL);
1566 double err_b1 = cpl_table_get_float(t, ERR_B1, i, NULL);
1567 double err_c1 = cpl_table_get_float(t, ERR_C1, i, NULL);
1579 (1-coeff)*(1-coeff)*err_b1*err_b1 +
1580 coeff*coeff *err_c1*err_c1
1582 dcoeff*dcoeff*color*color);
1586 else if (*B1 == *C1) {
1587 if (cpl_table_is_valid(t, B1, i) &&
1588 cpl_table_is_valid(t, C2, i) &&
1589 cpl_table_is_valid(t, ERR_B1, i) &&
1590 cpl_table_is_valid(t, ERR_C2, i)) {
1591 double b1 = cpl_table_get_float(t, B1, i, NULL);
1592 double c2 = cpl_table_get_float(t, C2, i, NULL);
1593 double err_b1 = cpl_table_get_float(t, ERR_B1, i, NULL);
1594 double err_c2 = cpl_table_get_float(t, ERR_C2, i, NULL);
1606 (1+coeff)*(1+coeff)*err_b1*err_b1 +
1607 coeff*coeff *err_c2*err_c2
1609 dcoeff*dcoeff*color*color);
1616 if (cpl_table_is_valid(t, B1, i) &&
1617 cpl_table_is_valid(t, C1, i) &&
1618 cpl_table_is_valid(t, C2, i) &&
1619 cpl_table_is_valid(t, ERR_B1, i) &&
1620 cpl_table_is_valid(t, ERR_C1, i) &&
1621 cpl_table_is_valid(t, ERR_C2, i)) {
1622 double b1 = cpl_table_get_float(t, B1, i, NULL);
1623 double c1 = cpl_table_get_float(t, C1, i, NULL);
1624 double c2 = cpl_table_get_float(t, C2, i, NULL);
1625 double err_b1 = cpl_table_get_float(t, ERR_B1, i, NULL);
1626 double err_c1 = cpl_table_get_float(t, ERR_C1, i, NULL);
1627 double err_c2 = cpl_table_get_float(t, ERR_C2, i, NULL);
1639 coeff*coeff * err_c1*err_c1 +
1640 coeff*coeff * err_c2*err_c2 +
1641 dcoeff*dcoeff * color*color);
1647 else if (*B1 ==
'G') {
1648 if (cpl_table_is_valid(t,
"V", i) &&
1649 cpl_table_is_valid(t,
"B_V", i) &&
1650 cpl_table_is_valid(t,
"ERR_V", i) &&
1651 cpl_table_is_valid(t,
"ERR_B_V", i)) {
1652 double v = cpl_table_get_float(t,
"V", i, NULL);
1653 double bv = cpl_table_get_float(t,
"B_V", i, NULL);
1654 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1655 double err_b_v = cpl_table_get_float(t,
"ERR_B_V", i, NULL);
1659 cat_mag = v + (0.56)*(bv) - 0.12;
1661 mag = v + (0.56+coeff)*(bv) - 0.12;
1665 (0.56+coeff)*(0.56+coeff)*err_b_v*err_b_v +
1667 dcoeff*dcoeff*bv*bv);
1671 (0.56)*(0.56)*err_b_v*err_b_v);
1677 if (cpl_table_is_valid(t,
"U", i) &&
1678 cpl_table_is_valid(t,
"U_B", i) &&
1679 cpl_table_is_valid(t,
"ERR_V", i) &&
1680 cpl_table_is_valid(t,
"ERR_B_V", i) &&
1681 cpl_table_is_valid(t,
"ERR_U_B", i)) {
1683 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1684 double err_bv = cpl_table_get_float(t,
"ERR_B_V", i, NULL);
1685 double err_ub = cpl_table_get_float(t,
"ERR_U_B", i, NULL);
1686 double ub = cpl_table_get_float(t,
"U_B", i, NULL);
1690 cat_mag = cpl_table_get_float(t,
"U", i, NULL);
1692 mag = cat_mag + coeff * ub;
1693 dmag = sqrt(err_v*err_v + err_bv*err_bv+
1694 (1+coeff)*(1+coeff)*err_ub*err_ub +
1695 dcoeff*dcoeff*ub*ub);
1697 dcat_mag = sqrt(err_v*err_v + err_bv*err_bv+
1703 if (cpl_table_is_valid(t,
"B", i) &&
1704 cpl_table_is_valid(t,
"B_V", i) &&
1705 cpl_table_is_valid(t,
"ERR_V", i) &&
1706 cpl_table_is_valid(t,
"ERR_B_V", i)) {
1708 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1709 double err_bv = cpl_table_get_float(t,
"ERR_B_V", i, NULL);
1710 double bv = cpl_table_get_float(t,
"B_V", i, NULL);
1713 cat_mag = cpl_table_get_float(t,
"B", i, NULL);
1717 dmag = sqrt(err_v*err_v +
1718 (1+coeff)*(1+coeff)*err_bv*err_bv +
1719 dcoeff*dcoeff*bv*bv);
1720 dcat_mag = sqrt(err_v*err_v +
1726 if (cpl_table_is_valid(t,
"V", i) &&
1727 cpl_table_is_valid(t,
"B_V", i) &&
1728 cpl_table_is_valid(t,
"ERR_V", i) &&
1729 cpl_table_is_valid(t,
"ERR_B_V", i)) {
1731 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1732 double err_bv = cpl_table_get_float(t,
"ERR_B_V", i, NULL);
1733 double bv = cpl_table_get_float(t,
"B_V", i, NULL);
1736 cat_mag = cpl_table_get_float(t,
"V", i, NULL);
1739 mag = cat_mag + coeff * bv;
1740 dmag = sqrt(err_v*err_v +
1741 coeff*coeff*err_bv*err_bv +
1742 dcoeff*dcoeff*bv*bv);
1747 if (cpl_table_is_valid(t,
"R", i) &&
1748 cpl_table_is_valid(t,
"V_R", i) &&
1749 cpl_table_is_valid(t,
"ERR_V", i) &&
1750 cpl_table_is_valid(t,
"ERR_V_R", i)) {
1752 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1753 double err_vr = cpl_table_get_float(t,
"ERR_V_R", i, NULL);
1754 double vr = cpl_table_get_float(t,
"V_R", i, NULL);
1757 cat_mag = cpl_table_get_float(t,
"R", i, NULL);
1758 mag = cat_mag + coeff * vr;
1759 dmag = sqrt(err_v*err_v +
1760 (1-coeff)*(1-coeff)*err_vr*err_vr +
1761 dcoeff*dcoeff*vr*vr);
1762 dcat_mag = sqrt(err_v*err_v + err_vr*err_vr);
1767 if (cpl_table_is_valid(t,
"I", i) &&
1768 cpl_table_is_valid(t,
"V_R", i) &&
1769 cpl_table_is_valid(t,
"ERR_V", i) &&
1770 cpl_table_is_valid(t,
"ERR_V_I", i) &&
1771 cpl_table_is_valid(t,
"ERR_V_R", i)) {
1773 double err_v = cpl_table_get_float(t,
"ERR_V", i, NULL);
1774 double err_vi = cpl_table_get_float(t,
"ERR_V_I", i, NULL);
1775 double err_vr = cpl_table_get_float(t,
"ERR_V_R", i, NULL);
1776 double vr = cpl_table_get_float(t,
"V_R", i, NULL);
1779 cat_mag = cpl_table_get_float(t,
"I", i, NULL);
1780 mag = cat_mag + coeff * vr;
1781 dmag = sqrt(err_v*err_v + err_vi*err_vi+
1782 coeff*coeff*err_vr*err_vr +
1783 dcoeff*dcoeff*vr*vr);
1784 dcat_mag = sqrt(err_v*err_v + err_vi*err_vi);
1790 "Unknown filter: %s", B1);
1794 double ra = cpl_table_get_double(t, FORS_DATA_STD_RA,
1796 double dec = cpl_table_get_double(t, FORS_DATA_STD_DEC,
1799 const char *std_name = cpl_table_get_string(t, FORS_DATA_STD_NAME,
1802 fors_std_star_list_insert(
1803 c, fors_std_star_new(ra, dec, mag, dmag,
1805 color, -1, -1, std_name));
1813 double nearest_dist;
1814 if (fors_std_star_list_size(c) > 0) {
1815 fors_std_star *nearest = fors_std_star_list_min_val(
1817 (fors_std_star_list_func_eval)
1818 fors_std_star_dist_arcsec,
1821 nearest_dist = fors_std_star_dist_arcsec(std, nearest);
1822 cpl_msg_debug(cpl_func,
"min dist = %f arcseconds",
1826 if (fors_std_star_list_size(c) == 0 || nearest_dist > 5) {
1827 fors_std_star_list_insert(c, std);
1830 fors_std_star_delete(&std);
1835 cpl_msg_info(cpl_func,
"Skipping catalog %s, no column %s",
1840 cpl_msg_info(cpl_func,
"Found %d catalogue standards",
1841 fors_std_star_list_size(c));
const char * fors_type_get_string(cpl_type t)
Textual representation of CPL type.