51 #include "gravi_data.h" 52 #include "gravi_dfs.h" 53 #include "gravi_pfits.h" 54 #include "gravi_cpl.h" 56 #include "gravi_utils.h" 58 #include "gravi_vis.h" 67 const char * data,
const char *flag);
69 const char * data,
const char *flag);
72 cpl_size
gravi_get_row_in_cat (cpl_table * diam_table,
double ra,
double dec,
double *separation);
88 cpl_ensure (array, CPL_ERROR_NULL_INPUT, -1);
91 if ( cpl_array_get_min ( array ) > 0.0 )
return 0;
93 cpl_size indx, size = cpl_array_get_size (array);
97 for ( indx = 0 ; indx < size ; indx ++ ) {
98 if ( cpl_array_get (array, indx, &nv) < 0.0 ) {
99 cpl_array_set_invalid (array, indx);
118 const char * data,
const char *flag)
120 gravi_msg_function_start(0);
121 cpl_ensure_code (oi_table, CPL_ERROR_NULL_INPUT);
122 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
123 cpl_ensure_code (flag, CPL_ERROR_ILLEGAL_OUTPUT);
127 cpl_size row, nrow = cpl_table_get_nrow (oi_table);
128 cpl_array ** pdata = cpl_table_get_data_array (oi_table, data);
129 cpl_array ** pflag = cpl_table_get_data_array (oi_table, flag);
130 cpl_size indx, size = cpl_array_get_size (pdata[0]);
132 CPLCHECK_MSG (
"Cannot get data");
135 for ( row = 0 ; row < nrow ; row ++ ) {
136 for ( indx = 0 ; indx < size ; indx ++ ) {
137 if ( cpl_array_get (pdata[row], indx, &nv) < 0.0) {
138 cpl_array_set (pflag[row], indx, cpl_array_get (pflag[row], indx, &nv) + 1 );
143 gravi_msg_function_exit(0);
144 return CPL_ERROR_NONE;
158 const char * data,
const char *flag)
160 gravi_msg_function_start(0);
161 cpl_ensure_code (oi_table, CPL_ERROR_NULL_INPUT);
162 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
163 cpl_ensure_code (flag, CPL_ERROR_ILLEGAL_OUTPUT);
167 cpl_size row, nrow = cpl_table_get_nrow (oi_table);
168 cpl_array ** pdata = cpl_table_get_data_array(oi_table, data);
169 cpl_array ** pflag = cpl_table_get_data_array(oi_table, flag);
170 cpl_size indx, size = cpl_array_get_size (pdata[0]);
172 CPLCHECK_MSG (
"Cannot get data");
175 for ( row = 0 ; row < nrow ; row ++ ) {
176 if (pdata[row]==NULL)
continue;
177 for ( indx = 0 ; indx < size ; indx ++ ) {
178 if ( !cpl_array_is_valid (pdata[row], indx) ) {
179 cpl_array_set (pflag[row], indx, cpl_array_get (pflag[row], indx, &nv) + 1 );
184 gravi_msg_function_exit(0);
185 return CPL_ERROR_NONE;
203 gravi_msg_function_start(0);
204 cpl_ensure (data, CPL_ERROR_NULL_INPUT, NULL);
207 cpl_propertylist * hdr_data = gravi_data_get_header (data);
210 char* setupstring = cpl_sprintf(
"%10s %s %s %.2fms %.2fs",
211 gravi_pfits_get_spec_res (hdr_data),
212 gravi_pfits_get_pola_mode (hdr_data, GRAVI_SC),
213 gravi_pfits_get_pola_mode (hdr_data, GRAVI_FT),
214 gravi_pfits_get_dit_ft (hdr_data) * 1e3,
215 gravi_pfits_get_dit_sc (hdr_data) );
217 cpl_msg_debug (cpl_func,
"Get setup string: %s", setupstring);
219 CPLCHECK_NUL (
"Cannot compute the setupstring");
221 gravi_msg_function_exit(0);
249 gravi_data * science_tf,
250 gravi_data ** used_tf_data,
252 const char * extName,
253 const char * insName,
254 const char * ampName,
255 const char * ampErrName,
256 int nbase,
double delta_t)
258 gravi_msg_function_start(0);
259 cpl_ensure_code (science, CPL_ERROR_NULL_INPUT);
260 cpl_ensure_code (insName, CPL_ERROR_NULL_INPUT);
261 cpl_ensure_code (extName, CPL_ERROR_NULL_INPUT);
262 cpl_ensure_code (ampName, CPL_ERROR_NULL_INPUT);
263 cpl_ensure_code (ampErrName, CPL_ERROR_NULL_INPUT);
264 cpl_ensure_code (used_tf_data, CPL_ERROR_NULL_INPUT);
265 cpl_ensure_code (num_tf_data>0, CPL_ERROR_ILLEGAL_INPUT);
267 cpl_msg_debug (cpl_func,
"%s %s amp=%s ampErr=%s nbase=%i",extName,insName,ampName,ampErrName,nbase);
269 int i, row_sc, row_cal, nv=0;
276 int nrow_sc = cpl_table_get_nrow (sci_table);
277 int nwave = cpl_table_get_column_depth (sci_table, ampName);
279 CPLCHECK_MSG (
"Cannot get data on SCIENCE");
282 for (row_sc = 0; row_sc < nrow_sc; row_sc ++){
283 double time_sci = cpl_table_get_double (sci_table,
"TIME", row_sc, &nv);
284 int base = row_sc % nbase;
287 cpl_array * tf_mean = cpl_array_new (nwave, CPL_TYPE_DOUBLE);
288 cpl_array_fill_window (tf_mean, 0, nwave, 0.0);
293 for (i = 0; i < num_tf_data; i++){
296 int nrow_tf = cpl_table_get_nrow (tf_table);
297 CPLCHECK_MSG(
"Cannot get the table on TF");
299 for (row_cal = base; row_cal < nrow_tf; row_cal += nbase){
300 double time_tf = cpl_table_get_double (tf_table,
"TIME", row_cal, &nv);
303 cpl_array * tf_data = cpl_array_duplicate ( cpl_table_get_array (tf_table, ampName, row_cal) );
304 cpl_array * tf_err = cpl_array_duplicate ( cpl_table_get_array (tf_table, ampErrName, row_cal) );
305 CPLCHECK_MSG(
"Cannot get data on TF");
309 double sigma = cpl_array_get_median (tf_err);
310 sigma = CPL_MAX (sigma, 0.02*fabs(cpl_array_get_median (tf_data)));
311 sigma = CPL_MAX (sigma, 1e-10);
314 double coeff = exp (-2 * fabs (time_sci - time_tf) / delta_t) / (sigma*sigma);
315 cpl_array_multiply_scalar (tf_data, coeff);
316 cpl_array_add (tf_mean, tf_data);
319 cpl_array_delete (tf_data);
320 cpl_array_delete (tf_err);
321 CPLCHECK_MSG(
"Error while integrating the TF" );
328 cpl_array_divide_scalar (tf_mean, norm);
335 if (sci_tf_table) cpl_table_set_array (sci_tf_table, ampName, row_sc, tf_mean);
338 cpl_array_divide (cpl_table_get_data_array (sci_table, ampName)[row_sc], tf_mean);
341 cpl_array_divide (cpl_table_get_data_array (sci_table, ampErrName)[row_sc], tf_mean);
344 cpl_array_delete (tf_mean);
359 gravi_msg_function_exit(0);
360 return CPL_ERROR_NONE;
387 gravi_data * science_tf,
388 gravi_data ** used_tf_data,
390 const char * extName,
391 const char * insName,
392 const char * phiName,
393 const char * phiErrName,
394 int nbase,
double delta_t)
396 gravi_msg_function_start(0);
397 cpl_ensure_code (science, CPL_ERROR_NULL_INPUT);
398 cpl_ensure_code (insName, CPL_ERROR_NULL_INPUT);
399 cpl_ensure_code (extName, CPL_ERROR_NULL_INPUT);
400 cpl_ensure_code (phiName, CPL_ERROR_NULL_INPUT);
401 cpl_ensure_code (phiErrName, CPL_ERROR_NULL_INPUT);
402 cpl_ensure_code (used_tf_data, CPL_ERROR_NULL_INPUT);
403 cpl_ensure_code (num_tf_data>0, CPL_ERROR_ILLEGAL_INPUT);
405 cpl_msg_debug(cpl_func,
"%s %s phi=%s phiErr=%s nbase=%i",extName,insName,phiName,phiErrName,nbase);
407 int i, row_sc, row_cal, nv=0;
414 int nrow_sc = cpl_table_get_nrow (sci_table);
415 int nwave = cpl_table_get_column_depth (sci_table, phiName);
417 CPLCHECK_MSG(
"Cannot get data on SCIENCE");
420 for (row_sc = 0; row_sc < nrow_sc; row_sc ++){
421 double time_sci = cpl_table_get_double (sci_table,
"TIME", row_sc, &nv);
422 int base = row_sc % nbase;
425 cpl_array * tf_mean = cpl_array_new (nwave, CPL_TYPE_DOUBLE_COMPLEX);
426 cpl_array_fill_window_complex (tf_mean, 0, nwave, 0.0 + 0.0*I);
430 for (i = 0; i < num_tf_data; i++){
433 int nrow_tf = cpl_table_get_nrow (tf_table);
434 CPLCHECK_MSG(
"Cannot get the table on TF");
436 for (row_cal = base; row_cal < nrow_tf; row_cal += nbase){
437 double time_tf = cpl_table_get_double (tf_table,
"TIME", row_cal, &nv);
440 cpl_array * tf_data =
gravi_array_cexp ( I*CPL_MATH_PI/180.0, cpl_table_get_array (tf_table, phiName, row_cal) );
441 cpl_array * tf_err = cpl_array_duplicate (cpl_table_get_array (tf_table, phiErrName, row_cal) );
442 CPLCHECK_MSG(
"Cannot get data on TF");
446 double sigma = CPL_MAX (cpl_array_get_median (tf_err), 0.2);
449 double coeff = exp (-2 * fabs (time_sci - time_tf) / delta_t) / (sigma*sigma);
450 cpl_array_multiply_scalar (tf_data, coeff);
451 cpl_array_add (tf_mean, tf_data);
453 cpl_array_delete (tf_data);
454 cpl_array_delete (tf_err);
455 CPLCHECK_MSG(
"Error while integrating the TF");
463 cpl_array * sci_data =
gravi_array_cexp ( I*CPL_MATH_PI/180.0, cpl_table_get_array (sci_table, phiName, row_sc) );
464 cpl_array_divide (sci_data, tf_mean);
465 cpl_array_arg (sci_data);
466 cpl_array_multiply_scalar (sci_data, 180./CPL_MATH_PI);
467 cpl_table_set_array (sci_table, phiName, row_sc, sci_data);
472 cpl_array_arg (tf_mean);
473 cpl_array_multiply_scalar (tf_mean, 180./CPL_MATH_PI);
474 if (sci_tf_table) cpl_table_set_array (sci_tf_table, phiName, row_sc, tf_mean );
479 cpl_array_delete (tf_mean);
480 cpl_array_delete (sci_data);
494 gravi_msg_function_exit(0);
495 return CPL_ERROR_NONE;
521 gravi_data * zero, gravi_data * tf_science,
522 const cpl_parameterlist * parlist)
524 gravi_msg_function_start(1);
525 cpl_ensure (vis_data, CPL_ERROR_NULL_INPUT, NULL);
526 cpl_ensure (tf_data, CPL_ERROR_NULL_INPUT, NULL);
527 cpl_ensure (parlist, CPL_ERROR_NULL_INPUT, NULL);
528 cpl_ensure (num_tf>0, CPL_ERROR_NULL_INPUT, NULL);
531 gravi_data * vis_calib;
532 char * setup_science, * setup_tf;
535 cpl_ensure( (vis_data != NULL) && (tf_data != NULL), CPL_ERROR_NULL_INPUT, NULL );
543 gravi_data ** used_tf_data = cpl_malloc (
sizeof( gravi_data *) * num_tf);
544 cpl_msg_info (cpl_func,
"Number of possible TF: %i", num_tf);
547 double delta_t = gravi_param_get_double (parlist,
"gravity.viscal.delta-time-calib");
548 cpl_msg_info (cpl_func,
"Delta time to interpolate the TF: %f s (%f h)", delta_t, delta_t/3600.0);
550 int force_calib = gravi_param_get_bool (parlist,
"gravity.viscal.force-calib");
551 cpl_msg_info (cpl_func,
"Force calibration of the SCI by CALs: %s", force_calib?
"T":
"F");
555 cpl_msg_info (cpl_func,
"Setup of SCIENCE: %s", setup_science);
557 CPLCHECK_NUL(
"Cannot build the setup string for SCIENCE");
561 for (i = 0; i < num_tf; i++){
567 if (!(strcmp (setup_tf, setup_science )) ) {
569 used_tf_data[num_used_tf] = tf_data[i];
571 cpl_msg_info (cpl_func,
"Setup of TF file: %s -> keep", setup_tf);
572 }
else if (force_calib) {
574 used_tf_data[num_used_tf] = tf_data[i];
576 cpl_msg_info (cpl_func,
"Setup of TF file: %s -> keep (force_calib)", setup_tf);
579 cpl_msg_info (cpl_func,
"Setup of TF file: %s -> discard", setup_tf);
585 if (num_used_tf == 0) {
586 cpl_free (used_tf_data);
587 cpl_error_set_message (cpl_func, CPL_ERROR_NULL_INPUT,
"No calib file with the same keywords");
595 cpl_propertylist * hdr_data = gravi_data_get_header (vis_calib);
598 int type_data, ntype_data = 2;
599 for (type_data = 0; type_data < ntype_data ; type_data ++) {
602 int pol, npol = gravi_pfits_get_pola_num( hdr_data, type_data );
603 for ( pol= 0 ; pol < npol ; pol++ ) {
608 GRAVI_INSNAME(type_data, pol, npol),
609 "VIS2DATA",
"VIS2ERR", 6, delta_t);
611 CPLCHECK_NUL(
"Cannot apply tf to VIS2DATA");
616 GRAVI_INSNAME(type_data, pol, npol),
617 "VISAMP",
"VISAMPERR", 6, delta_t);
619 CPLCHECK_NUL(
"Cannot apply tf to VISAMP");
624 GRAVI_INSNAME(type_data, pol, npol),
625 "VISPHI",
"VISPHIERR", 6, delta_t);
627 CPLCHECK_NUL(
"Cannot apply tf to VISPHI");
632 GRAVI_INSNAME(type_data, pol, npol),
633 "T3AMP",
"T3AMPERR", 4, delta_t);
635 CPLCHECK_NUL(
"Cannot apply tf to VISAMP");
640 GRAVI_INSNAME(type_data, pol, npol),
641 "T3PHI",
"T3PHIERR", 4, delta_t);
643 CPLCHECK_NUL(
"Cannot apply tf to T3PHI");
646 if (gravi_param_get_bool (parlist,
"gravity.viscal.calib-flux")){
649 GRAVI_INSNAME(type_data, pol, npol),
650 "FLUX",
"FLUXERR", 4, delta_t);
652 CPLCHECK_NUL(
"Cannot apply tf to FLUX");
661 cpl_free (used_tf_data);
662 cpl_free (setup_science);
664 gravi_msg_function_exit(1);
683 if (lbd <=0)
return 0.0;
684 double x = CPL_MATH_PI * uv / lbd * (diam * 1e-3 / 3600 / 180 * CPL_MATH_PI);
685 return ( (x<=0) ? 1.0 : 2.0 * j1 (x) / x );
703 gravi_msg_function_start(0);
704 cpl_ensure (diam_table, CPL_ERROR_NULL_INPUT, -1);
707 const char ** p_ra = cpl_table_get_data_string_const (diam_table,
"RAJ2000");
708 const char ** p_dec = cpl_table_get_data_string_const (diam_table,
"DEJ2000");
709 cpl_size nrow = cpl_table_get_nrow (diam_table);
711 cpl_ensure (p_ra, CPL_ERROR_ILLEGAL_INPUT, -1);
712 cpl_ensure (p_dec, CPL_ERROR_ILLEGAL_INPUT, -1);
713 cpl_ensure (nrow>0, CPL_ERROR_ILLEGAL_INPUT, -1);
720 for (cpl_size row = 0; row < nrow ; row ++) {
723 double c_ra = gravi_ra_to_rad (p_ra[row]);
724 double c_dec = gravi_dec_to_rad (p_dec[row]);
728 double dist = acos ( sin (c_dec) * sin (dec) + cos (c_dec) * cos (dec) * cos (ra - c_ra) );
738 if (separation != NULL) *separation = dis0 / CPL_MATH_PI * 180 * 3600;
740 gravi_msg_function_exit(0);
758 gravi_msg_function_start(1);
759 cpl_ensure (vis_data, CPL_ERROR_NULL_INPUT, NULL);
761 gravi_data * tf_data = NULL;
762 cpl_propertylist * plist;
763 cpl_table * tf_vistable;
764 cpl_table * tf_vis2table;
765 cpl_table * oi_wavelength;
767 double diameter, diameter_err, lambda, r_vis, r_vis2, tf_v, tf_v2;
772 plist = gravi_data_get_header (tf_data);
775 for (type_data = 0; type_data < 2; type_data ++) {
776 cpl_table * diam_table;
778 cpl_size row_cat = -1;
786 gravi_pfits_get_type_raep (plist, type_data),
787 gravi_pfits_get_type_decep (plist, type_data),
791 if ( (row_cat > -1) && (sep < 5.0) ) {
792 cpl_msg_info (cpl_func,
"Find match in DIAMETER_CAT (best sep=%.2f arcsec)", sep);
793 diameter = cpl_table_get (diam_table,
"UDDK", row_cat, NULL);
794 diameter_err = cpl_table_get (diam_table,
"e_LDD", row_cat, NULL);
796 cpl_msg_warning (cpl_func,
"No match in DIAMETER_CAT (best sep=%.2f arcsec), use the HEADER value instead", sep);
797 diameter = gravi_pfits_get_diameter (plist, type_data);
802 cpl_msg_info (cpl_func,
"No DIAMETER_CAT, use the HEADER value if any");
803 diameter = gravi_pfits_get_diameter (plist, type_data);
809 if ( diameter>=4.0 ) {
810 cpl_msg_warning (cpl_func,
"Diameter for %s target: %.3f (+-%.3f) mas. Expected ?", GRAVI_TYPE(type_data), diameter, diameter_err);
812 else if (diameter <= 0.0 && !gravi_data_is_internal(vis_data)) {
813 cpl_msg_warning (cpl_func,
"Diameter for %s target: 0.0 mas. Probably wrong, check parameter value", GRAVI_TYPE(type_data));
818 cpl_msg_info(cpl_func,
"Diameter for %s target: %.3f (+-%.3f) mas", GRAVI_TYPE(type_data), diameter, diameter_err);
822 int pol,npol = gravi_pfits_get_pola_num (plist, type_data);
823 for (pol = 0; pol < npol; pol ++){
825 oi_wavelength = gravi_data_get_oi_wave (vis_data, type_data, pol,npol);
826 tf_vistable = gravi_data_get_oi_vis (tf_data, type_data, pol,npol);
827 tf_vis2table = gravi_data_get_oi_vis2 (tf_data, type_data, pol,npol);
829 if ((tf_vistable == NULL) || (tf_vis2table == NULL) || (oi_wavelength == NULL)){
831 cpl_error_set_message (cpl_func, CPL_ERROR_NULL_INPUT,
832 "Missing OI_VIS or OI_VIS2 or OI_WAVELENGTH");
840 int nrow = cpl_table_get_nrow (tf_vistable);
841 int nwave = cpl_table_get_column_depth (tf_vis2table,
"VIS2DATA" );
842 for (cpl_size row = 0; row < nrow; row ++){
845 r_vis = sqrt (pow (cpl_table_get_double (tf_vistable,
"UCOORD", row, &nv), 2) +
846 pow (cpl_table_get_double (tf_vistable,
"VCOORD", row, &nv), 2));
848 r_vis2 = sqrt (pow (cpl_table_get_double (tf_vis2table,
"UCOORD", row, &nv), 2) +
849 pow (cpl_table_get_double (tf_vis2table,
"VCOORD", row, &nv), 2));
851 CPLCHECK_NUL (
"Cannot extract UVCOORD");
854 cpl_array * model_vis = cpl_array_new (nwave, CPL_TYPE_DOUBLE);
855 cpl_array * model_vis2 = cpl_array_new (nwave, CPL_TYPE_DOUBLE);
858 for (cpl_size wave = 0; wave < nwave ; wave ++){
860 lambda = cpl_table_get (oi_wavelength,
"EFF_WAVE", wave, &nv);
865 cpl_array_set_double (model_vis, wave, tf_v);
866 cpl_array_set_double (model_vis2, wave, tf_v2);
871 cpl_array * tf_vis = cpl_table_get_data_array (tf_vistable,
"VISAMP")[row];
872 cpl_array * tf_visErr = cpl_table_get_data_array (tf_vistable,
"VISAMPERR")[row];
873 cpl_array_divide (tf_vis, model_vis);
874 cpl_array_divide (tf_visErr, model_vis);
877 cpl_array * tf_vis2 = cpl_table_get_data_array (tf_vis2table,
"VIS2DATA")[row];
878 cpl_array * tf_vis2Err = cpl_table_get_data_array (tf_vis2table,
"VIS2ERR")[row];
879 cpl_array_divide (tf_vis2, model_vis2);
880 cpl_array_divide (tf_vis2Err, model_vis2);
882 CPLCHECK_NUL(
"Cannot set the tf array");
901 sprintf (qc_name,
"ESO QC TF VISMOD_%s%s RELERR", GRAVI_TYPE(type_data), GRAVI_BASE_NAME[base]);
902 gravi_pfits_update_double (plist, qc_name, errRelTF);
903 cpl_propertylist_set_comment (plist, qc_name,
"TF rel.err from diameter at 2.2um");
904 CPLCHECK_NUL (
"QC TF VISMOD RELERR");
906 sprintf (qc_name,
"ESO QC TF VISAMP_%s%s_P%d MED", GRAVI_TYPE(type_data), GRAVI_BASE_NAME[base], pol+1);
907 gravi_pfits_update_double (plist, qc_name, cpl_array_get_median (tf_vis));
908 cpl_propertylist_set_comment (plist, qc_name,
"TF. VIS median over lbd.");
909 CPLCHECK_NUL (
"QC TF VIS AVG");
911 sprintf (qc_name,
"ESO QC TF VIS2_%s%s_P%d MED", GRAVI_TYPE(type_data), GRAVI_BASE_NAME[base], pol+1);
912 gravi_pfits_update_double (plist, qc_name, cpl_array_get_median (tf_vis2));
913 cpl_propertylist_set_comment (plist, qc_name,
"TF. VIS2 median over lbd.");
914 CPLCHECK_NUL (
"QC TF VIS2 AVG");
917 cpl_array_delete (model_vis2);
918 cpl_array_delete (model_vis);
927 if ( (row_cat > -1) && (sep < 5.0) ) {
931 const char sta = *cpl_table_get_string (oi_array,
"TEL_NAME", 0);
932 if (*cpl_table_get_string (oi_array,
"TEL_NAME", 1) != sta ||
933 *cpl_table_get_string (oi_array,
"TEL_NAME", 2) != sta ||
934 *cpl_table_get_string (oi_array,
"TEL_NAME", 3) != sta)
936 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"AT/UT mode is not supported");
942 if (sta==
'U') { diam = 8.0; cpl_msg_info (cpl_func,
"Use UTs"); }
943 else if (sta==
'A') { diam = 1.8; cpl_msg_info (cpl_func,
"Use ATs"); }
944 else { diam = 1.0; cpl_msg_warning (cpl_func,
"Cannot find the diameter of telescope"); }
947 double Kmag = cpl_table_get (diam_table,
"Kmag", row_cat, NULL);
948 double flux0 = 1.71173e+09 * pow (10.0, -Kmag/2.5) * (CPL_MATH_PI * pow (diam/2, 2));
949 cpl_msg_info (cpl_func,
"Use Kmag=%.2f for QC.TRANS", Kmag);
952 for (
int tel = 0; tel < 4; tel++) {
956 sprintf (qc_name,
"ESO QC FLUXRATE_%s%i_P1 SUM",GRAVI_TYPE(type_data),tel+1);
957 flux += gravi_pfits_get_double_silentdefault (plist, qc_name, 0.);
958 sprintf (qc_name,
"ESO QC FLUXRATE_%s%i_P2 SUM",GRAVI_TYPE(type_data),tel+1);
959 flux += gravi_pfits_get_double_silentdefault (plist, qc_name, 0.);
960 CPLCHECK_NUL (
"Cannot get fluxrate");
963 sprintf (qc_name,
"ESO QC TF TRANS_%s%i",GRAVI_TYPE(type_data),tel+1);
964 gravi_pfits_update_double (plist, qc_name, flux / flux0 * 100.0);
965 cpl_propertylist_set_comment (plist, qc_name,
"[%] Total transmission");
966 cpl_msg_info (cpl_func,
"%s = %.2f%%", qc_name, flux / flux0 * 100.0);
967 CPLCHECK_NUL (
"QC TRANS");
974 gravi_msg_function_exit(1);
994 gravi_msg_function_start(0);
995 cpl_ensure_code (oi_vis, CPL_ERROR_NULL_INPUT);
997 cpl_errorstate prestate = cpl_errorstate_get();
999 cpl_msg_info (cpl_func,
"Compute the QC TF parameters");
1005 if ( cpl_error_get_code() || oi_tf == NULL) {
1006 cpl_msg_warning (cpl_func,
"Cannot compute the QC TF parameters for this observation... continue.");
1007 cpl_errorstate_set (prestate);
1008 return CPL_ERROR_NONE;
1012 cpl_propertylist_copy_property_regexp (gravi_data_get_header (oi_vis),
1013 gravi_data_get_header (oi_tf),
1017 gravi_msg_function_exit(0);
1018 return CPL_ERROR_NONE;
1029 gravi_msg_function_start(1);
1030 cpl_ensure (vis_calib, CPL_ERROR_NULL_INPUT, NULL);
1031 cpl_ensure (num_calib>0, CPL_ERROR_ILLEGAL_INPUT, NULL);
1035 gravi_msg_function_exit(1);
gravi_data * gravi_calibrate_vis(gravi_data *vis_data, gravi_data **tf_data, int num_tf, gravi_data *zero, gravi_data *tf_science, const cpl_parameterlist *parlist)
Computes the calibrated visibility from science a single data and several previously evaluated instru...
char * gravi_calib_setupstring(gravi_data *data)
Build a unique setup string per calibratable setup.
cpl_error_code gravi_compute_tf_qc(gravi_data *oi_vis, gravi_data *diamcat_data)
Fill QC parameters related to transfer function.
gravi_data * gravi_compute_zp(gravi_data **vis_calib, int num_calib)
Compute the ZP data.
cpl_array * gravi_array_cexp(double complex factor, const cpl_array *input)
Compute the complex exponention of an array: cexp (factor * input)
int gravi_array_set_invalid_negative(cpl_array *array)
Set invalid to all negative elements of an array.
cpl_table * gravi_data_get_table(gravi_data *self, const char *extname)
Return a pointer on a table extension by its EXTNAME.
gravi_data * gravi_compute_tf(gravi_data *vis_data, gravi_data *diamcat_data)
This function evaluates the transfer function from the observation of a reference star whose diameter...
double gravi_visibility_UD(double uv, double diam, double lbd)
Compute the expected visibility from a UD model.
cpl_error_code gravi_vis_flag_negative(cpl_table *oi_table, const char *data, const char *flag)
Flag negative element of an OIFITS table.
cpl_size gravi_get_row_in_cat(cpl_table *diam_table, double ra, double dec, double *separation)
Get the row in a cpl_table matching closest RAJ2000 and DEJ2000.
cpl_table * gravi_data_get_table_x(gravi_data *self, int i)
Get the table of an extension by position.
void gravi_data_delete(gravi_data *self)
Delete a gravi data.
gravi_data * gravi_data_duplicate(const gravi_data *self)
Create a copy of the gravi data.
cpl_error_code gravi_apply_tf_amp(gravi_data *science, gravi_data *science_tf, gravi_data **used_tf_data, int num_tf_data, const char *extName, const char *insName, const char *ampName, const char *ampErrName, int nbase, double delta_t)
Interpolate the TF at the time of the science observation for an amplitude quantity.
cpl_error_code gravi_apply_tf_phi(gravi_data *science, gravi_data *science_tf, gravi_data **used_tf_data, int num_tf_data, const char *extName, const char *insName, const char *phiName, const char *phiErrName, int nbase, double delta_t)
Interpolate the TF at the time of the science observation for a phase quantity (in deg)...
cpl_error_code gravi_vis_flag_invalid(cpl_table *oi_table, const char *data, const char *flag)
Flag invalid element of an OIFITS table.
cpl_table * gravi_data_get_oi_table(gravi_data *self, const char *extname, const char *insname)
Get an OI_FITS table from EXTNAME and INSNAME.