36#include "eris_ifu_dfs.h"
37#include "eris_ifu_utils.h"
38#include "eris_ifu_functions.h"
39#include "eris_ifu_error.h"
40#include "eris_ifu_distortion_static.h"
41#include "eris_ifu_debug.h"
42#include "eris_utils.h"
43#include <eris_pfits.h>
91 cpl_error_code retVal = CPL_ERROR_NONE;
92 const cpl_size n = cpl_frameset_get_size(self);
93 ifsInstrument instrument = UNSET_INSTRUMENT,
94 currInstrument = UNSET_INSTRUMENT;
95 cpl_frame *frame = NULL;
96 const char *tag = NULL;
99 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
104 for (cpl_size i = 0; i < n; i++) {
106 frame = cpl_frameset_get_position(self, i));
108 tag = cpl_frame_get_tag(frame);
111 "Frame %d of %d has no tag",
116 stag = cpl_sprintf(
",%s,", tag));
118 if (strstr(ERIS_IFU_RAW_TAGS, stag) != NULL) {
121 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW));
125 if (instrument == UNSET_INSTRUMENT) {
129 if (currInstrument != instrument) {
131 CPL_ERROR_BAD_FILE_FORMAT,
132 "SOF input files are from "
133 "different instruments");
137 }
else if (strstr(ERIS_IFU_REF_CALIB_TAGS, stag) != NULL) {
140 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
141 }
else if (strstr(ERIS_IFU_REF_UTIL_TAGS, stag) != NULL) {
144 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
145 }
else if (strstr(ERIS_IFU_PRO_CALIB_TAGS, stag) != NULL) {
148 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
149 }
else if (strstr(ERIS_IFU_PRO_JITTER_TAGS, stag) != NULL) {
152 cpl_frame_set_group(frame, CPL_FRAME_GROUP_PRODUCT));
155 if (instrument == UNSET_INSTRUMENT) {
159 if (currInstrument != instrument) {
161 CPL_ERROR_BAD_FILE_FORMAT,
162 "SOF input files are from "
163 "different instruments");
169 "Unkown tag \"%s\" for frame %d of %d",
170 cpl_frame_get_tag(frame), 1 + (
int)i, (
int)n);
177 retVal = cpl_error_get_code();
202 const cpl_frameset * in,
206 cpl_frame * loc_frame;
211 if (in == NULL)
return NULL ;
212 if (tag == NULL)
return NULL ;
215 nbframes = cpl_frameset_get_size(in) ;
218 if (cpl_frameset_count_tags(in, tag) == 0)
return NULL ;
221 out = cpl_frameset_new() ;
224 for (i=0 ; i<nbframes ; i++) {
225 const cpl_frame *cur_frame = cpl_frameset_get_position_const(in, i);
226 if (!strcmp(cpl_frame_get_tag(cur_frame), tag)) {
227 loc_frame = cpl_frame_duplicate(cur_frame) ;
228 cpl_frameset_insert(out, loc_frame) ;
249 const char* deq_hduclas)
251 cpl_propertylist_append_string(plist, FHDR_HDUCLASS, DEQ_HDUCLASS);
252 cpl_propertylist_append_string(plist, FHDR_HDUDOC, DEQ_HDUDOC);
253 cpl_propertylist_append_string(plist, FHDR_HDUVERS, DEQ_HDUVERS);
254 cpl_propertylist_append_string(plist, FHDR_HDUCLAS1, deq_hduclas);
256 return cpl_error_get_code();
275 cpl_propertylist_append_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_DATA);
276 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_SCIDATA);
277 cpl_propertylist_append_string(plist, FHDR_ERRDATA, DEQ_ERRDATA);
278 cpl_propertylist_append_string(plist, FHDR_QUALDATA, DEQ_QUALDATA);
280 return cpl_error_get_code();
298 deqErrorType errorType)
300 cpl_propertylist_update_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_ERROR);
301 cpl_propertylist_update_string(plist, FHDR_HDUCLAS3,
302 deqErrorTypeString[errorType]);
303 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_ERRDATA);
304 cpl_propertylist_update_string(plist, FHDR_SCIDATA, DEQ_SCIDATA);
305 cpl_propertylist_update_string(plist, FHDR_QUALDATA, DEQ_QUALDATA);
307 return cpl_error_get_code();
325 deqQualityType qualityType){
326 cpl_propertylist_update_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_QUAL);
327 cpl_propertylist_update_string(plist, FHDR_HDUCLAS3,
328 deqQualityTypeString[qualityType]);
329 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_QUALDATA);
330 cpl_propertylist_update_string(plist, FHDR_SCIDATA, DEQ_SCIDATA);
331 cpl_propertylist_update_string(plist, FHDR_ERRDATA, DEQ_ERRDATA);
333 return cpl_error_get_code();
368 cpl_frameset *allframes,
369 cpl_propertylist * header,
370 const cpl_parameterlist *parlist,
371 const cpl_frameset *usedframes,
372 const cpl_frame *inherit,
374 const cpl_propertylist *applist,
375 const char *remregexp,
376 const char *filename,
377 const cpl_image *image,
378 const cpl_image *error,
379 deqErrorType errorType,
380 const cpl_image *dataQualityMask,
381 deqQualityType dataQualityType,
384 cpl_error_code retVal = CPL_ERROR_NONE;
385 cpl_propertylist *dataHeader = NULL,
388 char *pipe_id = NULL;
390 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
391 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
392 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
393 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
394 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
395 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
396 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
401 cpl_propertylist* head_wcs_2d = NULL;
405 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
406 dataHeader = cpl_propertylist_new();
409 head_wcs_2d = eris_ifu_plist_extract_wcs2D(applist);
411 eris_ifu_plist_erase_wcs( (cpl_propertylist *) applist);
412 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"BUNIT")) {
413 cpl_propertylist_erase((cpl_propertylist *) applist,
"BUNIT");
415 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"EXTNAME")) {
416 cpl_propertylist_erase( (cpl_propertylist *)applist,
"EXTNAME");
418 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"HDUCLAS2")) {
419 cpl_propertylist_erase( (cpl_propertylist *)applist,
"HDUCLAS2");
421 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"COMMENT")) {
422 cpl_propertylist_erase( (cpl_propertylist *)applist,
"COMMENT");
425 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
426 inherit, recipe, applist, remregexp, pipe_id, filename);
427 cpl_propertylist_append(dataHeader, head_wcs_2d);
430 if(cpl_propertylist_has(dataHeader,
"BUNIT")) {
431 cpl_propertylist_set_string(dataHeader,
"BUNIT", unit);
433 cpl_propertylist_append_string(dataHeader,
"BUNIT", unit);
435 eris_pfits_clean_header_ra_dec_mjd_obs(dataHeader);
436 cpl_image_save(image, filename, cpl_image_get_type(image), dataHeader,
440 errsHeader = cpl_propertylist_new();
444 if(cpl_propertylist_has(errsHeader,
"BUNIT")) {
445 cpl_propertylist_set_string(errsHeader,
"BUNIT", unit);
447 cpl_propertylist_append_string(errsHeader,
"BUNIT", unit);
449 cpl_propertylist_append(errsHeader, head_wcs_2d);
450 eris_pfits_clean_header_ra_dec_mjd_obs(errsHeader);
451 cpl_image_save(error, filename, cpl_image_get_type(error), errsHeader,
455 if(dataQualityMask) {
456 qualHeader = cpl_propertylist_new();
460 if(cpl_propertylist_has(qualHeader,
"BUNIT")) {
461 cpl_propertylist_set_string(qualHeader,
"BUNIT",
"");
463 cpl_propertylist_append_string(qualHeader,
"BUNIT",
"");
465 cpl_propertylist_append(qualHeader, head_wcs_2d);
466 eris_pfits_clean_header_ra_dec_mjd_obs(qualHeader);
467 cpl_image_save(dataQualityMask, filename,
468 cpl_image_get_type(dataQualityMask), qualHeader, CPL_IO_EXTEND);
474 retVal = cpl_error_get_code();
517 cpl_frameset *allframes,
518 cpl_propertylist * header,
519 const cpl_parameterlist *parlist,
520 const cpl_frameset *usedframes,
521 const cpl_frame *inherit,
523 cpl_propertylist *applist,
524 const char *remregexp,
525 const char *filename,
527 cpl_imagelist *error,
528 deqErrorType errorType,
529 const cpl_imagelist *dataQualityMask,
530 deqQualityType qualityType
533 cpl_error_code retVal = CPL_ERROR_NONE;
534 cpl_propertylist *dataHeader = NULL,
537 char *pipe_id = NULL;
539 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
540 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
541 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
542 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
543 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
544 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
545 cpl_ensure_code(data, CPL_ERROR_NULL_INPUT);
546 cpl_ensure_code(error, CPL_ERROR_NULL_INPUT);
547 cpl_ensure_code(dataQualityMask, CPL_ERROR_NULL_INPUT);
552 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
555 if(cpl_propertylist_has(applist,
"CDELT3")) {
556 cpl_propertylist_erase(applist,
"CDELT3");
558 dataHeader = cpl_propertylist_duplicate(applist);
559 errsHeader = cpl_propertylist_duplicate(applist);
560 qualHeader = cpl_propertylist_duplicate(applist);
569 if(cpl_propertylist_has(dataHeader,
"HDRVER")) {
570 cpl_propertylist_erase(dataHeader,
"HDRVER");
572 if(cpl_propertylist_has(errsHeader,
"HDRVER")) {
573 cpl_propertylist_erase(errsHeader,
"HDRVER");
575 if(cpl_propertylist_has(qualHeader,
"HDRVER")) {
576 cpl_propertylist_erase(qualHeader,
"HDRVER");
578 if(cpl_propertylist_has(dataHeader,
"CTYPE1")) {
579 const char* ctype1 = cpl_propertylist_get_string(dataHeader,
"CTYPE1");
580 if (!cpl_propertylist_has(errsHeader,
"CTYPE1"))
581 cpl_propertylist_append_string(errsHeader,
"CTYPE1", ctype1);
582 if (!cpl_propertylist_has(qualHeader,
"CTYPE1"))
583 cpl_propertylist_append_string(qualHeader,
"CTYPE1", ctype1);
585 if(cpl_propertylist_has(dataHeader,
"CTYPE2")) {
586 const char* ctype2 = cpl_propertylist_get_string(dataHeader,
"CTYPE2");
587 if (!cpl_propertylist_has(errsHeader,
"CTYPE2"))
588 cpl_propertylist_append_string(errsHeader,
"CTYPE2",ctype2);
589 if (!cpl_propertylist_has(errsHeader,
"CTYPE2"))
590 cpl_propertylist_append_string(qualHeader,
"CTYPE2", ctype2);
594 eris_ifu_plist_erase_wcs( (cpl_propertylist *)applist);
595 eris_pfits_clean_header(dataHeader, CPL_TRUE);
596 eris_pfits_clean_header(errsHeader, CPL_TRUE);
597 eris_pfits_clean_header(qualHeader, CPL_TRUE);
598 if(strstr(filename,
"sky") != NULL) {
599 cpl_propertylist_append_string(applist,
"PRODCATG", PRODCATG_CUBE_SKY);
601 cpl_propertylist_append_string(applist,
"PRODCATG", PRODCATG_CUBE_OBJ);
603 if(cpl_propertylist_has(applist,
"BUNIT")) {
604 cpl_propertylist_erase(applist,
"BUNIT");
606 if(cpl_propertylist_has(applist,
"COMMENT")) {
607 cpl_propertylist_erase(applist,
"COMMENT");
611 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
612 inherit, recipe, applist, remregexp,
616 cpl_imagelist_save(data, filename,
617 cpl_image_get_type(cpl_imagelist_get(data,0)),
618 dataHeader, CPL_IO_EXTEND);
620 cpl_imagelist_save(error, filename,
621 cpl_image_get_type(cpl_imagelist_get(error,0)),
622 errsHeader, CPL_IO_EXTEND);
623 if(cpl_propertylist_has(qualHeader,
"BUNIT")) {
624 cpl_propertylist_set_string(qualHeader,
"BUNIT",
"");
626 cpl_propertylist_append_string(qualHeader,
"BUNIT",
"");
628 cpl_imagelist_save(dataQualityMask, filename,
630 qualHeader, CPL_IO_EXTEND);
634 retVal = cpl_error_get_code();
636 cpl_propertylist_delete(dataHeader);
637 cpl_propertylist_delete(errsHeader);
638 cpl_propertylist_delete(qualHeader);
667 cpl_frameset *allframes,
668 const cpl_parameterlist *parlist,
669 const cpl_frameset *usedframes,
671 const cpl_propertylist *applist,
672 const char *remregexp,
673 const char *filename,
674 const cpl_image *image,
678 cpl_error_code retVal = CPL_ERROR_NONE;
679 cpl_propertylist *dataHeader = NULL;
680 char *pipe_id = NULL;
682 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
683 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
684 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
685 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
686 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
687 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
688 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
690 cpl_propertylist* head_wcs_2d = NULL;
694 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
695 dataHeader = cpl_propertylist_new();
697 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"EXTNAME")) {
698 cpl_propertylist_erase( (cpl_propertylist *)applist,
"EXTNAME");
702 if(cpl_propertylist_has(applist,
"BUNIT")) {
703 cpl_propertylist_set_string((cpl_propertylist *) applist,
"BUNIT", unit);
705 cpl_propertylist_append_string((cpl_propertylist *) applist,
"BUNIT", unit);
707 cpl_dfs_save_image(allframes, NULL, parlist, usedframes, NULL, image, type,
708 recipe, applist, remregexp, pipe_id, filename);
712 retVal = cpl_error_get_code();
746 cpl_frameset *allframes,
747 cpl_propertylist *header,
748 const cpl_parameterlist *parlist,
749 const cpl_frameset *usedframes,
750 const cpl_frame *inherit,
753 cpl_propertylist *applist,
754 const char *remregexp,
755 const char *filename,
756 const cpl_table *table)
758 cpl_error_code retVal = CPL_ERROR_NONE;
759 cpl_propertylist *dataHeader = NULL;
760 char *pipe_id = NULL;
762 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
763 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
764 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
765 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
766 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
767 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
768 cpl_ensure_code(table, CPL_ERROR_NULL_INPUT);
769 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
774 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
776 dataHeader = cpl_propertylist_new();
779 cpl_propertylist_append_string(dataHeader, FHDR_HDUCLAS2, DEQ_HDUCLAS2_DATA);
780 cpl_propertylist_append_string(dataHeader, FHDR_EXTNAME, DEQ_SCIDATA);
781 cpl_propertylist_update_string(applist, CPL_DFS_PRO_CATG, procatg);
784 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
785 inherit, recipe, applist, remregexp, pipe_id, filename);
788 cpl_table_save(table, dataHeader, applist, filename, CPL_IO_EXTEND);
793 retVal = cpl_error_get_code();
890 const char *filename,
891 cpl_propertylist **primaryHeader,
892 cpl_image **dataImage,
893 cpl_image **errImage,
894 cpl_image **qualImage,
895 deqErrorType *errorType,
896 deqQualityType *qualityType)
898 cpl_error_code retVal = CPL_ERROR_NONE;
902 cpl_propertylist *pl = NULL;
903 const char *property;
905 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
906 cpl_ensure_code(dataImage, CPL_ERROR_NULL_INPUT);
910 nExt = cpl_fits_count_extensions(filename);
914 "For a DEQ FITS file 3 extensions are expected, but %d are found",
917 *dataImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED, 0, 1);
919 if (primaryHeader != NULL) {
920 *primaryHeader = cpl_propertylist_load(filename, 0);
923 if (errImage != NULL) {
925 *errImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
927 pl = cpl_propertylist_load(filename, extension);
928 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
929 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
932 "keyword %s does not exist",
935 for (match=0; match<4; match++) {
936 if (strcmp(property, deqErrorTypeString[match]) == 0) {
943 "The HDUCLAS3 keyword for the error extension (%d) has an"
944 " unknown value of %s", extension, property);
949 if (qualImage != NULL) {
951 *qualImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
953 pl = cpl_propertylist_load(filename, extension);
954 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
955 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
958 "keyword %s does not exist",
961 for (match=0; match<4; match++) {
962 if (strcmp(property, deqQualityTypeString[match]) == 0) {
963 *qualityType = match;
969 "The HDUCLAS3 keyword for the error extension (%d) has an"
970 " unknown value of %s", (
int) extension, property);
977 retVal = cpl_error_get_code();
1003 const char *filename,
1004 cpl_propertylist **primaryHeader,
1005 cpl_imagelist **dataImagelist,
1006 cpl_imagelist **errImagelist,
1007 cpl_imagelist **qualImagelist,
1008 deqErrorType *errorType,
1009 deqQualityType *qualityType)
1011 cpl_error_code retVal = CPL_ERROR_NONE;
1015 cpl_propertylist *pl = NULL;
1016 const char *property;
1018 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
1019 cpl_ensure_code(dataImagelist, CPL_ERROR_NULL_INPUT);
1023 nExt = cpl_fits_count_extensions(filename);
1027 "For a DEQ FITS file 3 extensions are expected, but %d are found",
1030 *dataImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED, 1);
1032 if (primaryHeader != NULL) {
1033 *primaryHeader = cpl_propertylist_load(filename, 0);
1036 if (errImagelist != NULL) {
1038 *errImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED,
1040 pl = cpl_propertylist_load(filename, extension);
1041 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
1042 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
1045 "keyword %s does not exist",
1048 for (match=0; match<4; match++) {
1049 if (strcmp(property, deqErrorTypeString[match]) == 0) {
1056 "The HDUCLAS3 keyword for the error extension (%d) has an"
1057 " unknown value of %s", extension, property);
1062 if (qualImagelist != NULL) {
1064 *qualImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED,
1066 pl = cpl_propertylist_load(filename, extension);
1067 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
1068 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
1071 "keyword %s does not exist",
1074 for (match=0; match<4; match++) {
1075 if (strcmp(property, deqQualityTypeString[match]) == 0) {
1076 *qualityType = match;
1082 "The HDUCLAS3 keyword for the error extension (%d) has an"
1083 " unknown value of %s", (
int) extension, property);
1090 retVal = cpl_error_get_code();
1117 const char *filename,
1118 cpl_propertylist **primaryHeader,
1119 cpl_image **qualImage,
1120 deqQualityType *qualityType)
1122 hdrl_image *image = NULL;
1123 cpl_image *dataImage = NULL;
1124 cpl_image *errImage = NULL;
1125 cpl_mask *mask = NULL;
1127 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1131 deqErrorType errorType;
1133 &dataImage, &errImage, qualImage, &errorType, qualityType);
1137 cpl_image_power(errImage, 0.5);
1146 "Cannot transfer error extension type %s to a HDLR error"
1147 " image", deqErrorTypeString[errorType]);
1151 "Internal error: unknown errorType enumeration value: %d",
1156 if (qualImage != NULL) {
1157 switch (*qualityType) {
1165 mask = cpl_mask_threshold_image_create(*qualImage,
1169 mask = cpl_mask_threshold_image_create(*qualImage,
1174 CPL_ERROR_ACCESS_OUT_OF_RANGE,
1175 "Internal error: unknown qualityType enumeration"
1183 cpl_image_set_bpm(dataImage, mask);
1190 cpl_mask_delete(mask);
1194 cpl_image_delete(dataImage);
1195 cpl_image_delete(errImage);
1219 const char *filename,
1220 cpl_propertylist **primaryHeader,
1221 cpl_imagelist **qualImagelist,
1222 deqQualityType *qualityType)
1224 hdrl_imagelist *imagelist = NULL;
1225 cpl_imagelist *dataImagelist = NULL;
1226 cpl_imagelist *errImagelist = NULL;
1227 cpl_image *dataImage = NULL;
1228 cpl_image *errImage = NULL;
1229 cpl_image *qualImage = NULL;
1230 cpl_mask *mask = NULL;
1231 deqErrorType errorType;
1233 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1238 &dataImagelist, &errImagelist, qualImagelist, &errorType, qualityType);
1240 if ((cpl_imagelist_get_size(dataImagelist) != cpl_imagelist_get_size(errImagelist))
1242 (cpl_imagelist_get_size(dataImagelist) != cpl_imagelist_get_size(*qualImagelist)))
1245 "All imagelists of an DEQ imagelist file must have the same size");
1248 for (cpl_size ix=0; ix < cpl_imagelist_get_size(dataImagelist); ix++) {
1249 dataImage = cpl_imagelist_get(dataImagelist, ix);
1250 errImage = cpl_imagelist_get(errImagelist, ix);
1251 qualImage = cpl_imagelist_get(*qualImagelist, ix);
1256 cpl_image_power(errImage, 0.5));
1266 "Cannot transfer error extension type %s to a HDLR error"
1267 " image", deqErrorTypeString[errorType]);
1271 "Internal error: unknown errorType enumeration value: %d",
1276 if (qualImage != NULL) {
1277 switch (*qualityType) {
1285 mask = cpl_mask_threshold_image_create(qualImage,
1289 mask = cpl_mask_threshold_image_create(qualImage,
1294 CPL_ERROR_ACCESS_OUT_OF_RANGE,
1295 "Internal error: unknown qualityType enumeration"
1304 for (cpl_size ny = 1; ny <= cpl_image_get_size_y(dataImage); ny++) {
1305 for (cpl_size nx = 1; nx <= cpl_image_get_size_x(dataImage); nx++) {
1309 cpl_mask_set(mask, nx, ny, BAD_PIX);
1314 cpl_image_set_bpm(dataImage, mask);
1315 cpl_image_set_bpm(errImage, cpl_mask_duplicate(mask));
1317 cpl_imagelist_set(dataImagelist, dataImage, ix);
1318 cpl_imagelist_set(errImagelist, errImage, ix);
1322 dataImagelist, errImagelist);
1329 cpl_imagelist_delete(dataImagelist);
1330 cpl_imagelist_delete(errImagelist);
1354 const cpl_frame *frame,
1356 ifsPreopticsScale scale,
1357 cpl_image **qualImage,
1358 deqQualityType *qualType)
1360 hdrl_image *image = NULL;
1361 const char *filename;
1363 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, NULL);
1367 filename = cpl_frame_get_filename(frame);
1369 filename, band, scale, qualImage, qualType);
1400 const char *filename,
1402 ifsPreopticsScale scale,
1403 cpl_image **qualImage,
1404 deqQualityType *qualType)
1406 hdrl_image *image = NULL;
1407 cpl_propertylist *header = NULL;
1408 cpl_image *dataImage = NULL;
1409 cpl_image *errorImage = NULL;
1414 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1418 nExt = cpl_fits_count_extensions(filename);
1421 qualImage, qualType);
1423 header = cpl_propertylist_load(filename, 0);
1424 dataImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
1426 errorImage = cpl_image_abs_create(dataImage);
1427 cpl_image_multiply_scalar(errorImage, 0.1);
1430 if (qualType != NULL) {
1431 *qualType = unspecified;
1434 if ((band != UNDEFINED_BAND) &&
1437 "different instrument band setting"
1438 " in calibration frame %s", filename);
1440 if ((scale != UNDEFINED_SCALE) &&
1444 "different instrument pre-optics setting"
1445 " in calibration frame %s", filename);
1478 const char* filename,
1479 cpl_polynomial ** poly_u,
1480 cpl_polynomial ** poly_v)
1482 cpl_error_code retVal = CPL_ERROR_NONE;
1483 cpl_table *distortionTable = NULL;
1484 cpl_size nTableRows;
1490 *poly_u = cpl_polynomial_new(2);
1491 *poly_v = cpl_polynomial_new(2);
1493 distortionTable = cpl_table_load(filename,1,0);
1494 nTableRows = cpl_table_get_nrow(distortionTable);
1496 for (cpl_size i=0; i<nTableRows; i++) {
1497 pows[0] = cpl_table_get_int(distortionTable,
"degx", i, NULL);
1498 pows[1] = cpl_table_get_int(distortionTable,
"degy", i, NULL);
1499 coeff = cpl_table_get_double(distortionTable,
"coeff", i, NULL);
1500 cpl_polynomial_set_coeff(*poly_u, pows, coeff);
1506 cpl_polynomial_set_coeff(*poly_v, pows, 1.0);
1511 retVal = cpl_error_get_code();
1537 const char* filename,
1538 cpl_polynomial ***polynomials,
1539 cpl_table **borders)
1541 cpl_error_code retVal = CPL_ERROR_NONE;
1542 cpl_table *distortionTable = NULL;
1549 cpl_calloc(SLITLET_CNT,
sizeof(cpl_polynomial*));
1551 for (
int sx = 0; sx < SLITLET_CNT; sx++) {
1552 cpl_size nTableRows;
1555 distortionTable = cpl_table_load(filename, sx+1, 0);
1556 nTableRows = cpl_table_get_nrow(distortionTable);
1558 (*polynomials)[sx] = cpl_polynomial_new(2);
1560 for (cpl_size i=0; i<nTableRows; i++) {
1564 pows[0] = cpl_table_get_int(distortionTable,
"degx", i, NULL);
1565 pows[1] = cpl_table_get_int(distortionTable,
"degy", i, NULL);
1566 coeff = cpl_table_get_double(distortionTable,
"coeff", i, NULL);
1567 cpl_polynomial_set_coeff((*polynomials)[sx], pows, coeff);
1573 *borders = cpl_table_load(filename, SLITLET_CNT+1, 0);
1577 if (*polynomials != NULL) {
1578 for (
int sx = 0; sx < SLITLET_CNT; sx++) {
1579 cpl_polynomial_delete((*polynomials)[sx]);
1583 retVal = cpl_error_set_where(cpl_func);
1592#define ERIS_IFU_DIST_SLIT_DISTANCE "slitlet_distance"
1607 const char* filename)
1609 cpl_vector *distances = NULL;
1610 cpl_table *table = NULL;
1611 cpl_size nTableRows = 0;
1616 table = cpl_table_load(filename,1,0);
1617 nTableRows = cpl_table_get_nrow(table);
1619 distances = cpl_vector_new(nTableRows);
1620 cpl_type type = cpl_table_get_column_type(table, ERIS_IFU_DIST_SLIT_DISTANCE);
1621 for (cpl_size i=0; i<nTableRows; i++) {
1622 if (type == CPL_TYPE_DOUBLE) {
1623 val = cpl_table_get_double(table, ERIS_IFU_DIST_SLIT_DISTANCE, i, NULL);
1624 }
else if (type == CPL_TYPE_FLOAT) {
1625 val = cpl_table_get_float(table, ERIS_IFU_DIST_SLIT_DISTANCE, i, NULL);
1630 cpl_vector_set(distances, i, val));
1635 cpl_vector_delete(distances);
1644#define ERIS_IFU_DIST_EDGE_L_old "pos1"
1645#define ERIS_IFU_DIST_EDGE_R_old "pos2"
1660 const char* filename)
1662 cpl_bivector *slitPos = NULL;
1663 cpl_vector *pos1 = NULL;
1664 cpl_vector *pos2 = NULL;
1665 cpl_table *slitPosTable = NULL;
1666 cpl_size nTableRows;
1670 slitPosTable = cpl_table_load(filename,1,0);
1671 nTableRows = cpl_table_get_nrow(slitPosTable);
1673 slitPos = cpl_bivector_new(nTableRows);
1674 pos1 = cpl_bivector_get_x(slitPos);
1675 pos2 = cpl_bivector_get_y(slitPos);
1678 for (cpl_size i=0; i<nTableRows; i++) {
1681 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_L, i, NULL);
1682 if (cpl_error_get_code()== CPL_ERROR_DATA_NOT_FOUND) {
1685 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_L_old, i, NULL);
1687 cpl_vector_set(pos1, i, val);
1690 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_R, i, NULL);
1691 if (cpl_error_get_code()== CPL_ERROR_DATA_NOT_FOUND) {
1694 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_R_old, i, NULL);
1696 cpl_vector_set(pos2, i, val);
1701 cpl_bivector_delete(slitPos);
1726 cpl_propertylist *pl,
1729 const char* comment)
1731 cpl_error_code retVal = CPL_ERROR_NONE;
1732 char *qcName = NULL;
1734 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1735 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1736 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1740 qcName = cpl_sprintf(
"ESO QC %s", name);
1741 cpl_propertylist_append_int(pl, qcName, val);
1742 cpl_propertylist_set_comment(pl , qcName, comment);
1746 retVal = cpl_error_get_code();
1770 cpl_propertylist *pl,
1773 const char* comment)
1775 cpl_error_code retVal = CPL_ERROR_NONE;
1776 char *qcName = NULL;
1778 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1779 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1780 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1784 qcName = cpl_sprintf(
"ESO QC %s", name);
1785 cpl_propertylist_append_double(pl, qcName, val);
1786 cpl_propertylist_set_comment(pl , qcName, comment);
1790 retVal = cpl_error_get_code();
1814 cpl_propertylist *pl,
1817 const char* comment)
1819 cpl_error_code retVal = CPL_ERROR_NONE;
1820 char *qcName = NULL;
1822 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1823 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1824 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1828 qcName = cpl_sprintf(
"ESO QC %s", name);
1829 cpl_propertylist_append_float(pl, qcName, val);
1830 cpl_propertylist_set_comment(pl , qcName, comment);
1834 retVal = cpl_error_get_code();
1860 const char *comment)
1862 cpl_error_code retVal = CPL_ERROR_NONE;
1863 char *qcName = NULL;
1865 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1866 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1867 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1871 qcName = cpl_sprintf(
"ESO QC %s", name);
1872 cpl_propertylist_set_int(pl, qcName, val);
1873 cpl_propertylist_set_comment(pl, qcName, comment);
1877 retVal = cpl_error_get_code();
1901 bool result =
false;
1902 cpl_propertylist *pl = NULL;
1903 const char *fn = NULL;
1904 char *dpr_type = NULL;
1906 cpl_ensure(fr != NULL, CPL_ERROR_NULL_INPUT,
false);
1910 fn = cpl_frame_get_filename(fr);
1913 pl = cpl_propertylist_load(fn, 0);
1915 if (cpl_propertylist_has(pl, FHDR_DPR_TYPE)) {
1916 dpr_type = cpl_strdup(
1917 cpl_propertylist_get_string(pl, FHDR_DPR_TYPE));
1920 "keyword %s does not exist",
1924 if ((strstr(dpr_type,
"STD") != NULL) ||
1925 (strstr(dpr_type,
"PSF") != NULL) ||
1926 (strstr(dpr_type,
"SKY") != NULL) ||
1927 (strstr(dpr_type,
"OBJECT") != NULL))
1962 bool result =
false;
1963 cpl_propertylist *pl = NULL;
1964 const char *fn = NULL;
1965 char *dpr_type = NULL;
1967 cpl_ensure(fr, CPL_ERROR_NULL_INPUT,
false);
1971 fn = cpl_frame_get_filename(fr);
1973 pl = cpl_propertylist_load(fn, 0);
1976 if (cpl_propertylist_has(pl, FHDR_DPR_TYPE)) {
1977 dpr_type = cpl_strdup(
1978 cpl_propertylist_get_string(pl, FHDR_DPR_TYPE));
1981 "keyword %s does not exist",
1986 if (strstr(dpr_type, ERIS_IFU_RAW_SKY) != NULL) {
2015 ifsInstrument instrument = UNSET_INSTRUMENT;
2017 cpl_ensure(header, CPL_ERROR_NULL_INPUT, 0);
2023 if (instrument == SPIFFIER) {
2024 dit = cpl_propertylist_get_float(header, FHDR_E_DIT);
2026 }
else if (instrument == SPIFFI) {
2027 dit = cpl_propertylist_get_float(header, FHDR_S_DIT);
2055 ifsInstrument instrument = UNSET_INSTRUMENT;
2063 cpl_ensure_code(header, CPL_ERROR_NULL_INPUT);
2069 if (instrument == SPIFFIER) {
2070 cpl_msg_debug(
"eris_ifu_get_callamp_status",
"ERIS/SPIFFIER found");
2071 if (cpl_propertylist_has(header, FHDR_E_AR_LAMP_ST)) {
2072 if (cpl_propertylist_get_bool(header, FHDR_E_AR_LAMP_ST)) {
2073 lampMask += AR_LAMP;
2077 if (cpl_propertylist_has(header, FHDR_E_KR_LAMP_ST)) {
2078 if (cpl_propertylist_get_bool(header, FHDR_E_KR_LAMP_ST)) {
2079 lampMask += KR_LAMP;
2083 if (cpl_propertylist_has(header, FHDR_E_NE_LAMP_ST)) {
2084 if (cpl_propertylist_get_bool(header, FHDR_E_NE_LAMP_ST)) {
2085 lampMask += NE_LAMP;
2089 if (cpl_propertylist_has(header, FHDR_E_XE_LAMP_ST)) {
2090 if (cpl_propertylist_get_bool(header, FHDR_E_XE_LAMP_ST)) {
2091 lampMask += XE_LAMP;
2095 if (cpl_propertylist_has(header, FHDR_E_QTH_LAMP_ST)) {
2096 if (cpl_propertylist_get_bool(header,FHDR_E_QTH_LAMP_ST)) {
2097 lampMask += QTH_LAMP;
2101 }
else if (instrument == SPIFFI) {
2102 cpl_msg_debug(
"eris_ifu_get_callamp_status",
"SINFONI/SPIFFI found");
2103 if (cpl_propertylist_get_bool(header,FHDR_S_AR_LAMP_ST)) {
2104 lampMask += AR_LAMP;
2107 if (cpl_propertylist_get_bool(header,FHDR_S_KR_LAMP_ST)) {
2108 lampMask += KR_LAMP;
2111 if (cpl_propertylist_get_bool(header,FHDR_S_NE_LAMP_ST)) {
2112 lampMask += NE_LAMP;
2115 if (cpl_propertylist_get_bool(header,FHDR_S_XE_LAMP_ST)) {
2116 lampMask += XE_LAMP;
2119 if (cpl_propertylist_get_bool(header,FHDR_S_QTH_LAMP_ST)) {
2120 lampMask += QTH_LAMP;
2129 cpl_msg_debug(cpl_func,
2130 "Lamps: Ar: %d, Kr: %d, Ne: %d, Xe: %d, Qth: %d, mask: %d",
2131 lampAr, lampKr, lampNe, lampXe, lampQth, lampMask);
2143 ifsBand band = UNDEFINED_BAND;
2144 ifsInstrument instrument = UNSET_INSTRUMENT;
2145 const char *bandId = NULL;
2149 if (header == NULL) {
2155 if (instrument == SPIFFIER) {
2156 bandId = cpl_propertylist_get_string(header, FHDR_E_GRATING_ID);
2158 if (strcmp(bandId, E_GRATING_J_LOW) == 0) {
2160 }
else if (strcmp(bandId, E_GRATING_J_SHORT) == 0) {
2162 }
else if (strcmp(bandId, E_GRATING_J_MIDDLE) == 0) {
2164 }
else if (strcmp(bandId, E_GRATING_J_LONG) == 0) {
2166 }
else if (strcmp(bandId, E_GRATING_H_LOW) == 0) {
2168 }
else if (strcmp(bandId, E_GRATING_H_SHORT) == 0) {
2170 }
else if (strcmp(bandId, E_GRATING_H_MIDDLE) == 0) {
2172 }
else if (strcmp(bandId, E_GRATING_H_LONG) == 0) {
2174 }
else if (strcmp(bandId, E_GRATING_K_LOW) == 0) {
2176 }
else if (strcmp(bandId, E_GRATING_K_SHORT) == 0) {
2178 }
else if (strcmp(bandId, E_GRATING_K_MIDDLE) == 0) {
2180 }
else if (strcmp(bandId, E_GRATING_K_LONG) == 0) {
2182 }
else if (strcmp(bandId, E_PREOPTICS_PUPIL) == 0) {
2183 cpl_msg_warning(cpl_func,
"found pupil data");
2186 }
else if (instrument == SPIFFI) {
2187 bandId = cpl_propertylist_get_string(header, FHDR_S_GRATING_ID);
2189 if (strcmp(bandId, S_GRATING_J_BAND) == 0) {
2191 }
else if (strcmp(bandId, S_GRATING_H_BAND) == 0) {
2193 }
else if (strcmp(bandId, S_GRATING_K_BAND) == 0) {
2195 }
else if (strcmp(bandId, S_GRATING_HK_BAND) == 0) {
2198 band = UNDEFINED_BAND;
2204 band = UNDEFINED_BAND;
2222 ifsInstrument instrument = UNSET_INSTRUMENT;
2223 const char *instrumentStr = NULL;
2224 const char *armStr = NULL;
2228 if (header == NULL) {
2232 instrumentStr = cpl_propertylist_get_string(header, FHDR_INSTRUMENT);
2234 "Cannot read "FHDR_INSTRUMENT
" FITS keyword");
2235 if (strcmp(instrumentStr, INSTRUMENT_SINFONI) == 0) {
2236 instrument = SPIFFI;
2237 }
else if (strcmp(instrumentStr, INSTRUMENT_ERIS) == 0) {
2238 armStr = cpl_propertylist_get_string(header, FHDR_E_ARM);
2240 "Cannot read "FHDR_E_ARM
" FITS keyword");
2241 if (strcmp(armStr, ARM_SPIFFIER) == 0) {
2242 instrument = SPIFFIER;
2243 }
else if (strcmp(armStr, ARM_NIX) == 0) {
2244 cpl_msg_error(cpl_func,
"ERIS/NIX frame detected");
2246 "ERIS/NIX frame detected");
2250 "Unkown instrument arm %s, neither SPIFFIER nor NIX",
2253 "Unkown instrument arm, neither SPIFFIER nor NIX");
2254 instrument = OTHER_INSTRUMENT;
2258 "Unkown instrument %s, neither ERIS/SPIFFIER nor SINFONI",
2261 "Unkown instrument, neither ERIS/SPIFFIER nor SINFONI");
2262 instrument = OTHER_INSTRUMENT;
2267 instrument = UNSET_INSTRUMENT;
2282 ifsPreopticsScale scale = UNDEFINED_SCALE;
2283 if (strcmp(scaleId, E_PREOPTICS_250MAS_SCALE) == 0) {
2285 }
else if (strcmp(scaleId, E_PREOPTICS_100MAS_SCALE) == 0) {
2287 }
else if (strcmp(scaleId, E_PREOPTICS_25MAS_SCALE) == 0) {
2289 }
else if (strcmp(scaleId, E_PREOPTICS_PUPIL) == 0) {
2292 scale = UNDEFINED_SCALE;
2306 ifsPreopticsScale scale = UNDEFINED_SCALE;
2307 if (strcmp(scaleId, S_PREOPTICS_250MAS_SCALE) == 0) {
2309 }
else if (strcmp(scaleId, S_PREOPTICS_100MAS_SCALE) == 0) {
2311 }
else if (strcmp(scaleId, S_PREOPTICS_25MAS_SCALE) == 0) {
2313 }
else if (strcmp(scaleId, S_PREOPTICS_PUPIL) == 0) {
2316 scale = UNDEFINED_SCALE;
2337 cpl_propertylist *header)
2339 ifsPreopticsScale scale = UNDEFINED_SCALE;
2340 ifsInstrument instrument = UNSET_INSTRUMENT;
2341 const char *scaleId;
2347 if (instrument == SPIFFIER) {
2348 scaleId = cpl_propertylist_get_string(header, FHDR_E_PREOPTICS_ID);
2351 }
else if (instrument == SPIFFI) {
2352 scaleId = cpl_propertylist_get_string(header, FHDR_S_PREOPTICS_ID);
2360 scale = UNDEFINED_SCALE;
2367#define KEY_NAME_COMOFFS_RA "ESO OCS CUMOFFS RA"
2368#define KEY_NAME_COMOFFS_DEC "ESO OCS CUMOFFS DEC"
2383 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, -1.0);
2384 cpl_propertylist* plist=NULL;
2388 file = cpl_strdup( cpl_frame_get_filename(frame)) ;
2390 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2391 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2392 cpl_propertylist_delete(plist) ;
2397 if (cpl_propertylist_has(plist, KEY_NAME_COMOFFS_RA)) {
2398 result=cpl_propertylist_get_double(plist, KEY_NAME_COMOFFS_RA);
2400 cpl_msg_error(cpl_func,
"keyword %s does not exist",KEY_NAME_COMOFFS_RA);
2401 cpl_propertylist_delete(plist) ;
2405 cpl_propertylist_delete(plist) ;
2425 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, -999.0);
2426 cpl_propertylist* plist=NULL;
2430 file = cpl_strdup( cpl_frame_get_filename(frame)) ;
2432 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2433 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2434 cpl_propertylist_delete(plist) ;
2439 if (cpl_propertylist_has(plist, KEY_NAME_COMOFFS_DEC)) {
2440 result=cpl_propertylist_get_double(plist, KEY_NAME_COMOFFS_DEC);
2442 cpl_msg_error(cpl_func,
"keyword %s does not exist",KEY_NAME_COMOFFS_DEC);
2443 cpl_propertylist_delete(plist) ;
2447 cpl_propertylist_delete(plist) ;
2465 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, -1.0);
2467 cpl_propertylist* plist=NULL;
2468 const char* file=NULL;
2471 file = cpl_frame_get_filename(frame) ;
2473 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2474 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2475 cpl_propertylist_delete(plist) ;
2478 if(cpl_propertylist_has(plist,
"MJD-OBS")){
2481 cpl_propertylist_delete(plist) ;
2482 cpl_error_set(cpl_func,CPL_ERROR_ILLEGAL_INPUT);
2487 cpl_propertylist_delete(plist) ;
2503 cpl_boolean result = CPL_FALSE;
2509 if ((strstr(ERIS_IFU_PRO_CALIB_TAGS, tag) != NULL) ||
2510 (strstr(ERIS_IFU_REF_CALIB_TAGS, tag) != NULL))
2528 cpl_boolean result = CPL_FALSE;
2534 char* tag_loc = (
char*) tag;
2535 if ((strcmp(tag_loc, ERIS_IFU_RAW_SKY) == 0) ||
2536 (strcmp(tag_loc, ERIS_IFU_RAW_OBJ_SKY) == 0) ||
2537 (strcmp(tag_loc, ERIS_IFU_RAW_STD_FLUX_SKY) == 0) ||
2538 (strcmp(tag_loc, ERIS_IFU_RAW_STD_SKY) == 0) ||
2539 (strcmp(tag_loc, ERIS_IFU_RAW_PSF_SKY) == 0) ||
2540 (strcmp(tag_loc, ERIS_IFU_RAW_PUPIL_SKY) == 0))
2555 cpl_boolean result = CPL_FALSE;
2561 char* tag_loc = (
char*) tag;
2562 if ((strcmp(tag_loc, ERIS_IFU_RAW_OBJ) == 0) ||
2563 (strcmp(tag_loc, ERIS_IFU_RAW_STD) == 0) ||
2564 (strcmp(tag_loc, ERIS_IFU_RAW_STD_FLUX) == 0) ||
2565 (strcmp(tag_loc, ERIS_IFU_RAW_PSF) == 0) ||
2566 (strcmp(tag_loc, ERIS_IFU_RAW_PUPIL_LAMP) == 0))
2583 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2584 cpl_ensure_code(obj, CPL_ERROR_NULL_INPUT);
2586 cpl_size nsof = cpl_frameset_get_size(sof);
2588 for (cpl_size i = 0 ; i < nsof ; i++) {
2589 const cpl_frame* frame = cpl_frameset_get_position_const(sof, i);
2590 cpl_frame_group group = cpl_frame_get_group(frame);
2592 if(group == CPL_FRAME_GROUP_RAW) {
2595 const char* tag = cpl_frame_get_tag(frame);
2599 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2600 cpl_frameset_insert(obj, frame_dup);
2608 return cpl_error_get_code();
2622 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2623 cpl_ensure_code(sky, CPL_ERROR_NULL_INPUT);
2625 cpl_size nsof = cpl_frameset_get_size(sof);
2626 for (cpl_size i = 0 ; i < nsof ; i++) {
2627 const cpl_frame* frame = cpl_frameset_get_position_const(sof, i);
2628 cpl_frame_group group = cpl_frame_get_group(frame);
2630 if(group == CPL_FRAME_GROUP_RAW) {
2632 const char* tag = cpl_frame_get_tag(frame);
2634 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2635 cpl_frameset_insert(sky, frame_dup);
2642 return cpl_error_get_code();
2656 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2657 cpl_ensure_code(cdb, CPL_ERROR_NULL_INPUT);
2659 cpl_size nsof = cpl_frameset_get_size(sof);
2660 for (cpl_size i = 0 ; i < nsof ; i++) {
2661 const cpl_frame* frame = cpl_frameset_get_position_const(sof,i);
2662 cpl_frame_group group = cpl_frame_get_group(frame);
2664 if(group == CPL_FRAME_GROUP_CALIB) {
2666 if(cpl_frame_get_tag(frame) != NULL) {
2668 char* tag= (
char*) cpl_frame_get_tag(frame);
2670 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2671 cpl_frameset_insert(cdb, frame_dup);
2678 return cpl_error_get_code();
cpl_error_code eris_ifu_load_deq_image(const char *filename, cpl_propertylist **primaryHeader, cpl_image **dataImage, cpl_image **errImage, cpl_image **qualImage, deqErrorType *errorType, deqQualityType *qualityType)
** Function to write a DFS compliant pipeline product with a badpixel map
cpl_error_code eris_ifu_append_qc_float(cpl_propertylist *pl, const char *name, float val, const char *comment)
Append a QC parameter of type FLOAT to a property list.
ifsPreopticsScale eris_ifu_get_preopticsScale(cpl_propertylist *header)
Return the the pre-optics scaling.
cpl_error_code eris_ifu_append_qc_double(cpl_propertylist *pl, const char *name, double val, const char *comment)
Append a QC parameter of type DOUBLE to a property list.
cpl_bivector * eris_ifu_load_slit_positions(const char *filename)
Load slitlet position bivector from a table.
float eris_ifu_get_dit(cpl_propertylist *header)
Get the detector integration time (DIT) from FITS header.
cpl_error_code eris_ifu_heades_add_hduclass_qual(cpl_propertylist *plist, deqQualityType qualityType)
Add quality extension classification properties to FITS header.
bool eris_ifu_frame_is_sky(const cpl_frame *fr)
Determine if a frame is a sky frame.
cpl_error_code eris_ifu_load_deq_imagelist(const char *filename, cpl_propertylist **primaryHeader, cpl_imagelist **dataImagelist, cpl_imagelist **errImagelist, cpl_imagelist **qualImagelist, deqErrorType *errorType, deqQualityType *qualityType)
Load a DEQ-format imagelist (cube) with data, error, and quality extensions.
ifsPreopticsScale eris_ifu_get_spiffier_preoptics_scale(const char *scaleId)
Determine observing scale on Sky.
cpl_error_code eris_ifu_extract_obj_frames(const cpl_frameset *sof, cpl_frameset *obj)
extract object raw frames from frame set and put them in a new one
cpl_error_code eris_ifu_load_distortion_polynomials(const char *filename, cpl_polynomial ***polynomials, cpl_table **borders)
Load distortion polynomials and slitlet borders from a table.
cpl_frameset * eris_ifu_extract_frameset(const cpl_frameset *in, const char *tag)
Extract frames with a specific tag from a frameset.
cpl_error_code eris_ifu_save_image_phase3(cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const char *recipe, const cpl_propertylist *applist, const char *remregexp, const char *filename, const cpl_image *image, cpl_type type, const char *unit)
Save a DFS-compliant Phase 3 image product.
hdrl_image * eris_ifu_load_cal_image_frame(const cpl_frame *frame, ifsBand band, ifsPreopticsScale scale, cpl_image **qualImage, deqQualityType *qualType)
Load a calibration image from a frame.
double eris_get_mjd_obs(cpl_frame *frame)
find out the Julian Date of the observation
hdrl_image * eris_ifu_load_cal_image_file(const char *filename, ifsBand band, ifsPreopticsScale scale, cpl_image **qualImage, deqQualityType *qualType)
Load a calibration image from a filename.
ifsPreopticsScale eris_ifu_get_spiffi_preoptics_scale(const char *scaleId)
Determine observing scale on Sky.
ifsInstrument eris_ifu_get_instrument(const cpl_propertylist *header)
Return the used instrument of the FITS file header.
hdrl_imagelist * eris_ifu_load_deq_hdrl_imagelist(const char *filename, cpl_propertylist **primaryHeader, cpl_imagelist **qualImagelist, deqQualityType *qualityType)
Load a DEQ-format cube into an HDRL imagelist structure.
cpl_error_code eris_ifu_heades_add_hduclass_common(cpl_propertylist *plist, const char *deq_hduclas)
Add common HDU classification properties to FITS header.
double eris_get_cumoffs_ra(cpl_frame *frame)
find out the ESO OCS CUMOFFS RA of the observation
cpl_boolean eris_ifu_tag_is_obj(const char *tag)
Add PRO* keywords to a SINFONI FITS header.
hdrl_image * eris_ifu_load_deq_hdrl_image(const char *filename, cpl_propertylist **primaryHeader, cpl_image **qualImage, deqQualityType *qualityType)
Load a DEQ-format file into an HDRL image structure.
cpl_error_code eris_ifu_dfs_set_groups(cpl_frameset *self)
Set the frame group (RAW, CALIB, or PRODUCT) for all frames in a frameset.
double eris_get_cumoffs_dec(cpl_frame *frame)
find out the ESO OCS CUMOFFS DEC of the observation
cpl_boolean eris_ifu_tag_is_sky(const char *tag)
check if input frame tag is a static of master calibration
cpl_error_code eris_ifu_set_qc_int(cpl_propertylist *pl, const char *name, int val, const char *comment)
Set (or update) a QC parameter of type INT in a property list.
cpl_boolean eris_ifu_tag_is_cdb(char *tag)
check if input frame tag is a static of master calibration
cpl_error_code eris_ifu_save_deq_image(cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const char *recipe, const cpl_propertylist *applist, const char *remregexp, const char *filename, const cpl_image *image, const cpl_image *error, deqErrorType errorType, const cpl_image *dataQualityMask, deqQualityType dataQualityType, const char *unit)
Save a DFS-compliant image product with data, error, and quality extensions.
int eris_ifu_get_callamp_status(cpl_propertylist *header)
Return a bit mask indicating which calibration lamps are turned on.
cpl_error_code eris_ifu_save_deq_cube(cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const char *recipe, cpl_propertylist *applist, const char *remregexp, const char *filename, cpl_imagelist *data, cpl_imagelist *error, deqErrorType errorType, const cpl_imagelist *dataQualityMask, deqQualityType qualityType)
Save a DFS-compliant cube product with data, error, and quality extensions.
cpl_error_code eris_ifu_save_table(cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const char *recipe, const char *procatg, cpl_propertylist *applist, const char *remregexp, const char *filename, const cpl_table *table)
Save a DFS-compliant table product.
cpl_error_code eris_ifu_heades_add_hduclass_data(cpl_propertylist *plist)
Add data extension classification properties to FITS header.
cpl_vector * eris_ifu_load_distances(const char *filename)
Load slitlet distance vector from a table.
ifsBand eris_ifu_get_band(const cpl_propertylist *header)
Determine preoptic band.
cpl_error_code eris_ifu_append_qc_int(cpl_propertylist *pl, const char *name, int val, const char *comment)
Append a QC parameter of type INT to a property list.
cpl_error_code eris_ifu_extract_sky_frames(const cpl_frameset *sof, cpl_frameset *sky)
extract sky raw frames from frame set and put them in a new one
cpl_error_code eris_ifu_heades_add_hduclass_errs(cpl_propertylist *plist, deqErrorType errorType)
Add error extension classification properties to FITS header.
cpl_error_code eris_ifu_load_distortion_polynomials_old(const char *filename, cpl_polynomial **poly_u, cpl_polynomial **poly_v)
Load old-format distortion polynomials from a table.
cpl_error_code eris_ifu_extract_mst_frames(const cpl_frameset *sof, cpl_frameset *cdb)
extract master and ref frames from input set and put them in a new one
bool eris_ifu_frame_is_on(const cpl_frame *fr)
Determine if a frame has calibration lamps ON or OFF.
#define BRK_WITH_ERROR(code)
Set a new CPL error, and exit the try-block.
#define SET_ERROR_MSG(code, msg)
Set a new error code together with a custom error message.
#define BRK_IF_ERROR(function)
If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
#define RECOVER(void)
Recover the error state which was present during TRY (at the beginning of the try-block).
#define CHECK_ERROR_STATE(void)
Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.
#define CHECK_ERROR_STATE_MSG(msg)
Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE. An additional error message ...
#define BRK_WITH_ERROR_MSG(code,...)
Set a new CPL error, and exit the try-block.
#define SET_ERROR(code)
Set a new error code.
#define TRY
Beginning of a TRY-block.
#define CATCH
End of a TRY-block, beginning of a CATCH-block.
#define BRK_IF_NULL(function)
If function is or returns a NULL pointer, then the try-block is exited.
#define CATCH_MSGS()
Displays an error message stack.
ifsInstrument eris_ifu_get_instrument_frame(cpl_frame *frame)
Get instrument identifier from a CPL frame.
void eris_ifu_free_propertylist(cpl_propertylist **item)
Free memory and set pointer to null.
void eris_ifu_free_string(char **item)
Free memory and set pointer to null.
void eris_ifu_free_table(cpl_table **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_file_exists(const char *filename)
**
void eris_ifu_free_image(cpl_image **item)
Free memory and set pointer to null.
int eris_ifu_is_nan_or_inf(double A)
Checks if a value is nan, inf or -inf.
double eris_pfits_get_mjdobs(const cpl_propertylist *aHeaders)
find out the Julian Date of the observation
cpl_error_code eris_check_error_code(const char *func_id)
handle CPL errors
hdrl_image * hdrl_image_create(const cpl_image *image, const cpl_image *error)
create a new hdrl_image from to existing images by copying them
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
hdrl_imagelist * hdrl_imagelist_create(cpl_imagelist *imlist, cpl_imagelist *errlist)
Create an hdrl_imagelist out of 2 cpl_imagelist.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.