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>
65 cpl_error_code retVal = CPL_ERROR_NONE;
66 const cpl_size n = cpl_frameset_get_size(self);
67 ifsInstrument instrument = UNSET_INSTRUMENT,
68 currInstrument = UNSET_INSTRUMENT;
69 cpl_frame *frame = NULL;
70 const char *tag = NULL;
73 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
78 for (cpl_size i = 0; i < n; i++) {
80 frame = cpl_frameset_get_position(self, i));
82 tag = cpl_frame_get_tag(frame);
85 "Frame %d of %d has no tag",
90 stag = cpl_sprintf(
",%s,", tag));
92 if (strstr(ERIS_IFU_RAW_TAGS, stag) != NULL) {
95 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW));
99 if (instrument == UNSET_INSTRUMENT) {
103 if (currInstrument != instrument) {
105 CPL_ERROR_BAD_FILE_FORMAT,
106 "SOF input files are from "
107 "different instruments");
111 }
else if (strstr(ERIS_IFU_REF_CALIB_TAGS, stag) != NULL) {
114 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
115 }
else if (strstr(ERIS_IFU_REF_UTIL_TAGS, stag) != NULL) {
118 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
119 }
else if (strstr(ERIS_IFU_PRO_CALIB_TAGS, stag) != NULL) {
122 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB));
123 }
else if (strstr(ERIS_IFU_PRO_JITTER_TAGS, stag) != NULL) {
126 cpl_frame_set_group(frame, CPL_FRAME_GROUP_PRODUCT));
129 if (instrument == UNSET_INSTRUMENT) {
133 if (currInstrument != instrument) {
135 CPL_ERROR_BAD_FILE_FORMAT,
136 "SOF input files are from "
137 "different instruments");
143 "Unkown tag \"%s\" for frame %d of %d",
144 cpl_frame_get_tag(frame), 1 + (
int)i, (
int)n);
151 retVal = cpl_error_get_code();
172 const cpl_frameset * in,
176 cpl_frame * loc_frame;
181 if (in == NULL)
return NULL ;
182 if (tag == NULL)
return NULL ;
185 nbframes = cpl_frameset_get_size(in) ;
188 if (cpl_frameset_count_tags(in, tag) == 0)
return NULL ;
191 out = cpl_frameset_new() ;
194 for (i=0 ; i<nbframes ; i++) {
195 const cpl_frame *cur_frame = cpl_frameset_get_position_const(in, i);
196 if (!strcmp(cpl_frame_get_tag(cur_frame), tag)) {
197 loc_frame = cpl_frame_duplicate(cur_frame) ;
198 cpl_frameset_insert(out, loc_frame) ;
212 const char* deq_hduclas)
214 cpl_propertylist_append_string(plist, FHDR_HDUCLASS, DEQ_HDUCLASS);
215 cpl_propertylist_append_string(plist, FHDR_HDUDOC, DEQ_HDUDOC);
216 cpl_propertylist_append_string(plist, FHDR_HDUVERS, DEQ_HDUVERS);
217 cpl_propertylist_append_string(plist, FHDR_HDUCLAS1, deq_hduclas);
219 return cpl_error_get_code();
231 cpl_propertylist_append_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_DATA);
232 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_SCIDATA);
233 cpl_propertylist_append_string(plist, FHDR_ERRDATA, DEQ_ERRDATA);
234 cpl_propertylist_append_string(plist, FHDR_QUALDATA, DEQ_QUALDATA);
236 return cpl_error_get_code();
247 deqErrorType errorType)
249 cpl_propertylist_update_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_ERROR);
250 cpl_propertylist_update_string(plist, FHDR_HDUCLAS3,
251 deqErrorTypeString[errorType]);
252 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_ERRDATA);
253 cpl_propertylist_update_string(plist, FHDR_SCIDATA, DEQ_SCIDATA);
254 cpl_propertylist_update_string(plist, FHDR_QUALDATA, DEQ_QUALDATA);
256 return cpl_error_get_code();
266 deqQualityType qualityType){
267 cpl_propertylist_update_string(plist, FHDR_HDUCLAS2, DEQ_HDUCLAS2_QUAL);
268 cpl_propertylist_update_string(plist, FHDR_HDUCLAS3,
269 deqQualityTypeString[qualityType]);
270 cpl_propertylist_update_string(plist, FHDR_EXTNAME, DEQ_QUALDATA);
271 cpl_propertylist_update_string(plist, FHDR_SCIDATA, DEQ_SCIDATA);
272 cpl_propertylist_update_string(plist, FHDR_ERRDATA, DEQ_ERRDATA);
274 return cpl_error_get_code();
301 cpl_frameset *allframes,
302 cpl_propertylist * header,
303 const cpl_parameterlist *parlist,
304 const cpl_frameset *usedframes,
305 const cpl_frame *inherit,
307 const cpl_propertylist *applist,
308 const char *remregexp,
309 const char *filename,
310 const cpl_image *image,
311 const cpl_image *error,
312 deqErrorType errorType,
313 const cpl_image *dataQualityMask,
314 deqQualityType dataQualityType,
317 cpl_error_code retVal = CPL_ERROR_NONE;
318 cpl_propertylist *dataHeader = NULL,
321 char *pipe_id = NULL;
323 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
324 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
325 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
326 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
327 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
328 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
329 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
334 cpl_propertylist* head_wcs_2d = NULL;
338 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
339 dataHeader = cpl_propertylist_new();
342 head_wcs_2d = eris_ifu_plist_extract_wcs2D(applist);
344 eris_ifu_plist_erase_wcs( (cpl_propertylist *) applist);
345 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"BUNIT")) {
346 cpl_propertylist_erase((cpl_propertylist *) applist,
"BUNIT");
348 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"EXTNAME")) {
349 cpl_propertylist_erase( (cpl_propertylist *)applist,
"EXTNAME");
351 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"HDUCLAS2")) {
352 cpl_propertylist_erase( (cpl_propertylist *)applist,
"HDUCLAS2");
354 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"COMMENT")) {
355 cpl_propertylist_erase( (cpl_propertylist *)applist,
"COMMENT");
358 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
359 inherit, recipe, applist, remregexp, pipe_id, filename);
360 cpl_propertylist_append(dataHeader, head_wcs_2d);
363 if(cpl_propertylist_has(dataHeader,
"BUNIT")) {
364 cpl_propertylist_set_string(dataHeader,
"BUNIT", unit);
366 cpl_propertylist_append_string(dataHeader,
"BUNIT", unit);
368 eris_pfits_clean_header_ra_dec_mjd_obs(dataHeader);
369 cpl_image_save(image, filename, cpl_image_get_type(image), dataHeader,
373 errsHeader = cpl_propertylist_new();
377 if(cpl_propertylist_has(errsHeader,
"BUNIT")) {
378 cpl_propertylist_set_string(errsHeader,
"BUNIT", unit);
380 cpl_propertylist_append_string(errsHeader,
"BUNIT", unit);
382 cpl_propertylist_append(errsHeader, head_wcs_2d);
383 eris_pfits_clean_header_ra_dec_mjd_obs(errsHeader);
384 cpl_image_save(error, filename, cpl_image_get_type(error), errsHeader,
388 if(dataQualityMask) {
389 qualHeader = cpl_propertylist_new();
393 if(cpl_propertylist_has(qualHeader,
"BUNIT")) {
394 cpl_propertylist_set_string(qualHeader,
"BUNIT",
"");
396 cpl_propertylist_append_string(qualHeader,
"BUNIT",
"");
398 cpl_propertylist_append(qualHeader, head_wcs_2d);
399 eris_pfits_clean_header_ra_dec_mjd_obs(qualHeader);
400 cpl_image_save(dataQualityMask, filename,
401 cpl_image_get_type(dataQualityMask), qualHeader, CPL_IO_EXTEND);
407 retVal = cpl_error_get_code();
442 cpl_frameset *allframes,
443 cpl_propertylist * header,
444 const cpl_parameterlist *parlist,
445 const cpl_frameset *usedframes,
446 const cpl_frame *inherit,
448 cpl_propertylist *applist,
449 const char *remregexp,
450 const char *filename,
452 cpl_imagelist *error,
453 deqErrorType errorType,
454 const cpl_imagelist *dataQualityMask,
455 deqQualityType qualityType
458 cpl_error_code retVal = CPL_ERROR_NONE;
459 cpl_propertylist *dataHeader = NULL,
462 char *pipe_id = NULL;
464 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
465 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
466 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
467 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
468 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
469 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
470 cpl_ensure_code(data, CPL_ERROR_NULL_INPUT);
471 cpl_ensure_code(error, CPL_ERROR_NULL_INPUT);
472 cpl_ensure_code(dataQualityMask, CPL_ERROR_NULL_INPUT);
477 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
480 if(cpl_propertylist_has(applist,
"CDELT3")) {
481 cpl_propertylist_erase(applist,
"CDELT3");
483 dataHeader = cpl_propertylist_duplicate(applist);
484 errsHeader = cpl_propertylist_duplicate(applist);
485 qualHeader = cpl_propertylist_duplicate(applist);
494 if(cpl_propertylist_has(dataHeader,
"HDRVER")) {
495 cpl_propertylist_erase(dataHeader,
"HDRVER");
497 if(cpl_propertylist_has(errsHeader,
"HDRVER")) {
498 cpl_propertylist_erase(errsHeader,
"HDRVER");
500 if(cpl_propertylist_has(qualHeader,
"HDRVER")) {
501 cpl_propertylist_erase(qualHeader,
"HDRVER");
503 if(cpl_propertylist_has(dataHeader,
"CTYPE1")) {
504 const char* ctype1 = cpl_propertylist_get_string(dataHeader,
"CTYPE1");
505 if (!cpl_propertylist_has(errsHeader,
"CTYPE1"))
506 cpl_propertylist_append_string(errsHeader,
"CTYPE1", ctype1);
507 if (!cpl_propertylist_has(qualHeader,
"CTYPE1"))
508 cpl_propertylist_append_string(qualHeader,
"CTYPE1", ctype1);
510 if(cpl_propertylist_has(dataHeader,
"CTYPE2")) {
511 const char* ctype2 = cpl_propertylist_get_string(dataHeader,
"CTYPE2");
512 if (!cpl_propertylist_has(errsHeader,
"CTYPE2"))
513 cpl_propertylist_append_string(errsHeader,
"CTYPE2",ctype2);
514 if (!cpl_propertylist_has(errsHeader,
"CTYPE2"))
515 cpl_propertylist_append_string(qualHeader,
"CTYPE2", ctype2);
519 eris_ifu_plist_erase_wcs( (cpl_propertylist *)applist);
520 eris_pfits_clean_header(dataHeader, CPL_TRUE);
521 eris_pfits_clean_header(errsHeader, CPL_TRUE);
522 eris_pfits_clean_header(qualHeader, CPL_TRUE);
523 if(strstr(filename,
"sky") != NULL) {
524 cpl_propertylist_append_string(applist,
"PRODCATG", PRODCATG_CUBE_SKY);
526 cpl_propertylist_append_string(applist,
"PRODCATG", PRODCATG_CUBE_OBJ);
528 if(cpl_propertylist_has(applist,
"BUNIT")) {
529 cpl_propertylist_erase(applist,
"BUNIT");
531 if(cpl_propertylist_has(applist,
"COMMENT")) {
532 cpl_propertylist_erase(applist,
"COMMENT");
536 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
537 inherit, recipe, applist, remregexp,
541 cpl_imagelist_save(data, filename,
542 cpl_image_get_type(cpl_imagelist_get(data,0)),
543 dataHeader, CPL_IO_EXTEND);
545 cpl_imagelist_save(error, filename,
546 cpl_image_get_type(cpl_imagelist_get(error,0)),
547 errsHeader, CPL_IO_EXTEND);
548 if(cpl_propertylist_has(qualHeader,
"BUNIT")) {
549 cpl_propertylist_set_string(qualHeader,
"BUNIT",
"");
551 cpl_propertylist_append_string(qualHeader,
"BUNIT",
"");
553 cpl_imagelist_save(dataQualityMask, filename,
555 qualHeader, CPL_IO_EXTEND);
559 retVal = cpl_error_get_code();
561 cpl_propertylist_delete(dataHeader);
562 cpl_propertylist_delete(errsHeader);
563 cpl_propertylist_delete(qualHeader);
587 cpl_frameset *allframes,
588 const cpl_parameterlist *parlist,
589 const cpl_frameset *usedframes,
591 const cpl_propertylist *applist,
592 const char *remregexp,
593 const char *filename,
594 const cpl_image *image,
598 cpl_error_code retVal = CPL_ERROR_NONE;
599 cpl_propertylist *dataHeader = NULL;
600 char *pipe_id = NULL;
602 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
603 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
604 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
605 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
606 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
607 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
608 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
610 cpl_propertylist* head_wcs_2d = NULL;
614 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
615 dataHeader = cpl_propertylist_new();
617 if(cpl_propertylist_has( (cpl_propertylist *) applist,
"EXTNAME")) {
618 cpl_propertylist_erase( (cpl_propertylist *)applist,
"EXTNAME");
622 if(cpl_propertylist_has(applist,
"BUNIT")) {
623 cpl_propertylist_set_string((cpl_propertylist *) applist,
"BUNIT", unit);
625 cpl_propertylist_append_string((cpl_propertylist *) applist,
"BUNIT", unit);
627 cpl_dfs_save_image(allframes, NULL, parlist, usedframes, NULL, image, type,
628 recipe, applist, remregexp, pipe_id, filename);
632 retVal = cpl_error_get_code();
661 cpl_frameset *allframes,
662 cpl_propertylist *header,
663 const cpl_parameterlist *parlist,
664 const cpl_frameset *usedframes,
665 const cpl_frame *inherit,
668 cpl_propertylist *applist,
669 const char *remregexp,
670 const char *filename,
671 const cpl_table *table)
673 cpl_error_code retVal = CPL_ERROR_NONE;
674 cpl_propertylist *dataHeader = NULL;
675 char *pipe_id = NULL;
677 cpl_ensure_code(allframes, CPL_ERROR_NULL_INPUT);
678 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
679 cpl_ensure_code(usedframes, CPL_ERROR_NULL_INPUT);
680 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
681 cpl_ensure_code(applist, CPL_ERROR_NULL_INPUT);
682 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
683 cpl_ensure_code(table, CPL_ERROR_NULL_INPUT);
684 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
689 pipe_id = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
691 dataHeader = cpl_propertylist_new();
694 cpl_propertylist_append_string(dataHeader, FHDR_HDUCLAS2, DEQ_HDUCLAS2_DATA);
695 cpl_propertylist_append_string(dataHeader, FHDR_EXTNAME, DEQ_SCIDATA);
696 cpl_propertylist_update_string(applist, CPL_DFS_PRO_CATG, procatg);
699 cpl_dfs_save_propertylist(allframes, header, parlist, usedframes,
700 inherit, recipe, applist, remregexp, pipe_id, filename);
703 cpl_table_save(table, dataHeader, applist, filename, CPL_IO_EXTEND);
708 retVal = cpl_error_get_code();
797 const char *filename,
798 cpl_propertylist **primaryHeader,
799 cpl_image **dataImage,
800 cpl_image **errImage,
801 cpl_image **qualImage,
802 deqErrorType *errorType,
803 deqQualityType *qualityType)
805 cpl_error_code retVal = CPL_ERROR_NONE;
809 cpl_propertylist *pl = NULL;
810 const char *property;
812 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
813 cpl_ensure_code(dataImage, CPL_ERROR_NULL_INPUT);
817 nExt = cpl_fits_count_extensions(filename);
821 "For a DEQ FITS file 3 extensions are expected, but %d are found",
824 *dataImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED, 0, 1);
826 if (primaryHeader != NULL) {
827 *primaryHeader = cpl_propertylist_load(filename, 0);
830 if (errImage != NULL) {
832 *errImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
834 pl = cpl_propertylist_load(filename, extension);
835 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
836 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
839 "keyword %s does not exist",
842 for (match=0; match<4; match++) {
843 if (strcmp(property, deqErrorTypeString[match]) == 0) {
850 "The HDUCLAS3 keyword for the error extension (%d) has an"
851 " unknown value of %s", extension, property);
856 if (qualImage != NULL) {
858 *qualImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
860 pl = cpl_propertylist_load(filename, extension);
861 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
862 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
865 "keyword %s does not exist",
868 for (match=0; match<4; match++) {
869 if (strcmp(property, deqQualityTypeString[match]) == 0) {
870 *qualityType = match;
876 "The HDUCLAS3 keyword for the error extension (%d) has an"
877 " unknown value of %s", (
int) extension, property);
884 retVal = cpl_error_get_code();
902 const char *filename,
903 cpl_propertylist **primaryHeader,
904 cpl_imagelist **dataImagelist,
905 cpl_imagelist **errImagelist,
906 cpl_imagelist **qualImagelist,
907 deqErrorType *errorType,
908 deqQualityType *qualityType)
910 cpl_error_code retVal = CPL_ERROR_NONE;
914 cpl_propertylist *pl = NULL;
915 const char *property;
917 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
918 cpl_ensure_code(dataImagelist, CPL_ERROR_NULL_INPUT);
922 nExt = cpl_fits_count_extensions(filename);
926 "For a DEQ FITS file 3 extensions are expected, but %d are found",
929 *dataImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED, 1);
931 if (primaryHeader != NULL) {
932 *primaryHeader = cpl_propertylist_load(filename, 0);
935 if (errImagelist != NULL) {
937 *errImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED,
939 pl = cpl_propertylist_load(filename, extension);
940 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
941 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
944 "keyword %s does not exist",
947 for (match=0; match<4; match++) {
948 if (strcmp(property, deqErrorTypeString[match]) == 0) {
955 "The HDUCLAS3 keyword for the error extension (%d) has an"
956 " unknown value of %s", extension, property);
961 if (qualImagelist != NULL) {
963 *qualImagelist = cpl_imagelist_load(filename, CPL_TYPE_UNSPECIFIED,
965 pl = cpl_propertylist_load(filename, extension);
966 if (cpl_propertylist_has(pl, FHDR_HDUCLAS3)) {
967 property = cpl_propertylist_get_string(pl, FHDR_HDUCLAS3);
970 "keyword %s does not exist",
973 for (match=0; match<4; match++) {
974 if (strcmp(property, deqQualityTypeString[match]) == 0) {
975 *qualityType = match;
981 "The HDUCLAS3 keyword for the error extension (%d) has an"
982 " unknown value of %s", (
int) extension, property);
989 retVal = cpl_error_get_code();
1004 const char *filename,
1005 cpl_propertylist **primaryHeader,
1006 cpl_image **qualImage,
1007 deqQualityType *qualityType)
1009 hdrl_image *image = NULL;
1010 cpl_image *dataImage = NULL;
1011 cpl_image *errImage = NULL;
1012 cpl_mask *mask = NULL;
1014 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1018 deqErrorType errorType;
1020 &dataImage, &errImage, qualImage, &errorType, qualityType);
1024 cpl_image_power(errImage, 0.5);
1033 "Cannot transfer error extension type %s to a HDLR error"
1034 " image", deqErrorTypeString[errorType]);
1038 "Internal error: unknown errorType enumeration value: %d",
1043 if (qualImage != NULL) {
1044 switch (*qualityType) {
1052 mask = cpl_mask_threshold_image_create(*qualImage,
1056 mask = cpl_mask_threshold_image_create(*qualImage,
1061 CPL_ERROR_ACCESS_OUT_OF_RANGE,
1062 "Internal error: unknown qualityType enumeration"
1070 cpl_image_set_bpm(dataImage, mask);
1077 cpl_mask_delete(mask);
1081 cpl_image_delete(dataImage);
1082 cpl_image_delete(errImage);
1096 const char *filename,
1097 cpl_propertylist **primaryHeader,
1098 cpl_imagelist **qualImagelist,
1099 deqQualityType *qualityType)
1101 hdrl_imagelist *imagelist = NULL;
1102 cpl_imagelist *dataImagelist = NULL;
1103 cpl_imagelist *errImagelist = NULL;
1104 cpl_image *dataImage = NULL;
1105 cpl_image *errImage = NULL;
1106 cpl_image *qualImage = NULL;
1107 cpl_mask *mask = NULL;
1108 deqErrorType errorType;
1110 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1115 &dataImagelist, &errImagelist, qualImagelist, &errorType, qualityType);
1117 if ((cpl_imagelist_get_size(dataImagelist) != cpl_imagelist_get_size(errImagelist))
1119 (cpl_imagelist_get_size(dataImagelist) != cpl_imagelist_get_size(*qualImagelist)))
1122 "All imagelists of an DEQ imagelist file must have the same size");
1125 for (cpl_size ix=0; ix < cpl_imagelist_get_size(dataImagelist); ix++) {
1126 dataImage = cpl_imagelist_get(dataImagelist, ix);
1127 errImage = cpl_imagelist_get(errImagelist, ix);
1128 qualImage = cpl_imagelist_get(*qualImagelist, ix);
1133 cpl_image_power(errImage, 0.5));
1143 "Cannot transfer error extension type %s to a HDLR error"
1144 " image", deqErrorTypeString[errorType]);
1148 "Internal error: unknown errorType enumeration value: %d",
1153 if (qualImage != NULL) {
1154 switch (*qualityType) {
1162 mask = cpl_mask_threshold_image_create(qualImage,
1166 mask = cpl_mask_threshold_image_create(qualImage,
1171 CPL_ERROR_ACCESS_OUT_OF_RANGE,
1172 "Internal error: unknown qualityType enumeration"
1181 for (cpl_size ny = 1; ny <= cpl_image_get_size_y(dataImage); ny++) {
1182 for (cpl_size nx = 1; nx <= cpl_image_get_size_x(dataImage); nx++) {
1186 cpl_mask_set(mask, nx, ny, BAD_PIX);
1191 cpl_image_set_bpm(dataImage, mask);
1192 cpl_image_set_bpm(errImage, cpl_mask_duplicate(mask));
1194 cpl_imagelist_set(dataImagelist, dataImage, ix);
1195 cpl_imagelist_set(errImagelist, errImage, ix);
1199 dataImagelist, errImagelist);
1206 cpl_imagelist_delete(dataImagelist);
1207 cpl_imagelist_delete(errImagelist);
1222 const cpl_frame *frame,
1224 ifsPreopticsScale scale,
1225 cpl_image **qualImage,
1226 deqQualityType *qualType)
1228 hdrl_image *image = NULL;
1229 const char *filename;
1231 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, NULL);
1235 filename = cpl_frame_get_filename(frame);
1237 filename, band, scale, qualImage, qualType);
1258 const char *filename,
1260 ifsPreopticsScale scale,
1261 cpl_image **qualImage,
1262 deqQualityType *qualType)
1264 hdrl_image *image = NULL;
1265 cpl_propertylist *header = NULL;
1266 cpl_image *dataImage = NULL;
1267 cpl_image *errorImage = NULL;
1272 cpl_ensure(filename, CPL_ERROR_NULL_INPUT, NULL);
1276 nExt = cpl_fits_count_extensions(filename);
1279 qualImage, qualType);
1281 header = cpl_propertylist_load(filename, 0);
1282 dataImage = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED,
1284 errorImage = cpl_image_abs_create(dataImage);
1285 cpl_image_multiply_scalar(errorImage, 0.1);
1288 if (qualType != NULL) {
1289 *qualType = unspecified;
1292 if ((band != UNDEFINED_BAND) &&
1295 "different instrument band setting"
1296 " in calibration frame %s", filename);
1298 if ((scale != UNDEFINED_SCALE) &&
1302 "different instrument pre-optics setting"
1303 " in calibration frame %s", filename);
1328 const char* filename,
1329 cpl_polynomial ** poly_u,
1330 cpl_polynomial ** poly_v)
1332 cpl_error_code retVal = CPL_ERROR_NONE;
1333 cpl_table *distortionTable = NULL;
1334 cpl_size nTableRows;
1340 *poly_u = cpl_polynomial_new(2);
1341 *poly_v = cpl_polynomial_new(2);
1343 distortionTable = cpl_table_load(filename,1,0);
1344 nTableRows = cpl_table_get_nrow(distortionTable);
1346 for (cpl_size i=0; i<nTableRows; i++) {
1347 pows[0] = cpl_table_get_int(distortionTable,
"degx", i, NULL);
1348 pows[1] = cpl_table_get_int(distortionTable,
"degy", i, NULL);
1349 coeff = cpl_table_get_double(distortionTable,
"coeff", i, NULL);
1350 cpl_polynomial_set_coeff(*poly_u, pows, coeff);
1356 cpl_polynomial_set_coeff(*poly_v, pows, 1.0);
1361 retVal = cpl_error_get_code();
1378 const char* filename,
1379 cpl_polynomial ***polynomials,
1380 cpl_table **borders)
1382 cpl_error_code retVal = CPL_ERROR_NONE;
1383 cpl_table *distortionTable = NULL;
1390 cpl_calloc(SLITLET_CNT,
sizeof(cpl_polynomial*));
1392 for (
int sx = 0; sx < SLITLET_CNT; sx++) {
1393 cpl_size nTableRows;
1396 distortionTable = cpl_table_load(filename, sx+1, 0);
1397 nTableRows = cpl_table_get_nrow(distortionTable);
1399 (*polynomials)[sx] = cpl_polynomial_new(2);
1401 for (cpl_size i=0; i<nTableRows; i++) {
1405 pows[0] = cpl_table_get_int(distortionTable,
"degx", i, NULL);
1406 pows[1] = cpl_table_get_int(distortionTable,
"degy", i, NULL);
1407 coeff = cpl_table_get_double(distortionTable,
"coeff", i, NULL);
1408 cpl_polynomial_set_coeff((*polynomials)[sx], pows, coeff);
1414 *borders = cpl_table_load(filename, SLITLET_CNT+1, 0);
1418 if (*polynomials != NULL) {
1419 for (
int sx = 0; sx < SLITLET_CNT; sx++) {
1420 cpl_polynomial_delete((*polynomials)[sx]);
1424 retVal = cpl_error_set_where(cpl_func);
1432#define ERIS_IFU_DIST_SLIT_DISTANCE "slitlet_distance"
1441 const char* filename)
1443 cpl_vector *distances = NULL;
1444 cpl_table *table = NULL;
1445 cpl_size nTableRows = 0;
1450 table = cpl_table_load(filename,1,0);
1451 nTableRows = cpl_table_get_nrow(table);
1453 distances = cpl_vector_new(nTableRows);
1454 cpl_type type = cpl_table_get_column_type(table, ERIS_IFU_DIST_SLIT_DISTANCE);
1455 for (cpl_size i=0; i<nTableRows; i++) {
1456 if (type == CPL_TYPE_DOUBLE) {
1457 val = cpl_table_get_double(table, ERIS_IFU_DIST_SLIT_DISTANCE, i, NULL);
1458 }
else if (type == CPL_TYPE_FLOAT) {
1459 val = cpl_table_get_float(table, ERIS_IFU_DIST_SLIT_DISTANCE, i, NULL);
1464 cpl_vector_set(distances, i, val));
1469 cpl_vector_delete(distances);
1478#define ERIS_IFU_DIST_EDGE_L_old "pos1"
1479#define ERIS_IFU_DIST_EDGE_R_old "pos2"
1487 const char* filename)
1489 cpl_bivector *slitPos = NULL;
1490 cpl_vector *pos1 = NULL;
1491 cpl_vector *pos2 = NULL;
1492 cpl_table *slitPosTable = NULL;
1493 cpl_size nTableRows;
1497 slitPosTable = cpl_table_load(filename,1,0);
1498 nTableRows = cpl_table_get_nrow(slitPosTable);
1500 slitPos = cpl_bivector_new(nTableRows);
1501 pos1 = cpl_bivector_get_x(slitPos);
1502 pos2 = cpl_bivector_get_y(slitPos);
1505 for (cpl_size i=0; i<nTableRows; i++) {
1508 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_L, i, NULL);
1509 if (cpl_error_get_code()== CPL_ERROR_DATA_NOT_FOUND) {
1512 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_L_old, i, NULL);
1514 cpl_vector_set(pos1, i, val);
1517 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_R, i, NULL);
1518 if (cpl_error_get_code()== CPL_ERROR_DATA_NOT_FOUND) {
1521 val = cpl_table_get_double(slitPosTable, ERIS_IFU_DIST_EDGE_R_old, i, NULL);
1523 cpl_vector_set(pos2, i, val);
1528 cpl_bivector_delete(slitPos);
1548 cpl_propertylist *pl,
1551 const char* comment)
1553 cpl_error_code retVal = CPL_ERROR_NONE;
1554 char *qcName = NULL;
1556 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1557 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1558 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1562 qcName = cpl_sprintf(
"ESO QC %s", name);
1563 cpl_propertylist_append_int(pl, qcName, val);
1564 cpl_propertylist_set_comment(pl , qcName, comment);
1568 retVal = cpl_error_get_code();
1586 cpl_propertylist *pl,
1589 const char* comment)
1591 cpl_error_code retVal = CPL_ERROR_NONE;
1592 char *qcName = NULL;
1594 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1595 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1596 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1600 qcName = cpl_sprintf(
"ESO QC %s", name);
1601 cpl_propertylist_append_double(pl, qcName, val);
1602 cpl_propertylist_set_comment(pl , qcName, comment);
1606 retVal = cpl_error_get_code();
1625 cpl_propertylist *pl,
1628 const char* comment)
1630 cpl_error_code retVal = CPL_ERROR_NONE;
1631 char *qcName = NULL;
1633 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1634 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1635 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1639 qcName = cpl_sprintf(
"ESO QC %s", name);
1640 cpl_propertylist_append_float(pl, qcName, val);
1641 cpl_propertylist_set_comment(pl , qcName, comment);
1645 retVal = cpl_error_get_code();
1666 const char *comment)
1668 cpl_error_code retVal = CPL_ERROR_NONE;
1669 char *qcName = NULL;
1671 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
1672 cpl_ensure_code(name, CPL_ERROR_NULL_INPUT);
1673 cpl_ensure_code(comment, CPL_ERROR_NULL_INPUT);
1677 qcName = cpl_sprintf(
"ESO QC %s", name);
1678 cpl_propertylist_set_int(pl, qcName, val);
1679 cpl_propertylist_set_comment(pl, qcName, comment);
1683 retVal = cpl_error_get_code();
1699 bool result =
false;
1700 cpl_propertylist *pl = NULL;
1701 const char *fn = NULL;
1702 char *dpr_type = NULL;
1704 cpl_ensure(fr != NULL, CPL_ERROR_NULL_INPUT,
false);
1708 fn = cpl_frame_get_filename(fr);
1709 eris_ifu_file_exists(fn);
1711 pl = cpl_propertylist_load(fn, 0);
1713 if (cpl_propertylist_has(pl, FHDR_DPR_TYPE)) {
1714 dpr_type = cpl_strdup(
1715 cpl_propertylist_get_string(pl, FHDR_DPR_TYPE));
1718 "keyword %s does not exist",
1722 if ((strstr(dpr_type,
"STD") != NULL) ||
1723 (strstr(dpr_type,
"PSF") != NULL) ||
1724 (strstr(dpr_type,
"SKY") != NULL) ||
1725 (strstr(dpr_type,
"OBJECT") != NULL))
1754 bool result =
false;
1755 cpl_propertylist *pl = NULL;
1756 const char *fn = NULL;
1757 char *dpr_type = NULL;
1759 cpl_ensure(fr, CPL_ERROR_NULL_INPUT,
false);
1763 fn = cpl_frame_get_filename(fr);
1764 eris_ifu_file_exists(fn);
1765 pl = cpl_propertylist_load(fn, 0);
1768 if (cpl_propertylist_has(pl, FHDR_DPR_TYPE)) {
1769 dpr_type = cpl_strdup(
1770 cpl_propertylist_get_string(pl, FHDR_DPR_TYPE));
1773 "keyword %s does not exist",
1778 if (strstr(dpr_type, ERIS_IFU_RAW_SKY) != NULL) {
1801 ifsInstrument instrument = UNSET_INSTRUMENT;
1803 cpl_ensure(header, CPL_ERROR_NULL_INPUT, 0);
1809 if (instrument == SPIFFIER) {
1810 dit = cpl_propertylist_get_float(header, FHDR_E_DIT);
1812 }
else if (instrument == SPIFFI) {
1813 dit = cpl_propertylist_get_float(header, FHDR_S_DIT);
1841 ifsInstrument instrument = UNSET_INSTRUMENT;
1849 cpl_ensure_code(header, CPL_ERROR_NULL_INPUT);
1855 if (instrument == SPIFFIER) {
1856 cpl_msg_debug(
"eris_ifu_get_callamp_status",
"ERIS/SPIFFIER found");
1857 if (cpl_propertylist_has(header, FHDR_E_AR_LAMP_ST)) {
1858 if (cpl_propertylist_get_bool(header, FHDR_E_AR_LAMP_ST)) {
1859 lampMask += AR_LAMP;
1863 if (cpl_propertylist_has(header, FHDR_E_KR_LAMP_ST)) {
1864 if (cpl_propertylist_get_bool(header, FHDR_E_KR_LAMP_ST)) {
1865 lampMask += KR_LAMP;
1869 if (cpl_propertylist_has(header, FHDR_E_NE_LAMP_ST)) {
1870 if (cpl_propertylist_get_bool(header, FHDR_E_NE_LAMP_ST)) {
1871 lampMask += NE_LAMP;
1875 if (cpl_propertylist_has(header, FHDR_E_XE_LAMP_ST)) {
1876 if (cpl_propertylist_get_bool(header, FHDR_E_XE_LAMP_ST)) {
1877 lampMask += XE_LAMP;
1881 if (cpl_propertylist_has(header, FHDR_E_QTH_LAMP_ST)) {
1882 if (cpl_propertylist_get_bool(header,FHDR_E_QTH_LAMP_ST)) {
1883 lampMask += QTH_LAMP;
1887 }
else if (instrument == SPIFFI) {
1888 cpl_msg_debug(
"eris_ifu_get_callamp_status",
"SINFONI/SPIFFI found");
1889 if (cpl_propertylist_get_bool(header,FHDR_S_AR_LAMP_ST)) {
1890 lampMask += AR_LAMP;
1893 if (cpl_propertylist_get_bool(header,FHDR_S_KR_LAMP_ST)) {
1894 lampMask += KR_LAMP;
1897 if (cpl_propertylist_get_bool(header,FHDR_S_NE_LAMP_ST)) {
1898 lampMask += NE_LAMP;
1901 if (cpl_propertylist_get_bool(header,FHDR_S_XE_LAMP_ST)) {
1902 lampMask += XE_LAMP;
1905 if (cpl_propertylist_get_bool(header,FHDR_S_QTH_LAMP_ST)) {
1906 lampMask += QTH_LAMP;
1915 cpl_msg_debug(cpl_func,
1916 "Lamps: Ar: %d, Kr: %d, Ne: %d, Xe: %d, Qth: %d, mask: %d",
1917 lampAr, lampKr, lampNe, lampXe, lampQth, lampMask);
1929 ifsBand band = UNDEFINED_BAND;
1930 ifsInstrument instrument = UNSET_INSTRUMENT;
1931 const char *bandId = NULL;
1935 if (header == NULL) {
1941 if (instrument == SPIFFIER) {
1942 bandId = cpl_propertylist_get_string(header, FHDR_E_GRATING_ID);
1944 if (strcmp(bandId, E_GRATING_J_LOW) == 0) {
1946 }
else if (strcmp(bandId, E_GRATING_J_SHORT) == 0) {
1948 }
else if (strcmp(bandId, E_GRATING_J_MIDDLE) == 0) {
1950 }
else if (strcmp(bandId, E_GRATING_J_LONG) == 0) {
1952 }
else if (strcmp(bandId, E_GRATING_H_LOW) == 0) {
1954 }
else if (strcmp(bandId, E_GRATING_H_SHORT) == 0) {
1956 }
else if (strcmp(bandId, E_GRATING_H_MIDDLE) == 0) {
1958 }
else if (strcmp(bandId, E_GRATING_H_LONG) == 0) {
1960 }
else if (strcmp(bandId, E_GRATING_K_LOW) == 0) {
1962 }
else if (strcmp(bandId, E_GRATING_K_SHORT) == 0) {
1964 }
else if (strcmp(bandId, E_GRATING_K_MIDDLE) == 0) {
1966 }
else if (strcmp(bandId, E_GRATING_K_LONG) == 0) {
1968 }
else if (strcmp(bandId, E_PREOPTICS_PUPIL) == 0) {
1969 cpl_msg_warning(cpl_func,
"found pupil data");
1972 }
else if (instrument == SPIFFI) {
1973 bandId = cpl_propertylist_get_string(header, FHDR_S_GRATING_ID);
1975 if (strcmp(bandId, S_GRATING_J_BAND) == 0) {
1977 }
else if (strcmp(bandId, S_GRATING_H_BAND) == 0) {
1979 }
else if (strcmp(bandId, S_GRATING_K_BAND) == 0) {
1981 }
else if (strcmp(bandId, S_GRATING_HK_BAND) == 0) {
1984 band = UNDEFINED_BAND;
1990 band = UNDEFINED_BAND;
2008 ifsInstrument instrument = UNSET_INSTRUMENT;
2009 const char *instrumentStr = NULL;
2010 const char *armStr = NULL;
2014 if (header == NULL) {
2018 instrumentStr = cpl_propertylist_get_string(header, FHDR_INSTRUMENT);
2020 "Cannot read "FHDR_INSTRUMENT
" FITS keyword");
2021 if (strcmp(instrumentStr, INSTRUMENT_SINFONI) == 0) {
2022 instrument = SPIFFI;
2023 }
else if (strcmp(instrumentStr, INSTRUMENT_ERIS) == 0) {
2024 armStr = cpl_propertylist_get_string(header, FHDR_E_ARM);
2026 "Cannot read "FHDR_E_ARM
" FITS keyword");
2027 if (strcmp(armStr, ARM_SPIFFIER) == 0) {
2028 instrument = SPIFFIER;
2029 }
else if (strcmp(armStr, ARM_NIX) == 0) {
2030 cpl_msg_error(cpl_func,
"ERIS/NIX frame detected");
2032 "ERIS/NIX frame detected");
2036 "Unkown instrument arm %s, neither SPIFFIER nor NIX",
2039 "Unkown instrument arm, neither SPIFFIER nor NIX");
2040 instrument = OTHER_INSTRUMENT;
2044 "Unkown instrument %s, neither ERIS/SPIFFIER nor SINFONI",
2047 "Unkown instrument, neither ERIS/SPIFFIER nor SINFONI");
2048 instrument = OTHER_INSTRUMENT;
2053 instrument = UNSET_INSTRUMENT;
2068 ifsPreopticsScale scale = UNDEFINED_SCALE;
2069 if (strcmp(scaleId, E_PREOPTICS_250MAS_SCALE) == 0) {
2071 }
else if (strcmp(scaleId, E_PREOPTICS_100MAS_SCALE) == 0) {
2073 }
else if (strcmp(scaleId, E_PREOPTICS_25MAS_SCALE) == 0) {
2075 }
else if (strcmp(scaleId, E_PREOPTICS_PUPIL) == 0) {
2078 scale = UNDEFINED_SCALE;
2092 ifsPreopticsScale scale = UNDEFINED_SCALE;
2093 if (strcmp(scaleId, S_PREOPTICS_250MAS_SCALE) == 0) {
2095 }
else if (strcmp(scaleId, S_PREOPTICS_100MAS_SCALE) == 0) {
2097 }
else if (strcmp(scaleId, S_PREOPTICS_25MAS_SCALE) == 0) {
2099 }
else if (strcmp(scaleId, S_PREOPTICS_PUPIL) == 0) {
2102 scale = UNDEFINED_SCALE;
2123 cpl_propertylist *header)
2125 ifsPreopticsScale scale = UNDEFINED_SCALE;
2126 ifsInstrument instrument = UNSET_INSTRUMENT;
2127 const char *scaleId;
2133 if (instrument == SPIFFIER) {
2134 scaleId = cpl_propertylist_get_string(header, FHDR_E_PREOPTICS_ID);
2137 }
else if (instrument == SPIFFI) {
2138 scaleId = cpl_propertylist_get_string(header, FHDR_S_PREOPTICS_ID);
2146 scale = UNDEFINED_SCALE;
2153#define KEY_NAME_COMOFFS_RA "ESO OCS CUMOFFS RA"
2154#define KEY_NAME_COMOFFS_DEC "ESO OCS CUMOFFS DEC"
2169 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, -1.0);
2170 cpl_propertylist* plist=NULL;
2174 file = cpl_strdup( cpl_frame_get_filename(frame)) ;
2176 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2177 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2178 cpl_propertylist_delete(plist) ;
2183 if (cpl_propertylist_has(plist, KEY_NAME_COMOFFS_RA)) {
2184 result=cpl_propertylist_get_double(plist, KEY_NAME_COMOFFS_RA);
2186 cpl_msg_error(cpl_func,
"keyword %s does not exist",KEY_NAME_COMOFFS_RA);
2187 cpl_propertylist_delete(plist) ;
2191 cpl_propertylist_delete(plist) ;
2211 cpl_ensure(frame, CPL_ERROR_NULL_INPUT, -999.0);
2212 cpl_propertylist* plist=NULL;
2216 file = cpl_strdup( cpl_frame_get_filename(frame)) ;
2218 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2219 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2220 cpl_propertylist_delete(plist) ;
2225 if (cpl_propertylist_has(plist, KEY_NAME_COMOFFS_DEC)) {
2226 result=cpl_propertylist_get_double(plist, KEY_NAME_COMOFFS_DEC);
2228 cpl_msg_error(cpl_func,
"keyword %s does not exist",KEY_NAME_COMOFFS_DEC);
2229 cpl_propertylist_delete(plist) ;
2233 cpl_propertylist_delete(plist) ;
2251 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, -1.0);
2253 cpl_propertylist* plist=NULL;
2254 const char* file=NULL;
2257 file = cpl_frame_get_filename(frame) ;
2259 if ((cpl_error_code)((plist = cpl_propertylist_load(file, 0)) == NULL)) {
2260 cpl_msg_error(cpl_func,
"getting header from reference frame %s",file);
2261 cpl_propertylist_delete(plist) ;
2264 if(cpl_propertylist_has(plist,
"MJD-OBS")){
2267 cpl_propertylist_delete(plist) ;
2268 cpl_error_set(cpl_func,CPL_ERROR_ILLEGAL_INPUT);
2273 cpl_propertylist_delete(plist) ;
2289 cpl_boolean result = CPL_FALSE;
2295 if ((strstr(ERIS_IFU_PRO_CALIB_TAGS, tag) != NULL) ||
2296 (strstr(ERIS_IFU_REF_CALIB_TAGS, tag) != NULL))
2314 cpl_boolean result = CPL_FALSE;
2320 char* tag_loc = (
char*) tag;
2321 if ((strcmp(tag_loc, ERIS_IFU_RAW_SKY) == 0) ||
2322 (strcmp(tag_loc, ERIS_IFU_RAW_OBJ_SKY) == 0) ||
2323 (strcmp(tag_loc, ERIS_IFU_RAW_STD_FLUX_SKY) == 0) ||
2324 (strcmp(tag_loc, ERIS_IFU_RAW_STD_SKY) == 0) ||
2325 (strcmp(tag_loc, ERIS_IFU_RAW_PSF_SKY) == 0) ||
2326 (strcmp(tag_loc, ERIS_IFU_RAW_PUPIL_SKY) == 0))
2341 cpl_boolean result = CPL_FALSE;
2347 char* tag_loc = (
char*) tag;
2348 if ((strcmp(tag_loc, ERIS_IFU_RAW_OBJ) == 0) ||
2349 (strcmp(tag_loc, ERIS_IFU_RAW_STD) == 0) ||
2350 (strcmp(tag_loc, ERIS_IFU_RAW_STD_FLUX) == 0) ||
2351 (strcmp(tag_loc, ERIS_IFU_RAW_PSF) == 0) ||
2352 (strcmp(tag_loc, ERIS_IFU_RAW_PUPIL_LAMP) == 0))
2369 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2370 cpl_ensure_code(obj, CPL_ERROR_NULL_INPUT);
2372 cpl_size nsof = cpl_frameset_get_size(sof);
2374 for (cpl_size i = 0 ; i < nsof ; i++) {
2375 const cpl_frame* frame = cpl_frameset_get_position_const(sof, i);
2376 cpl_frame_group group = cpl_frame_get_group(frame);
2378 if(group == CPL_FRAME_GROUP_RAW) {
2381 const char* tag = cpl_frame_get_tag(frame);
2385 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2386 cpl_frameset_insert(obj, frame_dup);
2394 return cpl_error_get_code();
2408 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2409 cpl_ensure_code(sky, CPL_ERROR_NULL_INPUT);
2411 cpl_size nsof = cpl_frameset_get_size(sof);
2412 for (cpl_size i = 0 ; i < nsof ; i++) {
2413 const cpl_frame* frame = cpl_frameset_get_position_const(sof, i);
2414 cpl_frame_group group = cpl_frame_get_group(frame);
2416 if(group == CPL_FRAME_GROUP_RAW) {
2418 const char* tag = cpl_frame_get_tag(frame);
2420 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2421 cpl_frameset_insert(sky, frame_dup);
2428 return cpl_error_get_code();
2442 cpl_ensure_code(sof, CPL_ERROR_NULL_INPUT);
2443 cpl_ensure_code(cdb, CPL_ERROR_NULL_INPUT);
2445 cpl_size nsof = cpl_frameset_get_size(sof);
2446 for (cpl_size i = 0 ; i < nsof ; i++) {
2447 const cpl_frame* frame = cpl_frameset_get_position_const(sof,i);
2448 cpl_frame_group group = cpl_frame_get_group(frame);
2450 if(group == CPL_FRAME_GROUP_CALIB) {
2452 if(cpl_frame_get_tag(frame) != NULL) {
2454 char* tag= (
char*) cpl_frame_get_tag(frame);
2456 cpl_frame* frame_dup = cpl_frame_duplicate(frame);
2457 cpl_frameset_insert(cdb, frame_dup);
2464 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)
Function to load slitlet positions.
float eris_ifu_get_dit(cpl_propertylist *header)
Determine if a frame is a Sky frame or not.
cpl_error_code eris_ifu_heades_add_hduclass_qual(cpl_propertylist *plist, deqQualityType qualityType)
add common quality info properties on errors
bool eris_ifu_frame_is_sky(const cpl_frame *fr)
Determine if a frame is a Sky frame or not.
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)
Function to load an imagelist with error an 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)
Function to load distortion polynomials.
cpl_frameset * eris_ifu_extract_frameset(const cpl_frameset *in, const char *tag)
Extract the frames with the given 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)
Write DFS pipeline product with image, error and data qual.
hdrl_image * eris_ifu_load_cal_image_frame(const cpl_frame *frame, ifsBand band, ifsPreopticsScale scale, cpl_image **qualImage, deqQualityType *qualType)
Function to load a calibration image 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)
Function to load a calibration image 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)
Function to load an HDRL imagelist with quality extensions.
cpl_error_code eris_ifu_heades_add_hduclass_common(cpl_propertylist *plist, const char *deq_hduclas)
add common properties
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)
Function to load an HDRL image with quality extensions.
cpl_error_code eris_ifu_dfs_set_groups(cpl_frameset *self)
Set the group as RAW or CALIB 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 a QC parameter of type INT to 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)
Write DFS pipeline product with image, error and data qual.
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)
Write DFS pipeline product with image, error and data qual.
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)
Write DFS pipeline product with table.
cpl_error_code eris_ifu_heades_add_hduclass_data(cpl_propertylist *plist)
add common data info properties
cpl_vector * eris_ifu_load_distances(const char *filename)
Function to load slitlet distances.
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 common errors info properties
cpl_error_code eris_ifu_load_distortion_polynomials_old(const char *filename, cpl_polynomial **poly_u, cpl_polynomial **poly_v)
Function to load distortion polynomials.
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 is obtained with 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)
Return value of INSTRUME from a given input 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
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.