70 cpl_errorstate prestate = cpl_errorstate_get();
72 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
78 cpl_errorstate prestate = cpl_errorstate_get();
80 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
86 cpl_errorstate prestate = cpl_errorstate_get();
88 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
94 cpl_errorstate prestate = cpl_errorstate_get();
95 int value = cpl_propertylist_get_int(
plist,
"ESO DET2 FRAM STRX");
96 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
102 cpl_errorstate prestate = cpl_errorstate_get();
105 const char * keyword = ( type_data ==
GRAVI_FT ?
"ESO FT ROBJ "
106 "DIAMETER" :
"ESO INS SOBJ DIAMETER" );
107 if (cpl_propertylist_has (
plist, keyword)) {
108 value = cpl_propertylist_get_double(
plist, keyword );
111 cpl_msg_warning (cpl_func,
"The keyword %s does not "
112 "exist in the propertylist", keyword);
115 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
121 const char * keyword =
"ESO FT ROBJ PMA";
128 const char * keyword =
"ESO FT ROBJ PMD";
135 const char * keyword =
"ESO FT ROBJ PARALLAX";
142 cpl_errorstate prestate = cpl_errorstate_get();
143 const char * value = cpl_propertylist_get_string(
plist,
"EXTNAME");
144 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(),
"");
150 const char * value = cpl_propertylist_get_string(
plist,
"ESO DPR TYPE");
151 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
157 const char * value = cpl_propertylist_get_string(
plist,
"ESO INS FILT2 NAME");
158 cpl_ensure(value != NULL, cpl_error_get_code(), NULL);
164 const char * value = cpl_propertylist_get_string(
plist,
"ESO INS SPEC RES");
165 cpl_ensure(value != NULL, cpl_error_get_code(), NULL);
171 const char * keyword = ( type_data ==
GRAVI_FT ?
"ESO FT POLA MODE" :
"ESO INS POLA MODE");
172 const char * value = cpl_propertylist_get_string(
plist, keyword);
173 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
179 cpl_ensure (frame, CPL_ERROR_NULL_INPUT, 0);
180 const char * value = cpl_frame_get_tag (frame);
182 cpl_ensure (value != NULL, cpl_error_get_code(), 0);
183 if (strstr(value,
"SINGLE")) {
186 if (strstr(value,
"DUAL")) {
197 if (cpl_propertylist_has (
plist,
"ESO PRO CATG"))
198 type = cpl_propertylist_get_string (
plist,
"ESO PRO CATG");
199 else if (cpl_propertylist_has (
plist,
"ESO DPR TYPE"))
200 type = cpl_propertylist_get_string (
plist,
"ESO DPR TYPE");
203 if (strstr (type,
"SINGLE")) {
206 if (strstr (type,
"DUAL")) {
215 const char * type=NULL;
222 if (cpl_propertylist_has (
plist,
"ESO INS ROOF POS")) {
223 type = cpl_propertylist_get_string (
plist,
"ESO INS ROOF POS");
225 if (cpl_propertylist_has (
plist,
"ESO INS OPTI11 ID")) {
226 type = cpl_propertylist_get_string (
plist,
"ESO INS OPTI11 ID");
227 cpl_msg_warning (cpl_func,
"Using ESO INS OPTI11 ID (making use of historic method)");
231 if (type == NULL)
return -1;
232 if (strstr (type,
"OFFAXIS")) {
235 if (strstr (type,
"ONAXIS")) {
244 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, NULL);
247 if (cpl_propertylist_has (
plist,
"ESO PRO CATG"))
248 type = cpl_propertylist_get_string (
plist,
"ESO PRO CATG");
249 else if (cpl_propertylist_has (
plist,
"ESO DPR TYPE"))
250 type = cpl_propertylist_get_string (
plist,
"ESO DPR TYPE");
251 else return "UNKNOWN";
253 if (strstr (type,
"SINGLE")) {
256 if (strstr (type,
"DUAL")) {
265 const char * keyword = ( type_data ==
GRAVI_FT ?
"ESO FT POLA MODE" :
"ESO INS POLA MODE");
266 const char * value = cpl_propertylist_get_string(
plist, keyword);
267 cpl_ensure (value != NULL, cpl_error_get_code(), 0);
268 return ( !(strcmp(value,
"SPLIT")) ? 2 : 1 );
273 cpl_errorstate prestate = cpl_errorstate_get();
275 const char * value = cpl_propertylist_get_string (
plist,
"XTENSION");
276 cpl_ensure (value, CPL_ERROR_ILLEGAL_INPUT, 0);
280 if (! strcmp(value,
"IMAGE"))
282 else if (! strcmp(value,
"BINTABLE"))
284 else if (! strcmp(value,
"TABLE"))
287 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
288 "Type extension is incorrect");
291 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
297 cpl_errorstate prestate = cpl_errorstate_get();
299 char *lock = cpl_sprintf (
"ESO OCS MET LKDT_FC%i", tel+1);
302 if (!cpl_errorstate_is_equal(prestate)) {
303 cpl_errorstate_set (prestate);
304 cpl_msg_warning (cpl_func,
"Cannot read %s", lock);
315 double lambda_met_mean = met_wavelength_ref +
316 cpl_table_get_column_mean(met_table,
"LAMBDA_LASER")*1e-9;
318 return (lambda_met_mean);
323 cpl_errorstate prestate = cpl_errorstate_get();
326 double wavelength = 0.0;
331 if (cpl_propertylist_has (
plist,
"ESO INS MLC POWER") == FALSE) {
333 cpl_msg_warning (cpl_func,
"Cannot read the laser POWER : use MLC wavelength : %f ", wavelength);
340 cpl_msg_info(cpl_func,
"Using laser MLC wavelength : %f ", wavelength);
347 wavelength = cpl_propertylist_get_double(
plist,
"ESO INS MLAS LWAV");
348 cpl_msg_info(cpl_func,
"Using laser MLAS wavelength : %f ", wavelength);
351 if (!cpl_errorstate_is_equal(prestate)) {
352 cpl_msg_warning (cpl_func,
"Cannot read the laser wavelength in the header : %s", cpl_error_get_message());
353 cpl_errorstate_set (prestate);
363 if ( !strcmp(value,
"FAINT") ) {
382 const char * faint_keys[]={
"ESO INS ANLO3 RATE1",\
383 "ESO INS ANLO3 REPEAT1",\
384 "ESO INS ANLO3 TIMER1",\
385 "ESO INS ANLO3 RATE2",\
386 "ESO INS ANLO3 REPEAT2",\
387 "ESO INS ANLO3 TIMER2"};
389 cpl_vector * faint_params = cpl_vector_new(
sizeof(faint_keys)/
sizeof(faint_keys[0]));
391 cpl_vector_fill(faint_params, 0.0);
393 for(
size_t i=0;i<
sizeof(faint_keys)/
sizeof(faint_keys[0]);i++)
395 cpl_errorstate prestate = cpl_errorstate_get();
396 cpl_type par_type = cpl_propertylist_get_type(
plist, faint_keys[i]);
397 if(par_type==CPL_TYPE_INT)
399 cpl_vector_set(faint_params,i,(
double) cpl_propertylist_get_int(
plist, faint_keys[i]));
403 cpl_vector_set(faint_params,i,cpl_propertylist_get_double(
plist, faint_keys[i]));
405 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), faint_params);
413 cpl_errorstate prestate = cpl_errorstate_get();
414 double value = cpl_propertylist_get_double(
plist,
"ESO ISS GEOLAT");
415 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
421 cpl_errorstate prestate = cpl_errorstate_get();
422 double value = cpl_propertylist_get_double(
plist,
"ESO ISS GEOLON");
423 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
429 cpl_errorstate prestate = cpl_errorstate_get();
430 double value = cpl_propertylist_get_double (
plist,
"ESO ISS GEOELEV");
431 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
449 cpl_errorstate prestate = cpl_errorstate_get();
450 double value = cpl_propertylist_get_double (
plist,
"ESO INS SOBJ DIAMETER");
451 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
486 return (value1+value2+value3+value4)*0.25;
496 return (value1+value2+value3+value4)*0.25;
507 cpl_errorstate prestate = cpl_errorstate_get();
508 double value = cpl_propertylist_get_double(
plist,
"ESO FT ROBJ DIAMETER");
509 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
520 cpl_errorstate prestate = cpl_errorstate_get();
521 double value = cpl_propertylist_get_double(
plist,
"ESO INS FDDL WINDOW");
522 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
528 cpl_errorstate prestate = cpl_errorstate_get();
529 double value = cpl_propertylist_get_double(
plist,
"MJD-OBS");
530 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
536 const char * tim1_start = cpl_propertylist_get_string(
plist,
"ESO OCS MET PH_DATE");
537 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
544 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
549 sprintf (name,
"ESO QC MET GD_ZERO_FC%i", tel);
550 if (cpl_propertylist_has(
plist, name))
554 sprintf (name,
"ESO PRO MET GD_ZERO_FC%i", tel);
555 if (cpl_propertylist_has(
plist, name))
565 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
570 sprintf (name,
"ESO QC MET GD_ZERO_FC%i", tel);
571 if (cpl_propertylist_has(
plist, name)) {
575 sprintf (name,
"ESO PRO MET GD_ZERO_FC%i", tel);
576 if (cpl_propertylist_has(
plist, name)) {
589 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
594 sprintf (name,
"ESO QC MET OPL_ZERO_FC%i", tel);
595 if (cpl_propertylist_has(
plist, name)) {
598 sprintf (name,
"ESO PRO MET OPL_ZERO_FC%i", tel);
599 if (cpl_propertylist_has(
plist, name))
609 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
614 sprintf (name,
"ESO QC MET OPL_ZERO_FC%i", tel);
615 if (cpl_propertylist_has(
plist, name)) {
619 sprintf (name,
"ESO PRO MET OPL_ZERO_FC%i", tel);
620 if (cpl_propertylist_has(
plist, name)) {
634 const char * tim1_start = cpl_propertylist_get_string(
plist,
"ESO INS TIM1 START");
635 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
642 const char * tim1_start = cpl_propertylist_get_string(
plist,
"ESO INS TIM2 START");
643 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
650 const char * acq_start = cpl_propertylist_get_string(
plist,
"ESO PCR ACQ START");
651 cpl_ensure (acq_start != NULL, cpl_error_get_code(), NULL);
658 cpl_errorstate prestate = cpl_errorstate_get();
659 double value = cpl_propertylist_get_double(
plist,
"ESO DET1 SEQ1 DIT");
660 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
667 cpl_errorstate prestate = cpl_errorstate_get();
668 double value = cpl_propertylist_get_double(
plist,
"ESO DET2 SEQ1 DIT");
669 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
676 cpl_errorstate prestate = cpl_errorstate_get();
677 double value = cpl_propertylist_get_double(
plist,
"ESO DET3 SEQ1 DIT");
678 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
685 cpl_errorstate prestate = cpl_errorstate_get();
686 double value = cpl_propertylist_get_double(
plist,
"ESO INS TIM1 PERIOD");
687 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
694 cpl_errorstate prestate = cpl_errorstate_get();
695 double value = cpl_propertylist_get_double(
plist,
"ESO INS TIM2 PERIOD");
696 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
713 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, 0.0);
714 cpl_errorstate prestate = cpl_errorstate_get();
721 double extra_time_faint = 0.0;
723 extra_time_faint = 1.0;
726 double time = 86400 * 1e6 *
729 (period-window_time-extra_time_faint)/2. * 1e6 +
733 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
752 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, 0.0);
753 cpl_ensure (row>=0, CPL_ERROR_ILLEGAL_INPUT, 0.0);
754 cpl_errorstate prestate = cpl_errorstate_get();
760 double time = 86400 * 1e6 *
767 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
775 cpl_errorstate prestate = cpl_errorstate_get();
777 sprintf (name,
"ESO ACQ PTFC REFPOS%i", spot);
778 double value = cpl_propertylist_get_double (
plist, name);
779 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
788 sprintf (name,
"ESO INS DROTOFF%i", tel+1);
789 double drottoff = cpl_propertylist_get_double (
plist, name);
799 sprintf (name,
"ESO INS DROTOFF%i", tel+1);
801 if (cpl_propertylist_has(
plist,
"ESO ACQ NORTHANG"))
803 fangle = cpl_propertylist_get_double (
plist,
"ESO ACQ NORTHANG");
804 cpl_msg_warning( cpl_func,
"Using ACQ Camera North angle from header" );
805 cpl_msg_warning (cpl_func,
"North angle = %.2f [deg] / NorthACQ in Y to X", fangle);
809 if (cpl_propertylist_has (
plist,
"ESO INS SOBJ X") &&
810 cpl_propertylist_has (
plist,
"ESO INS SOBJ Y") &&
811 cpl_propertylist_has (
plist, name)) {
814 double drottoff = cpl_propertylist_get_double (
plist, name);
817 double dx = cpl_propertylist_get_double (
plist,
"ESO INS SOBJ X");
818 double dy = cpl_propertylist_get_double (
plist,
"ESO INS SOBJ Y");
821 double posangle = 0.0;
822 if (cpl_propertylist_has(
plist,
"ESO INS SOBJ OFFX") &&
823 cpl_propertylist_has(
plist,
"ESO INS SOBJ OFFY")) {
828 if ((fabs(dx)>0.0) || (fabs(dy)>0.0))
829 posangle = atan2 (dx, dy) * CPL_MATH_DEG_RAD;
832 fangle = - posangle - drottoff + 270;
833 if (fangle >= 180) fangle -= 360.0;
834 if (fangle < -180) fangle += 360.0;
835 if (fangle >= 180) fangle -= 360.0;
836 if (fangle < -180) fangle += 360.0;
838 cpl_msg_info (cpl_func,
"Acquisition camera North angle (tel=%i) = %.2f [deg] / NorthACQ in Y to X", (tel+1), fangle);
842 cpl_msg_warning (cpl_func,
"Cannot compute North angle: fangle = 0.0");
854 char pupilrot_start_name[90];
855 char pupilrot_end_name[90];
856 char drot_enc_start_name[90];
857 char drot_enc_end_name[90];
858 char kmiroff_name[90];
859 char rotoff_name[90];
861 sprintf (pupilrot_start_name,
"ESO ISS IP%i PUPILROT START", 7-tel*2);
862 sprintf (pupilrot_end_name,
"ESO ISS IP%i PUPILROT END", 7-tel*2);
863 sprintf (drot_enc_start_name,
"ESO INS DROT%i ENC START", tel+1);
864 sprintf (drot_enc_end_name,
"ESO INS DROT%i ENC END", tel+1);
865 sprintf (kmiroff_name,
"ESO INS KMIRROROFFSET%i", tel+1);
866 sprintf (rotoff_name,
"ESO INS ROTATIONOFFSET%i", tel+1);
869 if (cpl_propertylist_has (
plist, pupilrot_start_name) &&
870 cpl_propertylist_has (
plist, pupilrot_end_name) &&
871 cpl_propertylist_has (
plist, drot_enc_start_name) &&
872 cpl_propertylist_has (
plist, drot_enc_end_name) &&
873 cpl_propertylist_has (
plist, kmiroff_name) &&
874 cpl_propertylist_has (
plist, rotoff_name)) {
877 double pupilrot1 = cpl_propertylist_get_double(
plist, pupilrot_start_name);
878 double pupilrot2 = cpl_propertylist_get_double(
plist, pupilrot_end_name);
880 double prdif = pupilrot2 - pupilrot1;
885 double pupilrot = pupilrot1 + prdif*n/(nrow-1);
888 int drotenc1 = cpl_propertylist_get_int(
plist, drot_enc_start_name);
889 int drotenc2 = cpl_propertylist_get_int(
plist, drot_enc_end_name);
891 double drotencdif = (double)drotenc2 - (
double)drotenc1;
892 double posenc = (double)drotenc1 + drotencdif*n/(nrow-1);
895 double kmirroroffset = cpl_propertylist_get_double(
plist, kmiroff_name);
898 double rotoff = cpl_propertylist_get_double(
plist, rotoff_name);
900 zangle = pupilrot + 90. - posenc / 200. - kmirroroffset - rotoff + 180.;
901 if (zangle >= 180) zangle -= 360.0;
902 if (zangle < -180) zangle += 360.0;
904 cpl_msg_info (cpl_func,
"Acquisition camera Zenith angle Beam B (tel=%i) = %.2f [deg] / ZenithACQ in Y to X", (tel+1), zangle);
908 cpl_msg_warning (cpl_func,
"Cannot compute Zenith angle for Beam B: zangle = 0.0");
917 const char * value = cpl_propertylist_get_string(
plist,
"INSNAME");
918 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
934 if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
935 cpl_propertylist_has (
plist,
"ESO INS DET3 GAIN") &&
936 cpl_propertylist_get_double (
plist,
"MJD-OBS") >= 57584.83 &&
937 cpl_propertylist_get_double (
plist,
"MJD-OBS") < 57617.0) {
941 gain = cpl_propertylist_get_double (
plist,
"ESO INS DET3 GAIN");
942 if (gain == 3.0) gain = 1.7;
943 cpl_msg_warning (cpl_func,
"Use FT gain of %.3f [adu/e] (wrong units and value in header)", gain);
944 }
else if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
945 cpl_propertylist_has (
plist,
"ESO INS DET3 GAIN") &&
946 cpl_propertylist_get_double (
plist,
"MJD-OBS") >= 57617.0) {
949 gain = 1. / cpl_propertylist_get_double (
plist,
"ESO INS DET3 GAIN");
950 cpl_msg_info (cpl_func,
"Use FT gain of %.3f [adu/e] from header", gain);
954 cpl_msg_warning (cpl_func,
"Force FT gain to %.3f [adu/e] (wrong value or no value in header)", gain);
973 if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
974 cpl_propertylist_has (
plist,
"ESO INS DET2 GAIN") &&
975 cpl_propertylist_get_double (
plist,
"MJD-OBS") > 57617.0) {
978 gain = 1. / cpl_propertylist_get_double (
plist,
"ESO INS DET2 GAIN");
979 cpl_msg_info (cpl_func,
"Use SC gain of %.3f [adu/e] from header", gain);
983 cpl_msg_warning (cpl_func,
"Force SC gain to %.3f [adu/e]", gain);
1008 cpl_propertylist * o_plist = cpl_propertylist_new ();
1011 cpl_propertylist_update_string (o_plist,
"CONTENT",
"OIFITS2");
1012 cpl_propertylist_update_string (o_plist,
"REFERENC",
"2001PASP..112.1133P");
1016 cpl_propertylist_update_string (o_plist,
"OBSERVER", observer);
1020 cpl_propertylist_update_string (o_plist,
"PROG_ID", prog_id);
1023 char * procsoft = cpl_sprintf(
"GRAVITY pipeline %s", PACKAGE_VERSION);
1024 cpl_propertylist_update_string (o_plist,
"PROCSOFT", procsoft);
1025 FREE (cpl_free, procsoft);
1030 char *
object = cpl_sprintf (
"%s,%s", sc_object, ft_object);
1031 cpl_propertylist_update_string (o_plist,
"OBJECT",
object);
1032 FREE (cpl_free,
object);
1036 mode = cpl_sprintf (
"%s,%s,%s,%s",
1041 cpl_propertylist_update_string (o_plist,
"INSMODE", mode);
1042 FREE (cpl_free, mode);
1044 CPLCHECK_NUL (
"Cannot fill the OIFITS2 specific keywords");
1061 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, NULL);
1064 const char* param_value=NULL;
1065 const char * param_name =
"extra-pixel-ft";
1068 sprintf (key,
"ESO PRO REC1 PARAM%d NAME",key_index);
1069 while (cpl_propertylist_has(
header, key)){
1070 if (!strcmp(cpl_propertylist_get_string(
header, key), param_name))
1072 sprintf (key,
"ESO PRO REC1 PARAM%d VALUE",key_index);
1073 param_value = cpl_propertylist_get_string(
header, key);
1074 cpl_msg_info (cpl_func,
"Retrieve the extra-pixel-ft option from the p2vm: [%s] ", param_value);
1076 sprintf (key,
"ESO PRO REC1 PARAM%d NAME", ++key_index);
1079 cpl_parameter * p = cpl_parameter_new_value (
"gravity.preproc.extra-pixel-ft", CPL_TYPE_BOOL,
1080 "Include the 6th pixels ot the FT",
1081 "gravity.preproc", TRUE);
1082 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"extra-pixel-ft");
1084 if (param_value != NULL && !strcmp(param_value,
"true"))
1085 cpl_parameter_set_bool(p, 1);
1087 cpl_parameter_set_bool(p, 0);
1089 cpl_msg_info(cpl_func,
"Set extra-pixel-ft option : [%d] ", cpl_parameter_get_bool(p));
1103 const char * qc =
" QC ";
1106 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, NULL);
1109 cpl_propertylist * applist = cpl_propertylist_new();
1110 cpl_size size = cpl_propertylist_get_size (
header);
1111 for (cpl_size i = 0; i < size; i++) {
1112 cpl_property * p = cpl_propertylist_get (
header, i);
1113 const char * p_name = cpl_property_get_name (p);
1114 if ( (strstr(p_name, qc) != NULL) ||
1116 cpl_type type_qc = cpl_property_get_type (p);
1118 case CPL_TYPE_FLOAT :
1119 if (cpl_property_get_float (p) != NAN)
1120 cpl_propertylist_append_property(applist, p);
1122 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1124 case CPL_TYPE_DOUBLE :
1125 if (cpl_property_get_double (p) != NAN)
1126 cpl_propertylist_append_property(applist, p);
1128 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1131 if (cpl_property_get_int (p) != NAN)
1132 cpl_propertylist_append_property(applist, p);
1134 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1136 case CPL_TYPE_STRING :
1137 if (cpl_property_get_string (p))
1138 cpl_propertylist_append_property(applist, p);
1140 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1142 case CPL_TYPE_CHAR :
1143 if (cpl_property_get_char (p))
1144 cpl_propertylist_append_property(applist, p);
1146 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1148 case CPL_TYPE_BOOL :
1149 cpl_propertylist_append_property (applist, p);
1152 cpl_msg_error (cpl_func,
"'%s' is an invalid type of property",p_name);
1153 cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE,
1154 "invalid type of property");
1168 cpl_ensure (start, CPL_ERROR_NULL_INPUT, 0.0);
1172 char * str = cpl_strdup (start);
1180 int iy = atoi (str+0);
1181 int im = atoi (str+5);
1182 int id = atoi (str+8);
1183 double dhr = atof (str+11);
1184 double dmin = atof (str+14);
1185 double dsec = atof (str+17);
1190 eraCal2jd (iy, im,
id, &dmjd0, &dmjd);
1193 return dmjd + (dhr + (dmin + dsec/60.0)/60.0)/24.0;
1198 int year, month, day, hour, minute;
1199 double fraction, second;
1201 eraJd2cal (2400000.5, mjd, &year, &month, &day, &fraction);
1203 hour = (int)(fraction/3600.0);
1204 fraction -= hour*3600.0;
1205 minute = (int)(fraction/60.0);
1206 fraction -= minute*60.0;
1209 return cpl_sprintf (
"%04i-%02i-%02iT%02i:%02i:%06.3f", year, month, day, hour, minute, second);
1214 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0.0);
1215 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1225 double sdecz = sin(decz);
1226 double cdecz = cos(decz);
1227 double denom = cdecz - eta * sdecz;
1230 double dec = atan2 (sdecz+eta*cdecz, sqrt(xi*xi + denom*denom));
1238 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1241 char * str = cpl_strdup (stri);
1248 out += atof(str+3) / 60;
1249 out += atof(str+6) / 3600;
1252 return out / 12 * CPL_MATH_PI;
1257 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1260 char * str = cpl_strdup (stri);
1267 out += atof(str+4) / 60;
1268 out += atof(str+7) / 3600;
1270 out *= (str[0]==
'-' ? -1.0 : 1.0);
1273 return out / 180 * CPL_MATH_PI;
1283 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0.0);
1284 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1294 double sdecz = sin(decz);
1295 double cdecz = cos(decz);
1296 double denom = cdecz - eta * sdecz;
1299 double ra = atan2 (xi,denom) + raz;
1302 ra = fmod (ra, CPL_MATH_2PI);
1303 if ( ra < 0.0 ) ra += CPL_MATH_2PI;
1311 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 99.);
1312 cpl_errorstate prestate = cpl_errorstate_get();
1316 const char * str_value;
1325 strncpy(tmp, str_value, 2);
1327 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1331 strncpy(tmp, str_value+2, 4);
1333 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1334 value += atof(tmp) / 60.0;
1337 strcpy(tmp, str_value+4);
1338 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1339 value += atof(tmp) / 3600.0;
1345 cpl_msg_debug( cpl_func,
"Convert RA='%s' into RA=%fdeg", str_value, value);
1347 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1348 cpl_errorstate_set (prestate);
1349 cpl_msg_warning(cpl_func,
"rarp doesn't exist in this file.");
1355 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1358 return value * CPL_MATH_RAD_DEG;
1363 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 99.);
1365 cpl_errorstate prestate = cpl_errorstate_get();
1370 const char * str_value;
1378 if ( str_value[0] ==
'-' ) {
1380 str_value = str_value + 1;
1381 }
else if ( str_value[0] ==
'+' ) {
1383 str_value = str_value + 1;
1389 strncpy(tmp, str_value, 2);
1391 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1395 strncpy(tmp, str_value+2, 4);
1397 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1398 value += atof(tmp) / 60.0;
1401 strcpy(tmp, str_value+4);
1402 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1403 value += atof(tmp) / 3600.0;
1409 cpl_msg_debug( cpl_func,
"Convert DEC='%s' into DEC=%fdeg", str_value, value);
1411 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1412 cpl_errorstate_set (prestate);
1413 cpl_msg_warning(cpl_func,
"decep doesn't exist in this file.");
1420 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1423 return value * CPL_MATH_RAD_DEG;
1432 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
1433 const char * opt1 =
"ESO INS OPTI1 NAME";
1435 if ( !cpl_propertylist_has (
plist, opt1) )
return 0;
1437 const char * value = cpl_propertylist_get_string (
plist, opt1);
1438 if ( !strcmp (value,
"CALIB") )
return 1;
1464 cpl_ensure (self, CPL_ERROR_NULL_INPUT, 0);
1465 cpl_ensure (name, CPL_ERROR_NULL_INPUT, 0);
1466 cpl_ensure (cpl_propertylist_has (self, name), CPL_ERROR_DATA_NOT_FOUND, 0);
1468 cpl_type type = cpl_propertylist_get_type (self, name);
1471 case CPL_TYPE_UCHAR:
1473 case CPL_TYPE_SHORT:
1474 case CPL_TYPE_USHORT:
1478 case CPL_TYPE_LONG_LONG:
1479 case CPL_TYPE_ULONG:
1481 return cpl_propertylist_get_long(self, name);
1482 case CPL_TYPE_FLOAT:
1483 case CPL_TYPE_DOUBLE:
1484 return cpl_propertylist_get_double(self, name);
1485 case CPL_TYPE_STRING:
1486 cpl_msg_debug (cpl_func,
"FITS card %s is string '%s' to double %f",
1487 name,cpl_propertylist_get_string(self, name),atof(cpl_propertylist_get_string(self, name)));
1488 return atof(cpl_propertylist_get_string(self, name));
1490 cpl_error_set(cpl_func, CPL_ERROR_TYPE_MISMATCH);
1498 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
1499 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1503 char * comment = cpl_sprintf (
"%s", cpl_propertylist_get_comment (self, name));
1506 cpl_propertylist_erase (self, name);
1507 cpl_propertylist_append_double (self, name, value );
1508 cpl_propertylist_set_comment (self, name, comment);
1511 return cpl_error_get_code();
1519 const char * full_name,
double value)
1521 cpl_error_code code;
1522 cpl_ensure_code (
plist, CPL_ERROR_NULL_INPUT);
1523 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1532 if ( (code=cpl_error_get_code()) ) {
1533 cpl_msg_warning (cpl_func,
"Cannot set keyword: %s", full_name);
1534 return cpl_error_set_message(cpl_func, code,
"Cannot set keyword: %s", full_name);
1537 return CPL_ERROR_NONE;
1541 const char * full_name,
int value)
1543 cpl_error_code code;
1544 cpl_ensure_code (
plist, CPL_ERROR_NULL_INPUT);
1545 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1548 if ( isnan((
double)value) )
1551 cpl_propertylist_update_int (
plist, full_name, value);
1554 if ( (code=cpl_error_get_code()) ) {
1555 cpl_msg_warning (cpl_func,
"Cannot set keyword: %s", full_name);
1556 return cpl_error_set_message(cpl_func, code,
"Cannot set keyword: %s", full_name);
1559 return CPL_ERROR_NONE;
1566 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1567 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1571 if (cpl_propertylist_has(
plist, name)) {
1573 output = cpl_propertylist_get_string(
plist, name);
1579 cpl_msg_warning (cpl_func,
"Can't find keyword %s (use '%s')", name, def);
1581 cpl_msg_info (cpl_func,
"Can't find keyword %s (use '%s')", name, def);
1591 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1592 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1596 if (cpl_propertylist_has(
plist, name)) {
1604 cpl_msg_warning (cpl_func,
"Can't find keyword %s (use '%f')", name, def);
1606 cpl_msg_info (cpl_func,
"Can't find keyword %s (use '%f')", name, def);
1616 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1617 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1620 if (cpl_propertylist_has(
plist, name))
1646 cpl_ensure_code (
header, CPL_ERROR_NULL_INPUT);
1647 cpl_ensure_code (msg, CPL_ERROR_NULL_INPUT);
1651 if (cpl_propertylist_has (
header,
"ESO QC CHECK FLAGS"))
1652 i = cpl_propertylist_get_int (
header,
"ESO QC CHECK FLAGS") + 1;
1654 cpl_propertylist_update_int (
header,
"ESO QC CHECK FLAGS", i);
1659 sprintf (qc_name,
"ESO QC CHECK MSG%i", i);
1661 cpl_msg_warning (cpl_func,
"%s = '%s'", qc_name, msg);
1662 cpl_propertylist_append_string (
header, qc_name, msg);
1667 return CPL_ERROR_NONE;
1686 cpl_ensure_code (
header, CPL_ERROR_NULL_INPUT);
1695 sprintf (name,
"ESO PRO REC%i PIPE LAST_BUILD", i);
1696 }
while (cpl_propertylist_has (
header, name));
1699 sprintf (value,
"%s %s", __DATE__,__TIME__);
1703 cpl_propertylist_update_string (
header, name, value);
1704 cpl_propertylist_set_comment (
header, name,
"Last 'make clean all install'");
1708 return CPL_ERROR_NONE;
cpl_msg_debug(cpl_func, "Spectra has <50 pixels -> don't flat")
cpl_propertylist * header
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
cpl_propertylist_update_double(header, "ESO QC MINWAVE SC", cpl_propertylist_get_double(plist, "ESO QC MINWAVE SC"))
#define PROFILE_FULLSTARTX
#define MET_NORMAL_HEADER
#define gravi_msg_function_exit(flag)
#define FREE(function, variable)
#define CPLCHECK_NUL(msg)
#define gravi_msg_function_start(flag)
#define CPLCHECK_MSG(msg)
int gravi_pfits_get_startx(const cpl_propertylist *plist)
find out the name of the propertylist
double gravi_pfits_get_sobj_offy(const cpl_propertylist *plist)
double gravi_pfits_get_zenithangle_beamb_acqcam(const cpl_propertylist *plist, int tel, int n, int nrow)
const char * gravi_pfits_get_insname(const cpl_propertylist *plist)
cpl_propertylist * gravi_plist_get_oifits_keywords(cpl_propertylist *header)
Create OIFITS keywords to satisfy standar.
cpl_propertylist * gravi_plist_get_qc(cpl_propertylist *header)
Extract QC parameters.
int gravi_pfits_get_pola_num(const cpl_propertylist *plist, int type_data)
const char * gravi_pfits_get_met_ph(const cpl_propertylist *plist)
cpl_error_code gravi_pfits_update_double(cpl_propertylist *plist, const char *full_name, double value)
double gravi_pfits_get_sobj_offx(const cpl_propertylist *plist)
cpl_error_code gravi_pfits_update_int(cpl_propertylist *plist, const char *full_name, int value)
double gravi_pfits_get_gvctu_x(const cpl_propertylist *plist)
const char * gravi_pfits_get_mode_name(const cpl_propertylist *plist)
double gravi_pfits_get_gdzero(const cpl_propertylist *plist, int tel)
double gravi_pfits_get_sobj_y(const cpl_propertylist *plist)
double gravi_pfits_get_robj_diam(const cpl_propertylist *plist)
int gravi_pfits_get_fullstartx(const cpl_propertylist *plist)
double gravi_pfits_get_geolon(const cpl_propertylist *plist)
const char * gravi_pfits_get_sobj(const cpl_propertylist *plist)
int gravi_pfits_get_mode(const cpl_propertylist *plist)
double gravi_pfits_get_metfc_lockmjd(const cpl_propertylist *plist, int tel)
const char * gravi_pfits_get_pola_mode(const cpl_propertylist *plist, int type_data)
double gravi_convert_to_mjd(const char *start)
cpl_error_code gravi_pfits_add_check(cpl_propertylist *header, const char *msg)
Add a QC.CHECK keyword to the header.
int gravi_data_frame_get_mode(const cpl_frame *frame)
double gravi_pfits_get_pmra(const cpl_propertylist *plist)
cpl_error_code gravi_pfits_ensure_double(cpl_propertylist *self, const char *name)
int gravi_pfits_get_extension_type(const cpl_propertylist *plist)
double gravi_pfits_get_oplzero(const cpl_propertylist *plist, int tel)
double gravi_pfits_get_plx(const cpl_propertylist *plist)
cpl_parameter * gravi_pfits_get_extrapixel_param(const cpl_propertylist *header)
Extract parameters from a product header.
const char * gravi_pfits_get_spec_res(const cpl_propertylist *plist)
double gravi_pfits_get_drotoff(const cpl_propertylist *plist, int tel)
int gravi_pfits_is_calib(const cpl_propertylist *plist)
double gravi_pfits_get_robj_raep(const cpl_propertylist *plist)
double gravi_pfits_get_dit_sc(const cpl_propertylist *plist)
double gravi_dec_to_rad(const char *stri)
double gravi_pfits_get_dit_ft(const cpl_propertylist *plist)
const char * gravi_pfits_get_string_default(const cpl_propertylist *plist, const char *name, const char *def)
const char * gravi_pfits_get_robj(const cpl_propertylist *plist)
int gravi_pfits_has_gdzero(const cpl_propertylist *plist, int tel)
double gravi_pfits_get_northangle_acqcam(const cpl_propertylist *plist, int tel)
double gravi_pfits_get_gvctu_y(const cpl_propertylist *plist)
double gravi_pfits_get_met_wavelength_mean(const cpl_propertylist *plist, cpl_table *met_table)
double gravi_pfits_get_dit_acqcam(const cpl_propertylist *plist)
cpl_vector * gravi_pfits_get_met_faint_params(const cpl_propertylist *plist)
Extract metrology faint settings.
double gravi_pfits_get_mjd(const cpl_propertylist *plist)
int gravi_pfits_get_axis(const cpl_propertylist *plist)
const char * gravi_pfits_get_resolution(const cpl_propertylist *plist)
const char * gravi_pfits_get_start_sc(const cpl_propertylist *plist)
double gravi_pfits_get_period_sc(const cpl_propertylist *plist)
double gravi_pfits_get_ft_gain(const cpl_propertylist *plist)
FT system gain in [ADU/e].
double gravi_pfits_get_geolat(const cpl_propertylist *plist)
double gravi_pfits_get_period_acqcam(const cpl_propertylist *plist)
const char * gravi_pfits_get_start_prcacq(const cpl_propertylist *plist)
double gravi_pfits_get_time_sc(const cpl_propertylist *header, cpl_size row)
Time of the middle of the SC exposure row in [us], counted from PRC.ACQ.START.
cpl_error_code gravi_pfits_add_pipe_build(cpl_propertylist *header)
Add the ESO PRO REC# PIPE LAST_BUILD in header.
double gravi_pfits_get_sobj_diam(const cpl_propertylist *plist)
char * gravi_convert_to_timestamp(double mjd)
double gravi_pfits_get_fddlwindow(const cpl_propertylist *plist)
int gravi_pfits_get_nx(const cpl_propertylist *plist)
double gravi_pfits_get_double(const cpl_propertylist *self, const char *name)
Get the double value of the given property list entry.
const char * gravi_pfits_get_feed(const cpl_propertylist *plist)
const char * gravi_pfits_get_dpr_type(const cpl_propertylist *plist)
double gravi_pfits_get_sc_gain(const cpl_propertylist *plist)
SC system gain in [ADU/e].
int gravi_pfits_get_met_mode(const cpl_propertylist *plist)
double gravi_pfits_get_pmdec(const cpl_propertylist *plist)
const char * gravi_pfits_get_extname(const cpl_propertylist *plist)
int gravi_pfits_has_oplzero(const cpl_propertylist *plist, int tel)
double gravi_pfits_get_decep(const cpl_propertylist *plist, double coef)
double gravi_pfits_get_double_silentdefault(const cpl_propertylist *plist, const char *name, double def)
double gravi_pfits_get_sobj_x(const cpl_propertylist *plist)
double gravi_pfits_get_diameter(const cpl_propertylist *plist, int type_data)
double gravi_pfits_get_geoelev(const cpl_propertylist *plist)
double gravi_pfits_get_raep(const cpl_propertylist *plist, double coef)
double gravi_pfits_get_met_wavelength(const cpl_propertylist *plist)
double gravi_ra_to_rad(const char *stri)
double gravi_pfits_get_robj_decep(const cpl_propertylist *plist)
double gravi_pfits_get_time_acqcam(const cpl_propertylist *header, cpl_size row)
Time of the middle of the ACQCAM exposure row in [us], counted from PRC.ACQ.START.
int gravi_pfits_get_window_start(const cpl_propertylist *plist)
double gravi_pfits_get_double_default(const cpl_propertylist *plist, const char *name, double def)
double gravi_pfits_get_ptfc_acqcam(const cpl_propertylist *plist, int spot)
const char * gravi_pfits_get_start_acqcam(const cpl_propertylist *plist)