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 ISS PBL%i%i START", tel1, tel2);
800 double pbl = cpl_propertylist_get_double (
plist, name);
810 sprintf (name,
"ESO ISS PBL%i%i END", tel1, tel2);
811 double pbl = cpl_propertylist_get_double (
plist, name);
821 sprintf (name,
"ESO INS DROTOFF%i", tel+1);
823 if (cpl_propertylist_has(
plist,
"ESO ACQ NORTHANG"))
825 fangle = cpl_propertylist_get_double (
plist,
"ESO ACQ NORTHANG");
826 cpl_msg_warning( cpl_func,
"Using ACQ Camera North angle from header" );
827 cpl_msg_warning (cpl_func,
"North angle = %.2f [deg] / NorthACQ in Y to X", fangle);
831 if (cpl_propertylist_has (
plist,
"ESO INS SOBJ X") &&
832 cpl_propertylist_has (
plist,
"ESO INS SOBJ Y") &&
833 cpl_propertylist_has (
plist, name)) {
836 double drottoff = cpl_propertylist_get_double (
plist, name);
839 double dx = cpl_propertylist_get_double (
plist,
"ESO INS SOBJ X");
840 double dy = cpl_propertylist_get_double (
plist,
"ESO INS SOBJ Y");
843 double posangle = 0.0;
844 if (cpl_propertylist_has(
plist,
"ESO INS SOBJ OFFX") &&
845 cpl_propertylist_has(
plist,
"ESO INS SOBJ OFFY")) {
850 if ((fabs(dx)>0.0) || (fabs(dy)>0.0))
851 posangle = atan2 (dx, dy) * CPL_MATH_DEG_RAD;
854 fangle = - posangle - drottoff + 270;
855 if (fangle >= 180) fangle -= 360.0;
856 if (fangle < -180) fangle += 360.0;
857 if (fangle >= 180) fangle -= 360.0;
858 if (fangle < -180) fangle += 360.0;
860 cpl_msg_info (cpl_func,
"Acquisition camera North angle (tel=%i) = %.2f [deg] / NorthACQ in Y to X", (tel+1), fangle);
864 cpl_msg_warning (cpl_func,
"Cannot compute North angle: fangle = 0.0");
876 char pupilrot_start_name[90];
877 char pupilrot_end_name[90];
878 char drot_enc_start_name[90];
879 char drot_enc_end_name[90];
880 char kmiroff_name[90];
881 char rotoff_name[90];
883 sprintf (pupilrot_start_name,
"ESO ISS IP%i PUPILROT START", 7-tel*2);
884 sprintf (pupilrot_end_name,
"ESO ISS IP%i PUPILROT END", 7-tel*2);
885 sprintf (drot_enc_start_name,
"ESO INS DROT%i ENC START", tel+1);
886 sprintf (drot_enc_end_name,
"ESO INS DROT%i ENC END", tel+1);
887 sprintf (kmiroff_name,
"ESO INS KMIRROROFFSET%i", tel+1);
888 sprintf (rotoff_name,
"ESO INS ROTATIONOFFSET%i", tel+1);
891 if (cpl_propertylist_has (
plist, pupilrot_start_name) &&
892 cpl_propertylist_has (
plist, pupilrot_end_name) &&
893 cpl_propertylist_has (
plist, drot_enc_start_name) &&
894 cpl_propertylist_has (
plist, drot_enc_end_name) &&
895 cpl_propertylist_has (
plist, kmiroff_name) &&
896 cpl_propertylist_has (
plist, rotoff_name)) {
899 double pupilrot1 = cpl_propertylist_get_double(
plist, pupilrot_start_name);
900 double pupilrot2 = cpl_propertylist_get_double(
plist, pupilrot_end_name);
902 double prdif = pupilrot2 - pupilrot1;
907 double pupilrot = pupilrot1 + prdif*n/(nrow-1);
910 int drotenc1 = cpl_propertylist_get_int(
plist, drot_enc_start_name);
911 int drotenc2 = cpl_propertylist_get_int(
plist, drot_enc_end_name);
913 double drotencdif = (double)drotenc2 - (
double)drotenc1;
914 double posenc = (double)drotenc1 + drotencdif*n/(nrow-1);
917 double kmirroroffset = cpl_propertylist_get_double(
plist, kmiroff_name);
920 double rotoff = cpl_propertylist_get_double(
plist, rotoff_name);
922 zangle = pupilrot + 90. - posenc / 200. - kmirroroffset - rotoff + 180.;
923 if (zangle >= 180) zangle -= 360.0;
924 if (zangle < -180) zangle += 360.0;
926 cpl_msg_info (cpl_func,
"Acquisition camera Zenith angle Beam B (tel=%i) = %.2f [deg] / ZenithACQ in Y to X", (tel+1), zangle);
930 cpl_msg_warning (cpl_func,
"Cannot compute Zenith angle for Beam B: zangle = 0.0");
939 const char * value = cpl_propertylist_get_string(
plist,
"INSNAME");
940 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
956 if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
957 cpl_propertylist_has (
plist,
"ESO INS DET3 GAIN") &&
958 cpl_propertylist_get_double (
plist,
"MJD-OBS") >= 57584.83 &&
959 cpl_propertylist_get_double (
plist,
"MJD-OBS") < 57617.0) {
963 gain = cpl_propertylist_get_double (
plist,
"ESO INS DET3 GAIN");
964 if (gain == 3.0) gain = 1.7;
965 cpl_msg_warning (cpl_func,
"Use FT gain of %.3f [adu/e] (wrong units and value in header)", gain);
966 }
else if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
967 cpl_propertylist_has (
plist,
"ESO INS DET3 GAIN") &&
968 cpl_propertylist_get_double (
plist,
"MJD-OBS") >= 57617.0) {
971 gain = 1. / cpl_propertylist_get_double (
plist,
"ESO INS DET3 GAIN");
972 cpl_msg_info (cpl_func,
"Use FT gain of %.3f [adu/e] from header", gain);
976 cpl_msg_warning (cpl_func,
"Force FT gain to %.3f [adu/e] (wrong value or no value in header)", gain);
995 if ( cpl_propertylist_has (
plist,
"MJD-OBS") &&
996 cpl_propertylist_has (
plist,
"ESO INS DET2 GAIN") &&
997 cpl_propertylist_get_double (
plist,
"MJD-OBS") > 57617.0) {
1000 gain = 1. / cpl_propertylist_get_double (
plist,
"ESO INS DET2 GAIN");
1001 cpl_msg_info (cpl_func,
"Use SC gain of %.3f [adu/e] from header", gain);
1005 cpl_msg_warning (cpl_func,
"Force SC gain to %.3f [adu/e]", gain);
1030 cpl_propertylist * o_plist = cpl_propertylist_new ();
1033 cpl_propertylist_update_string (o_plist,
"CONTENT",
"OIFITS2");
1034 cpl_propertylist_update_string (o_plist,
"REFERENC",
"2001PASP..112.1133P");
1038 cpl_propertylist_update_string (o_plist,
"OBSERVER", observer);
1042 cpl_propertylist_update_string (o_plist,
"PROG_ID", prog_id);
1045 char * procsoft = cpl_sprintf(
"GRAVITY pipeline %s", PACKAGE_VERSION);
1046 cpl_propertylist_update_string (o_plist,
"PROCSOFT", procsoft);
1047 FREE (cpl_free, procsoft);
1052 char *
object = cpl_sprintf (
"%s,%s", sc_object, ft_object);
1053 cpl_propertylist_update_string (o_plist,
"OBJECT",
object);
1054 FREE (cpl_free,
object);
1058 mode = cpl_sprintf (
"%s,%s,%s,%s",
1063 cpl_propertylist_update_string (o_plist,
"INSMODE", mode);
1064 FREE (cpl_free, mode);
1066 CPLCHECK_NUL (
"Cannot fill the OIFITS2 specific keywords");
1083 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, NULL);
1086 const char* param_value=NULL;
1087 const char * param_name =
"extra-pixel-ft";
1090 sprintf (key,
"ESO PRO REC1 PARAM%d NAME",key_index);
1091 while (cpl_propertylist_has(
header, key)){
1092 if (!strcmp(cpl_propertylist_get_string(
header, key), param_name))
1094 sprintf (key,
"ESO PRO REC1 PARAM%d VALUE",key_index);
1095 param_value = cpl_propertylist_get_string(
header, key);
1096 cpl_msg_info (cpl_func,
"Retrieve the extra-pixel-ft option from the p2vm: [%s] ", param_value);
1098 sprintf (key,
"ESO PRO REC1 PARAM%d NAME", ++key_index);
1101 cpl_parameter * p = cpl_parameter_new_value (
"gravity.preproc.extra-pixel-ft", CPL_TYPE_BOOL,
1102 "Include the 6th pixels ot the FT",
1103 "gravity.preproc", TRUE);
1104 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"extra-pixel-ft");
1106 if (param_value != NULL && !strcmp(param_value,
"true"))
1107 cpl_parameter_set_bool(p, 1);
1109 cpl_parameter_set_bool(p, 0);
1111 cpl_msg_info(cpl_func,
"Set extra-pixel-ft option : [%d] ", cpl_parameter_get_bool(p));
1125 const char * qc =
" QC ";
1128 cpl_ensure (
header, CPL_ERROR_NULL_INPUT, NULL);
1131 cpl_propertylist * applist = cpl_propertylist_new();
1132 cpl_size size = cpl_propertylist_get_size (
header);
1133 for (cpl_size i = 0; i < size; i++) {
1134 cpl_property * p = cpl_propertylist_get (
header, i);
1135 const char * p_name = cpl_property_get_name (p);
1136 if ( (strstr(p_name, qc) != NULL) ||
1138 cpl_type type_qc = cpl_property_get_type (p);
1140 case CPL_TYPE_FLOAT :
1141 if (cpl_property_get_float (p) != NAN)
1142 cpl_propertylist_append_property(applist, p);
1144 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1146 case CPL_TYPE_DOUBLE :
1147 if (cpl_property_get_double (p) != NAN)
1148 cpl_propertylist_append_property(applist, p);
1150 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1153 if (cpl_property_get_int (p) != NAN)
1154 cpl_propertylist_append_property(applist, p);
1156 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1158 case CPL_TYPE_STRING :
1159 if (cpl_property_get_string (p))
1160 cpl_propertylist_append_property(applist, p);
1162 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1164 case CPL_TYPE_CHAR :
1165 if (cpl_property_get_char (p))
1166 cpl_propertylist_append_property(applist, p);
1168 cpl_msg_warning(cpl_func,
"The parameter %s is not correct", cpl_property_get_name (p));
1170 case CPL_TYPE_BOOL :
1171 cpl_propertylist_append_property (applist, p);
1174 cpl_msg_error (cpl_func,
"'%s' is an invalid type of property",p_name);
1175 cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE,
1176 "invalid type of property");
1190 cpl_ensure (start, CPL_ERROR_NULL_INPUT, 0.0);
1194 char * str = cpl_strdup (start);
1202 int iy = atoi (str+0);
1203 int im = atoi (str+5);
1204 int id = atoi (str+8);
1205 double dhr = atof (str+11);
1206 double dmin = atof (str+14);
1207 double dsec = atof (str+17);
1212 eraCal2jd (iy, im,
id, &dmjd0, &dmjd);
1215 return dmjd + (dhr + (dmin + dsec/60.0)/60.0)/24.0;
1220 int year, month, day, hour, minute;
1221 double fraction, second;
1223 eraJd2cal (2400000.5, mjd, &year, &month, &day, &fraction);
1225 hour = (int)(fraction/3600.0);
1226 fraction -= hour*3600.0;
1227 minute = (int)(fraction/60.0);
1228 fraction -= minute*60.0;
1231 return cpl_sprintf (
"%04i-%02i-%02iT%02i:%02i:%06.3f", year, month, day, hour, minute, second);
1236 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0.0);
1237 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1247 double sdecz = sin(decz);
1248 double cdecz = cos(decz);
1249 double denom = cdecz - eta * sdecz;
1252 double dec = atan2 (sdecz+eta*cdecz, sqrt(xi*xi + denom*denom));
1260 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1263 char * str = cpl_strdup (stri);
1270 out += atof(str+3) / 60;
1271 out += atof(str+6) / 3600;
1274 return out / 12 * CPL_MATH_PI;
1279 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1282 char * str = cpl_strdup (stri);
1289 out += atof(str+4) / 60;
1290 out += atof(str+7) / 3600;
1292 out *= (str[0]==
'-' ? -1.0 : 1.0);
1295 return out / 180 * CPL_MATH_PI;
1305 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0.0);
1306 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1316 double sdecz = sin(decz);
1317 double cdecz = cos(decz);
1318 double denom = cdecz - eta * sdecz;
1321 double ra = atan2 (xi,denom) + raz;
1324 ra = fmod (ra, CPL_MATH_2PI);
1325 if ( ra < 0.0 ) ra += CPL_MATH_2PI;
1333 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 99.);
1334 cpl_errorstate prestate = cpl_errorstate_get();
1338 const char * str_value;
1347 strncpy(tmp, str_value, 2);
1349 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1353 strncpy(tmp, str_value+2, 4);
1355 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1356 value += atof(tmp) / 60.0;
1359 strcpy(tmp, str_value+4);
1360 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1361 value += atof(tmp) / 3600.0;
1367 cpl_msg_debug( cpl_func,
"Convert RA='%s' into RA=%fdeg", str_value, value);
1369 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1370 cpl_errorstate_set (prestate);
1371 cpl_msg_warning(cpl_func,
"rarp doesn't exist in this file.");
1377 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1380 return value * CPL_MATH_RAD_DEG;
1385 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 99.);
1387 cpl_errorstate prestate = cpl_errorstate_get();
1392 const char * str_value;
1400 if ( str_value[0] ==
'-' ) {
1402 str_value = str_value + 1;
1403 }
else if ( str_value[0] ==
'+' ) {
1405 str_value = str_value + 1;
1411 strncpy(tmp, str_value, 2);
1413 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1417 strncpy(tmp, str_value+2, 4);
1419 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1420 value += atof(tmp) / 60.0;
1423 strcpy(tmp, str_value+4);
1424 cpl_msg_debug( cpl_func,
"Found tmp '%s' -> %f", tmp, atof(tmp) );
1425 value += atof(tmp) / 3600.0;
1431 cpl_msg_debug( cpl_func,
"Convert DEC='%s' into DEC=%fdeg", str_value, value);
1433 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1434 cpl_errorstate_set (prestate);
1435 cpl_msg_warning(cpl_func,
"decep doesn't exist in this file.");
1442 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1445 return value * CPL_MATH_RAD_DEG;
1454 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, 0);
1455 const char * opt1 =
"ESO INS OPTI1 NAME";
1457 if ( !cpl_propertylist_has (
plist, opt1) )
return 0;
1459 const char * value = cpl_propertylist_get_string (
plist, opt1);
1460 if ( !strcmp (value,
"CALIB") )
return 1;
1486 cpl_ensure (self, CPL_ERROR_NULL_INPUT, 0);
1487 cpl_ensure (name, CPL_ERROR_NULL_INPUT, 0);
1488 cpl_ensure (cpl_propertylist_has (self, name), CPL_ERROR_DATA_NOT_FOUND, 0);
1490 cpl_type type = cpl_propertylist_get_type (self, name);
1493 case CPL_TYPE_UCHAR:
1495 case CPL_TYPE_SHORT:
1496 case CPL_TYPE_USHORT:
1500 case CPL_TYPE_LONG_LONG:
1501 case CPL_TYPE_ULONG:
1503 return cpl_propertylist_get_long(self, name);
1504 case CPL_TYPE_FLOAT:
1505 case CPL_TYPE_DOUBLE:
1506 return cpl_propertylist_get_double(self, name);
1507 case CPL_TYPE_STRING:
1508 cpl_msg_debug (cpl_func,
"FITS card %s is string '%s' to double %f",
1509 name,cpl_propertylist_get_string(self, name),atof(cpl_propertylist_get_string(self, name)));
1510 return atof(cpl_propertylist_get_string(self, name));
1512 cpl_error_set(cpl_func, CPL_ERROR_TYPE_MISMATCH);
1520 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
1521 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1525 char * comment = cpl_sprintf (
"%s", cpl_propertylist_get_comment (self, name));
1528 cpl_propertylist_erase (self, name);
1529 cpl_propertylist_append_double (self, name, value );
1530 cpl_propertylist_set_comment (self, name, comment);
1533 return cpl_error_get_code();
1541 const char * full_name,
double 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);
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;
1563 const char * full_name,
int value)
1565 cpl_error_code code;
1566 cpl_ensure_code (
plist, CPL_ERROR_NULL_INPUT);
1567 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1570 if ( isnan((
double)value) )
1573 cpl_propertylist_update_int (
plist, full_name, value);
1576 if ( (code=cpl_error_get_code()) ) {
1577 cpl_msg_warning (cpl_func,
"Cannot set keyword: %s", full_name);
1578 return cpl_error_set_message(cpl_func, code,
"Cannot set keyword: %s", full_name);
1581 return CPL_ERROR_NONE;
1588 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1589 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1593 if (cpl_propertylist_has(
plist, name)) {
1595 output = cpl_propertylist_get_string(
plist, name);
1601 cpl_msg_warning (cpl_func,
"Can't find keyword %s (use '%s')", name, def);
1603 cpl_msg_info (cpl_func,
"Can't find keyword %s (use '%s')", name, def);
1613 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1614 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1618 if (cpl_propertylist_has(
plist, name)) {
1626 cpl_msg_warning (cpl_func,
"Can't find keyword %s (use '%f')", name, def);
1628 cpl_msg_info (cpl_func,
"Can't find keyword %s (use '%f')", name, def);
1638 cpl_ensure (
plist, CPL_ERROR_NULL_INPUT, def);
1639 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1642 if (cpl_propertylist_has(
plist, name))
1668 cpl_ensure_code (
header, CPL_ERROR_NULL_INPUT);
1669 cpl_ensure_code (msg, CPL_ERROR_NULL_INPUT);
1673 if (cpl_propertylist_has (
header,
"ESO QC CHECK FLAGS"))
1674 i = cpl_propertylist_get_int (
header,
"ESO QC CHECK FLAGS") + 1;
1676 cpl_propertylist_update_int (
header,
"ESO QC CHECK FLAGS", i);
1681 sprintf (qc_name,
"ESO QC CHECK MSG%i", i);
1683 cpl_msg_warning (cpl_func,
"%s = '%s'", qc_name, msg);
1684 cpl_propertylist_append_string (
header, qc_name, msg);
1689 return CPL_ERROR_NONE;
1708 cpl_ensure_code (
header, CPL_ERROR_NULL_INPUT);
1717 sprintf (name,
"ESO PRO REC%i PIPE LAST_BUILD", i);
1718 }
while (cpl_propertylist_has (
header, name));
1721 sprintf (value,
"%s %s", __DATE__,__TIME__);
1725 cpl_propertylist_update_string (
header, name, value);
1726 cpl_propertylist_set_comment (
header, name,
"Last 'make clean all install'");
1730 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)
double gravi_pfits_get_projected_baseline_end(const cpl_propertylist *plist, int tel1, int tel2)
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_pfits_get_projected_baseline_start(const cpl_propertylist *plist, int tel1, int tel2)
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)