38#include "eris_ifu_utils.h"
39#include "eris_ifu_error.h"
40#include "eris_ifu_functions.h"
41#include "eris_utils.h"
42#include "eris_pfits.h"
80 cpl_vector *ret_vec = NULL;
81 double *pret_vec = NULL;
82 const double *pdata = NULL;
86 cpl_ensure(data, CPL_ERROR_NULL_INPUT, NULL);
90 size = cpl_vector_get_size(data);
94 ret_vec = cpl_vector_new(size);
95 pret_vec = cpl_vector_get_data(ret_vec);
97 cpl_vector_fill(ret_vec, -1.0);
100 pdata = cpl_vector_get_data_const(data);
103 for (
int i = 0; i < size; i++) {
110 if (fabs(pdata[i]-val) > 0.0001)
169 const cpl_vector *indices)
171 cpl_vector* ret_vec = NULL;
172 double *pret_vec = NULL;
173 const double *pdata = NULL,
177 cpl_ensure(data, CPL_ERROR_NULL_INPUT, NULL);
178 cpl_ensure(indices, CPL_ERROR_NULL_INPUT, NULL);
182 pdata = cpl_vector_get_data_const(data);
183 pindices = cpl_vector_get_data_const(indices);
185 size = cpl_vector_get_size(indices);
187 ret_vec = cpl_vector_new(size);
188 pret_vec = cpl_vector_get_data(ret_vec);
190 for (
int i = 0; i < size; i++) {
191 if ((
int)pindices[i] < 0) {
193 "One of the indices is < 0!");
195 pret_vec[i] = pdata[(int)pindices[i]];
234 int *begin,
int *end,
int cut)
236 cpl_error_code err = CPL_ERROR_NONE;
240 cpl_vector *tmp_vec = NULL;
242 cpl_ensure_code(vec, CPL_ERROR_NULL_INPUT);
243 cpl_ensure_code(*vec, CPL_ERROR_NULL_INPUT);
247 pvec = cpl_vector_get_data(*vec);
249 max = cpl_vector_get_size(*vec)-1;
252 for (
int i = 0; i < cpl_vector_get_size(*vec); i++) {
260 if (min != cpl_vector_get_size(*vec)) {
262 for (
int i = cpl_vector_get_size(*vec)-1; i >= 0; i--) {
272 tmp_vec = cpl_vector_extract(*vec, min, max, 1);
274 cpl_vector_delete(*vec); *vec= NULL;
281 cpl_vector_delete(*vec); *vec = NULL;
300 err = cpl_error_get_code();
332 int exposureCorrectionMode)
334 hdrl_imagelist *hdrl_list = NULL;
335 cpl_frameset *frames = NULL;
336 hdrl_image *tmp_img = NULL;
337 const cpl_frame *fr = NULL;
338 const char *fn = NULL;
340 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
341 cpl_ensure(tag, CPL_ERROR_NULL_INPUT, NULL);
352 fr = cpl_frameset_find_const(frames, tag);
355 fn = cpl_frame_get_filename(fr);
356 eris_ifu_file_exists(fn);
360 if (cpl_frame_get_tag(fr) != NULL) {
362 exposureCorrectionMode, NULL);
371 fr = cpl_frameset_find_const(frames, NULL);
392 const cpl_frameset *frameset,
395 cpl_frameset *frames = NULL;
396 const cpl_frame *curFrame ;
397 cpl_frame *locFrame ;
401 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
402 cpl_ensure(tag, CPL_ERROR_NULL_INPUT, NULL);
407 frameCnt = cpl_frameset_count_tags(frameset, tag);
412 "frameset contains no frames with tag %s", tag);
416 frames = cpl_frameset_new() ;
419 frameCnt = cpl_frameset_get_size(frameset) ;
420 for (i=0 ; i<frameCnt ; i++) {
421 curFrame = cpl_frameset_get_position_const(frameset, i) ;
422 if (!strcmp(cpl_frame_get_tag(curFrame), tag)) {
423 locFrame = cpl_frame_duplicate(curFrame) ;
424 cpl_frameset_insert(frames, locFrame) ;
443 cpl_parameterlist *p1,
444 const cpl_parameterlist *p2)
446 cpl_error_code err = CPL_ERROR_NONE;
447 const cpl_parameter *p = NULL;
449 cpl_ensure_code(p1, CPL_ERROR_NULL_INPUT);
450 cpl_ensure_code(p2, CPL_ERROR_NULL_INPUT);
454 p = cpl_parameterlist_get_first_const(p2);
455 cpl_parameterlist_append(p1, cpl_parameter_duplicate(p));
456 while ((p = cpl_parameterlist_get_next_const(p2)) != NULL) {
457 cpl_parameterlist_append(p1, cpl_parameter_duplicate(p));
463 err = cpl_error_get_code();
475 if ((item != NULL) && (*item != NULL)) {
485 if ((item != NULL) && (*item != NULL)) {
495 if ((item != NULL) && (*item != NULL)) {
496 cpl_image_delete(*item);
505 if ((item != NULL) && (*item != NULL)) {
506 cpl_imagelist_delete(*item);
515 if ((item != NULL) && (*item != NULL)) {
516 cpl_mask_delete(*item);
525 if ((item != NULL) && (*item != NULL)) {
526 cpl_matrix_delete(*item);
535 if ((item != NULL) && (*item != NULL)) {
536 cpl_propertylist_delete(*item);
545 if ((item != NULL) && (*item != NULL)) {
546 cpl_vector_delete(*item);
555 if ((item != NULL) && (*item != NULL)) {
565 if ((item != NULL) && (*item != NULL)) {
575 if ((item != NULL) && (*item != NULL)) {
576 cpl_frameset_delete(*item);
585 if ((item != NULL) && (*item != NULL)) {
586 cpl_frame_delete(*item);
595 if ((item != NULL) && (*item != NULL)) {
605 if ((item != NULL) && (*item != NULL)) {
606 cpl_parameter_delete(*item);
616 if ((item != NULL) && (*item != NULL)) {
617 cpl_parameterlist_delete(*item);
626 if ((item != NULL) && (*item != NULL)) {
627 cpl_table_delete(*item);
636 if ((item != NULL) && (*item != NULL)) {
646 if ((item != NULL) && (*item != NULL)) {
656 if ((item != NULL) && (*item != NULL)) {
666 if ((item != NULL) && (*item != NULL)) {
667 cpl_polynomial_delete(*item);
676 if ((item != NULL) && (*item != NULL)) {
677 cpl_bivector_delete(*item);
686 if ((item != NULL) && (*item != NULL)) {
687 cpl_apertures_delete(*item);
704 const cpl_propertylist *plist,
705 const cpl_parameterlist *parlist,
708 const char *filename,
710 const cpl_image *image)
712 cpl_error_code err = CPL_ERROR_NONE;
713 char *pckgName = NULL;
714 cpl_propertylist *plistdup = NULL;
716 cpl_ensure_code(fs, CPL_ERROR_NULL_INPUT);
717 cpl_ensure_code(plist, CPL_ERROR_NULL_INPUT);
718 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
719 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
720 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
721 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
722 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
726 plistdup = cpl_propertylist_duplicate(plist);
728 pckgName = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
730 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_CATG, procatg);
732 cpl_dfs_save_image(fs, NULL, parlist, fs, NULL, image, type,
733 recipe, plistdup,
"RADECSYS", pckgName, filename);
735 cpl_propertylist_delete(plistdup);
740 err = cpl_error_get_code();
762 const cpl_propertylist *plist,
763 const cpl_parameterlist *parlist,
766 const char *filename,
768 const cpl_imagelist *imglist)
770 cpl_error_code err = CPL_ERROR_NONE;
771 char *pckgName = NULL;
772 cpl_propertylist *plistdup = NULL;
774 cpl_ensure_code(fs, CPL_ERROR_NULL_INPUT);
775 cpl_ensure_code(plist, CPL_ERROR_NULL_INPUT);
776 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
777 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
778 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
779 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
780 cpl_ensure_code(imglist, CPL_ERROR_NULL_INPUT);
784 plistdup = cpl_propertylist_duplicate(plist);
785 pckgName = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
786 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_CATG, procatg);
788 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_TYPE,
"CUBE");
789 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_TECH,
"CUBE");
791 cpl_propertylist_erase(plistdup,
"RADECSYS");
795 cpl_dfs_save_imagelist(fs, NULL, parlist, fs, inherit, imglist, type,
796 recipe, plistdup,
"RADECSYS", pckgName, filename);
802 err = cpl_error_get_code();
806 cpl_propertylist_delete(plistdup);
825 const cpl_mask *mask)
827 cpl_error_code err = CPL_ERROR_NONE;
828 const cpl_binary *pmask = NULL;
829 cpl_mask *img_mask = NULL;
830 cpl_binary *pimg_mask = NULL;
834 cpl_ensure_code(img, CPL_ERROR_NULL_INPUT);
835 cpl_ensure_code(mask, CPL_ERROR_NULL_INPUT);
837 CPL_ERROR_ILLEGAL_INPUT);
839 CPL_ERROR_ILLEGAL_INPUT);
845 pimg_mask = cpl_mask_get_data(img_mask);
846 pmask = cpl_mask_get_data_const(mask);
850 for (cpl_size y = 0; y < nRows; y++) {
851 for (cpl_size x = 0; x < nCols; x++) {
852 if ((pmask[x+y*nCols] == BAD_PIX) &&
853 (pimg_mask[x+y*nCols] == GOOD_PIX))
855 pimg_mask[x+y*nCols] = BAD_PIX;
863 err = cpl_error_get_code();
877 const char* filename,
int create,
878 const cpl_propertylist *pl)
880 cpl_ensure_code(vec,CPL_ERROR_NULL_INPUT);
882 return cpl_vector_save(vec, filename, CPL_TYPE_DOUBLE, pl, create);
892 const char* filename,
int create)
909 const char* filename,
int col,
int create)
914 const cpl_vector *x = NULL,
918 x = cpl_bivector_get_x_const(bivec);
920 }
else if (col == 2) {
921 y = cpl_bivector_get_x_const(bivec);
923 }
else if (col == 0) {
924 x = cpl_bivector_get_x_const(bivec);
925 y = cpl_bivector_get_y_const(bivec);
929 return CPL_ERROR_ILLEGAL_INPUT;
941 const char* filename,
int create,
942 const cpl_propertylist *pl)
944 cpl_ensure_code(img,CPL_ERROR_NULL_INPUT);
947 return cpl_image_save(img, filename,
948 CPL_TYPE_INT, pl, create);
949 }
else if (cpl_image_get_type(img) == CPL_TYPE_FLOAT) {
950 return cpl_image_save(img, filename,
951 CPL_TYPE_FLOAT, pl, create);
952 }
else if (cpl_image_get_type(img) == CPL_TYPE_DOUBLE) {
953 return cpl_image_save(img, filename,
954 CPL_TYPE_DOUBLE, pl, create);
955 }
else if (cpl_image_get_type(img) == CPL_TYPE_INT) {
956 return cpl_image_save(img, filename,
957 CPL_TYPE_INT, pl, create);
959 return CPL_ERROR_ILLEGAL_INPUT;
970 const char* filename,
int create)
972 return cpl_table_save(tbl, NULL, NULL, filename, create);
983 const char* filename,
int create,
984 const cpl_propertylist *pl)
986 return cpl_mask_save(mask, filename, pl, create);
997 const char* filename,
int create)
999 cpl_ensure_code(imglist, CPL_ERROR_NULL_INPUT);
1000 cpl_ensure_code(cpl_imagelist_get_size(imglist) >= 0,
1001 CPL_ERROR_ILLEGAL_INPUT);
1003 const cpl_image *img = cpl_imagelist_get_const(imglist, 0);
1005 if (cpl_image_get_type(img) == CPL_TYPE_FLOAT) {
1006 return cpl_imagelist_save(imglist, filename,
1007 CPL_TYPE_FLOAT, NULL, create);
1008 }
else if (cpl_image_get_type(img) == CPL_TYPE_DOUBLE) {
1009 return cpl_imagelist_save(imglist, filename,
1010 CPL_TYPE_DOUBLE, NULL, create);
1012 return CPL_ERROR_ILLEGAL_INPUT;
1024 const char* name,
int singlefile,
1025 const cpl_propertylist *pl)
1028 const cpl_mask *mask = NULL;
1029 cpl_error_code err = CPL_ERROR_NONE;
1030 int create = CPL_IO_CREATE;
1035 fn = cpl_sprintf(
"%s.fits", name);
1037 fn = cpl_sprintf(
"%s_data.fits", name);
1040 cpl_free(fn); fn = NULL;
1043 fn = cpl_sprintf(
"%s.fits", name);
1044 create = CPL_IO_EXTEND;
1046 fn = cpl_sprintf(
"%s_mask.fits", name);
1047 create = CPL_IO_CREATE;
1049 mask = cpl_image_get_bpm_const(img);
1051 cpl_free(fn); fn = NULL;
1056 err = cpl_error_get_code();
1058 cpl_free(fn); fn = NULL;
1072 cpl_error_code err = CPL_ERROR_NONE;
1076 fn = cpl_sprintf(
"%s.fits", name);
1083 err = cpl_error_get_code();
1097 const char* filename,
int singlefile,
1098 const cpl_propertylist *pl)
1101 const cpl_image *img = NULL;
1102 const cpl_mask *mask = NULL;
1103 cpl_error_code err = CPL_ERROR_NONE;
1104 int create = CPL_IO_CREATE;
1109 fn = cpl_sprintf(
"%s.fits", filename);
1111 fn = cpl_sprintf(
"%s_data.fits", filename);
1115 cpl_free(fn); fn = NULL;
1118 fn = cpl_sprintf(
"%s.fits", filename);
1119 create = CPL_IO_EXTEND;
1121 fn = cpl_sprintf(
"%s_err.fits", filename);
1122 create = CPL_IO_CREATE;
1126 cpl_free(fn); fn = NULL;
1129 fn = cpl_sprintf(
"%s.fits", filename);
1130 create = CPL_IO_EXTEND;
1132 fn = cpl_sprintf(
"%s_mask.fits", filename);
1133 create = CPL_IO_CREATE;
1139 cpl_free(fn); fn = NULL;
1144 err = cpl_error_get_code();
1157 const hdrl_imagelist *hdrl_img_list,
1158 const char* filename,
int singlefile)
1161 cpl_imagelist *img_list = NULL;
1162 const hdrl_image *tmp_hdrl_img = NULL;
1163 const cpl_mask *mask = NULL;
1164 const cpl_binary *pmask = NULL;
1165 cpl_image *img = NULL;
1166 cpl_error_code err = CPL_ERROR_NONE;
1170 create = CPL_IO_CREATE;
1176 fn = cpl_sprintf(
"%s.fits", filename);
1178 fn = cpl_sprintf(
"%s_data.fits", filename);
1184 cpl_free(fn); fn = NULL;
1188 fn = cpl_sprintf(
"%s.fits", filename);
1189 create = CPL_IO_EXTEND;
1191 fn = cpl_sprintf(
"%s_err.fits", filename);
1192 create = CPL_IO_CREATE;
1198 cpl_free(fn); fn = NULL;
1202 fn = cpl_sprintf(
"%s.fits", filename);
1203 create = CPL_IO_EXTEND;
1205 fn = cpl_sprintf(
"%s_mask.fits", filename);
1206 create = CPL_IO_CREATE;
1208 img_list = cpl_imagelist_new();
1214 nx = cpl_mask_get_size_x(mask);
1215 ny = cpl_mask_get_size_y(mask);
1217 img = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
1218 pimg = cpl_image_get_data_float(img);
1219 pmask = cpl_mask_get_data_const(mask);
1221 for (
int j = 0; j < nx*ny; j++) {
1222 if (pmask[j] == BAD_PIX) {
1229 cpl_imagelist_set(img_list, img, i);
1233 cpl_free(fn); fn = NULL;
1238 err = cpl_error_get_code();
1297 const cpl_frameset *frameset,
1298 const char *category,
1301 const cpl_frame *frame = NULL;
1302 cpl_mask *bp_mask = NULL;
1304 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
1305 cpl_ensure(category, CPL_ERROR_NULL_INPUT, NULL);
1310 CPL_ERROR_ILLEGAL_INPUT,
1311 "ext must be 0 or larger!");
1313 frame = cpl_frameset_find_const(frameset, category);
1316 if (frame != NULL) {
1317 bp_mask = cpl_mask_load(cpl_frame_get_filename(frame), 0, ext);
1413cpl_error_code eris_ifu_file_exists(
const char *filename)
1415 cpl_error_code err = CPL_ERROR_NONE;
1418 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
1422 fh = fopen(filename,
"r");
1426 err = cpl_error_get_code();
1445 cpl_imagelist *data = NULL;
1446 const hdrl_image *tmp_hdrl_img = NULL;
1447 cpl_image *tmp_img = NULL;
1449 cpl_ensure(hdrl_imglist, CPL_ERROR_NULL_INPUT, NULL);
1453 data = cpl_imagelist_new();
1458 if (type == eris_hdrl_data) {
1460 tmp_img = cpl_image_duplicate(
1462 }
else if (type == eris_hdrl_error) {
1464 tmp_img = cpl_image_duplicate(
1474 cpl_imagelist_set(data, tmp_img, i);
1494 const char *arLampString =
"";
1495 const char *krLampString =
"";
1496 const char *neLampString =
"";
1497 const char *xeLampString =
"";
1499 if ((lampStatus & AR_LAMP) == AR_LAMP) {arLampString =
"Ar";}
1500 if ((lampStatus & KR_LAMP) == KR_LAMP) {krLampString =
"Kr";}
1501 if ((lampStatus & NE_LAMP) == NE_LAMP) {neLampString =
"Ne";}
1502 if ((lampStatus & XE_LAMP) == XE_LAMP) {xeLampString =
"Xe";}
1503 lampString = cpl_sprintf(
"%s%s%s%s",
1504 arLampString, krLampString, neLampString, xeLampString);
1516 const char *bandString;
1518 case UNDEFINED_BAND:
1522 bandString =
"J_LOW";
1525 bandString =
"H_LOW";
1528 bandString =
"K_LOW";
1531 bandString =
"J_SHORT";
1534 bandString =
"J_MIDDLE";
1537 bandString =
"J_LONG";
1540 bandString =
"H_SHORT";
1543 bandString =
"H_MIDDLE";
1546 bandString =
"H_LONG";
1549 bandString =
"K_SHORT";
1552 bandString =
"K_MIDDLE";
1555 bandString =
"K_LONG";
1558 bandString =
"J_SPIFFI";
1561 bandString =
"H_SPIFFI";
1564 bandString =
"K_SPIFFI";
1567 bandString =
"HK_SPIFFI";
1570 bandString =
"Unknown";
1585 case UNDEFINED_BAND: resolution = 0;
break;
1586 case J_LOW: resolution = 5000;
break;
1587 case H_LOW: resolution = 5200;
break;
1588 case K_LOW: resolution = 5600;
break;
1589 case J_SHORT: resolution = 10000;
break;
1590 case J_MIDDLE: resolution = 10000;
break;
1591 case J_LONG: resolution = 10000;
break;
1592 case H_SHORT: resolution = 10400;
break;
1593 case H_MIDDLE: resolution = 10400;
break;
1594 case H_LONG: resolution = 10400;
break;
1595 case K_SHORT: resolution = 11200;
break;
1596 case K_MIDDLE: resolution = 11200;
break;
1597 case K_LONG: resolution = 11200;
break;
1598 case J_SPIFFI: resolution = 5000;
break;
1599 case H_SPIFFI: resolution = 5000;
break;
1600 case K_SPIFFI: resolution = 5000;
break;
1601 case HK_SPIFFI: resolution = 3000;
break;
1602 default: resolution = 0;
break;
1620 cpl_ensure_code(zmin >= 0, CPL_ERROR_ILLEGAL_INPUT);
1621 cpl_ensure_code(zmin <= zmax, CPL_ERROR_ILLEGAL_INPUT);
1622 cpl_ensure_code(zmin != NULL, CPL_ERROR_NULL_INPUT);
1623 cpl_ensure_code(zmax != NULL, CPL_ERROR_NULL_INPUT);
1626 case UNDEFINED_BAND:
break;
1627 case J_LOW: *zmin = 46; *zmax = 2015;
break;
1628 case H_LOW: *zmin = 48; *zmax = 2023;
break;
1629 case K_LOW: *zmin = 62; *zmax = 2022;
break;
1630 case J_SHORT: *zmin = 50; *zmax = 2034;
break;
1631 case J_MIDDLE: *zmin = 57; *zmax = 2040;
break;
1632 case J_LONG: *zmin = 48; *zmax = 2033;
break;
1633 case H_SHORT: *zmin = 52; *zmax = 2034;
break;
1634 case H_MIDDLE: *zmin = 47; *zmax = 2034;
break;
1635 case H_LONG: *zmin = 56; *zmax = 2042;
break;
1636 case K_SHORT: *zmin = 54; *zmax = 2036;
break;
1637 case K_MIDDLE: *zmin = 49; *zmax = 2029;
break;
1638 case K_LONG: *zmin = 50; *zmax = 2034;
break;
1639 case J_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1640 case H_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1641 case K_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1642 case HK_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1646 return cpl_error_get_code();
1666 cpl_msg_info(cpl_func,
"org size: %lld", size);
1667 hdrl_image* hima = NULL;
1669 hdrl_value hvalue = {0, 0};
1670 for(cpl_size k = 0; k < size; k++) {
1672 for(cpl_size j = 10; j < 20; j++) {
1673 for(cpl_size i = 10; i < 20; i++) {
1674 hvalue.data = k * 10.;
1685 return cpl_error_get_code();
1699 hdrl_imagelist** iml, cpl_imagelist** bpm, cpl_propertylist* header) {
1701 cpl_ensure_code(iml,CPL_ERROR_NULL_INPUT);
1702 cpl_ensure_code(bpm,CPL_ERROR_NULL_INPUT);
1703 cpl_ensure_code(header,CPL_ERROR_NULL_INPUT);
1704 cpl_ensure_code(zmin <= zmax,CPL_ERROR_ILLEGAL_INPUT);
1706 cpl_msg_debug(cpl_func,
"org size: %lld", size);
1710 for(cpl_size i = size-1; i > zmax; i--) {
1712 cpl_imagelist_unset(*bpm, i);
1718 for(cpl_size i = 0; i < zmin; i++) {
1720 cpl_imagelist_unset(*bpm, 0);
1723 double crval3 = cpl_propertylist_get_double(header,
"CRVAL3");
1724 const double cd3_3 = cpl_propertylist_get_double(header,
"CD3_3");
1725 int naxis3 = cpl_propertylist_get_int(header,
"NAXIS3");
1727 crval3 += cd3_3 * zmin;
1728 naxis3 = zmax - zmin +1;
1729 cpl_propertylist_set_double(header,
"CRVAL3", crval3);
1730 cpl_propertylist_set_int(header,
"NAXIS3", naxis3);
1733 return cpl_error_get_code();
1744 const char *instrumentString;
1745 switch (instrument) {
1746 case OTHER_INSTRUMENT: instrumentString =
"unknown instrument";
break;
1747 case SPIFFI: instrumentString =
"SPIFFI";
break;
1748 case SPIFFIER: instrumentString =
"SPIFFIER";
break;
1749 case NIX: instrumentString =
"NIX";
break;
1750 case UNSET_INSTRUMENT: instrumentString =
"unset instrument";
break;
1751 default: instrumentString =
"unset instrument";
break;
1754 return instrumentString;
1764 const char *scaleString;
1766 case UNDEFINED_SCALE:
1770 scaleString =
"250mas";
1773 scaleString =
"100mas";
1776 scaleString =
"25mas";
1779 scaleString =
"PUPIL";
1782 scaleString =
"Unknown";
1794cpl_image* eris_ifu_image_create_window(
const cpl_image* img)
1798 double *pimg_window = NULL;
1799 const double *pimg = NULL;
1800 cpl_image *img_window = NULL;
1801 const cpl_mask *mask = NULL;
1802 cpl_mask *mask_window = NULL;
1803 const cpl_binary *pmask = NULL;
1804 cpl_binary *pmask_window = NULL;
1806 cpl_ensure(img, CPL_ERROR_NULL_INPUT, NULL);
1810 nx = cpl_image_get_size_x(img);
1811 ny = cpl_image_get_size_y(img);
1813 img_window = cpl_image_new(nx-2*ERIS_IFU_DETECTOR_BP_BORDER,
1814 ny-2*ERIS_IFU_DETECTOR_BP_BORDER,
1815 cpl_image_get_type(img));
1817 pimg = cpl_image_get_data_const(img);
1818 mask = cpl_image_get_bpm_const(img);
1819 pmask = cpl_mask_get_data_const(mask);
1820 pimg_window = cpl_image_get_data(img_window);
1821 mask_window = cpl_image_get_bpm(img_window);
1822 pmask_window = cpl_mask_get_data(mask_window);
1824 for (
int x = 0; x < nx-2*ERIS_IFU_DETECTOR_BP_BORDER; x++) {
1825 for (
int y = 0; y < ny-2*ERIS_IFU_DETECTOR_BP_BORDER; y++) {
1826 cpl_size nx_new = nx-2*ERIS_IFU_DETECTOR_BP_BORDER,
1827 x_old = x+ERIS_IFU_DETECTOR_BP_BORDER,
1828 y_old = y+ERIS_IFU_DETECTOR_BP_BORDER;
1829 pimg_window[x+y*nx_new] = pimg[x_old+y_old*nx];
1830 pmask_window[x+y*nx_new] = pmask[x_old+y_old*nx];
1854 cpl_binary *pmask_border = NULL;
1855 const cpl_binary *pmask = NULL;
1856 cpl_mask *mask_border = NULL;
1858 cpl_ensure(mask, CPL_ERROR_NULL_INPUT, NULL);
1862 nx = cpl_mask_get_size_x(mask);
1863 ny = cpl_mask_get_size_y(mask);
1866 mask_border = cpl_mask_new(nx+2*ERIS_IFU_DETECTOR_BP_BORDER,
1867 ny+2*ERIS_IFU_DETECTOR_BP_BORDER);
1869 pmask = cpl_mask_get_data_const(mask);
1870 pmask_border = cpl_mask_get_data(mask_border);
1872 for (
int x = 0; x < nx; x++) {
1873 for (
int y = 0; y < ny; y++) {
1874 cpl_size x_new = x+ERIS_IFU_DETECTOR_BP_BORDER,
1875 y_new = y+ERIS_IFU_DETECTOR_BP_BORDER,
1876 nx_new = nx+2*ERIS_IFU_DETECTOR_BP_BORDER;
1877 pmask_border[x_new+y_new*nx_new] = pmask[x+y*nx];
1901 double* pdata = NULL;
1902 double* perrs = NULL;
1903 cpl_binary* pbpm = NULL;
1906 cpl_size npoints = 0;
1907 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
1918 cpl_size nan_pix = 0;
1919 for(cpl_size i = 0; i < npoints; i++) {
1922 if(isnan(pdata[i]) || isnan(perrs[i]) ){
1930 return cpl_error_get_code();
1943 cpl_error_code retVal = CPL_ERROR_NONE;
1948 cpl_image *tmpImg = NULL;
1949 cpl_mask *mask = NULL;
1950 cpl_binary *maskData = NULL;
1951 const double *imgDataD = NULL;
1952 const float *imgDataF = NULL;
1953 cpl_type imgType = CPL_TYPE_INVALID;
1955 cpl_ensure(cube, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
1959 nz = cpl_imagelist_get_size(cube);
1961 tmpImg = cpl_imagelist_get(cube,0);
1962 imgType = cpl_image_get_type(tmpImg);
1963 if (! (imgType == CPL_TYPE_FLOAT || imgType == CPL_TYPE_DOUBLE)) {
1965 "unsupported image type within cube");
1967 nx = cpl_image_get_size_x(tmpImg);
1968 ny = cpl_image_get_size_y(tmpImg);
1971 for (cpl_size z=0; z < nz; z++) {
1972 tmpImg = cpl_imagelist_get(cube,z);
1974 case CPL_TYPE_FLOAT:
1975 imgDataF = cpl_image_get_data_float_const(tmpImg);
1977 case CPL_TYPE_DOUBLE:
1978 imgDataD = cpl_image_get_data_double_const(tmpImg);
1982 mask = cpl_image_get_bpm(tmpImg);
1983 maskData = cpl_mask_get_data(mask);
1984 for (cpl_size y=0; y < ny; y++) {
1985 for (cpl_size x=0; x < nx; x++) {
1988 case CPL_TYPE_FLOAT:
1989 if (!isfinite(imgDataF[idx])) {
1990 maskData[idx] = BAD_PIX;
1993 case CPL_TYPE_DOUBLE:
1994 if (!isfinite(imgDataD[idx])) {
1995 maskData[idx] = BAD_PIX;
2007 retVal = cpl_error_get_code();
2056 deqQualityType qualityType)
2058 cpl_mask *bpmMask = NULL;
2061 ASSURE((qualityMask != NULL), CPL_ERROR_NULL_INPUT, NULL);
2062 bpmMask = cpl_mask_threshold_image_create(
2063 qualityMask, .5, 4294967296.5 );
2064 switch(qualityType) {
2066 cpl_mask_not(bpmMask);
2075 cpl_mask_delete(bpmMask);
2077 "Unspecified DEQ quality type");
2082 "Unknown DEQ quality type");
2104 cpl_imagelist *maskOneCube = NULL;
2105 cpl_image *img = NULL;
2106 cpl_image *maskOneImg = NULL;
2107 int *maskOneImgPtr = NULL;
2108 float *floatPtr = NULL;
2109 double *doublePtr = NULL;
2110 float floatThreshold;
2111 cpl_size imgPixelCnt = 0,
2118 ASSURE(bpmCube != NULL, CPL_ERROR_NULL_INPUT,
"bpmCube must not be NULL");
2120 maskOneCube = cpl_imagelist_new();
2122 img = cpl_imagelist_get(bpmCube, 0);
2123 bpmType = cpl_image_get_type(img);
2124 ASSURE(bpmType == CPL_TYPE_FLOAT || bpmType == CPL_TYPE_DOUBLE,
2125 CPL_ERROR_ILLEGAL_INPUT,
"bpmCube must be of type float or double");
2127 nx = cpl_image_get_size_x(img);
2128 ny = cpl_image_get_size_y(img);
2129 imgPixelCnt = nx * ny;
2131 floatThreshold = (float) threshold;
2133 for (cpl_size cx=0; cx < cpl_imagelist_get_size(bpmCube); cx++) {
2134 img = cpl_imagelist_get(bpmCube, cx);
2136 maskOneImg = cpl_image_new(nx, ny, CPL_TYPE_INT);
2137 maskOneImgPtr = cpl_image_get_data_int(maskOneImg);
2139 if (bpmType == CPL_TYPE_FLOAT) {
2140 floatPtr = cpl_image_get_data_float(img);
2141 for (cpl_size px=0; px < imgPixelCnt; px++) {
2142 if (floatPtr[px] > floatThreshold) {
2143 maskOneImgPtr[px] = 1;
2145 maskOneImgPtr[px] = 0;
2148 }
else if (bpmType == CPL_TYPE_DOUBLE) {
2149 doublePtr = cpl_image_get_data_double(img);
2150 for (cpl_size px=0; px < imgPixelCnt; px++) {
2151 if (doublePtr[px] > threshold) {
2152 maskOneImgPtr[px] = 1;
2154 maskOneImgPtr[px] = 0;
2160 cpl_imagelist_set(maskOneCube, maskOneImg, cx);
2182 cpl_imagelist *dataCube,
2183 cpl_imagelist *errorCube)
2185 cpl_error_code retVal = CPL_ERROR_NONE;
2186 hdrl_image *image = NULL;
2190 cpl_ensure(cube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2191 cpl_ensure(dataCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2192 cpl_ensure(errorCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2220 cpl_imagelist *dataCube,
2221 cpl_imagelist *errorCube,
2222 cpl_imagelist *qualCube)
2224 cpl_error_code retVal = CPL_ERROR_NONE;
2225 hdrl_image *image = NULL;
2228 cpl_ensure(cube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2229 cpl_ensure(dataCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2230 cpl_ensure(errorCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2231 cpl_ensure(qualCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2235 cpl_imagelist_set(dataCube,
2237 cpl_imagelist_set(errorCube,
2239 cpl_imagelist_set(qualCube,
2264 table = cpl_table_new(0);
2265 cpl_table_new_column(table,
"key_name", CPL_TYPE_STRING);
2266 cpl_table_new_column(table,
"key_type", CPL_TYPE_STRING);
2267 cpl_table_new_column(table,
"key_value", CPL_TYPE_STRING);
2268 cpl_table_new_column(table,
"key_help", CPL_TYPE_STRING);
2286 const char* key_name,
2288 const char* key_help)
2291 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2292 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2293 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2295 int sz = cpl_table_get_nrow(table);
2300 key_value = cpl_sprintf(
"%d",value);
2301 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_INT");
2303 cpl_table_set_size(table,sz+1);
2305 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2306 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2307 cpl_table_set_string(table,
"key_value",raw,key_value);
2308 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2310 cpl_free(key_value);
2313 return cpl_error_get_code();
2331 const char* key_name,
2332 const char* key_help)
2334 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2335 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2336 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2338 int sz = cpl_table_get_nrow(table);
2343 key_value = cpl_sprintf(
"%s",key_name);
2344 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_BOOL");
2346 cpl_table_set_size(table,sz+1);
2348 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2349 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2350 cpl_table_set_string(table,
"key_value",raw,key_value);
2351 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2352 cpl_free(key_value);
2355 return cpl_error_get_code();
2373 const char* key_name,
2375 const char* key_help)
2377 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2378 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2379 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2381 int sz = cpl_table_get_nrow(table);
2387 key_value = cpl_sprintf(
"%g",value);
2389 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2391 cpl_table_set_size(table,sz+1);
2393 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2394 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2395 cpl_table_set_string(table,
"key_value",raw,key_value);
2396 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2398 cpl_free(key_value);
2401 return cpl_error_get_code();
2418 const char* key_name,
2420 const char* key_help)
2423 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2424 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2425 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2427 int sz = cpl_table_get_nrow(table);
2432 key_value = cpl_sprintf(
"%f",value);
2433 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2435 cpl_table_set_size(table,sz+1);
2437 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2438 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2439 cpl_table_set_string(table,
"key_value",raw,key_value);
2440 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2441 cpl_free(key_value);
2444 return cpl_error_get_code();
2461 const char* key_name,
2463 const char* key_help)
2466 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2467 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2468 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2470 int sz = cpl_table_get_nrow(table);
2475 key_value = cpl_sprintf(
"%13.6f",value);
2476 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2478 cpl_table_set_size(table,sz+1);
2480 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2481 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2482 cpl_table_set_string(table,
"key_value",raw,key_value);
2483 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2484 cpl_free(key_value);
2487 return cpl_error_get_code();
2504 const char* key_name,
2506 const char* key_help)
2509 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2510 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2511 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2513 int sz = cpl_table_get_nrow(table);
2518 key_value = cpl_sprintf(
"%s",value);
2519 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_STRING");
2521 cpl_table_set_size(table,sz+1);
2523 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2524 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2525 cpl_table_set_string(table,
"key_value",raw,key_value);
2526 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2527 cpl_free(key_value);
2530 return cpl_error_get_code();
2546 cpl_propertylist * plist,
2551 cpl_ensure_code(plist != NULL, CPL_ERROR_NULL_INPUT);
2552 cpl_ensure_code(qclog != NULL, CPL_ERROR_NULL_INPUT);
2553 char* key_name = NULL;
2554 char* key_value = NULL;
2555 char* key_type = NULL;
2556 char* key_help = NULL;
2567 if (plist == NULL) {
2568 cpl_msg_error(cpl_func,
"plist=NULL, something strange");
2569 return CPL_ERROR_NULL_INPUT ;
2574 n = cpl_table_get_nrow(qclog);
2575 for(i = 0; i < n; i++) {
2577 key_name = cpl_sprintf(
"ESO %s",cpl_table_get_string(qclog,
"key_name", i));
2579 key_type = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_type", i));
2581 key_value = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_value", i));
2583 key_help = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_help", i));
2589 if( !cpl_propertylist_has(plist, key_name) ) {
2590 if(strcmp(key_type,
"CPL_TYPE_STRING") == 0) {
2591 cpl_propertylist_append_string(plist, key_name, key_value) ;
2592 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2593 }
else if(strcmp(key_type,
"CPL_TYPE_BOOL") == 0) {
2594 cpl_propertylist_append_bool(plist, key_name, atoi(key_value)) ;
2595 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2596 }
else if(strcmp(key_type,
"CPL_TYPE_INT") == 0) {
2597 cpl_propertylist_append_int(plist, key_name, atoi(key_value)) ;
2598 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2599 }
else if(strcmp(key_type,
"CPL_TYPE_FLOAT") == 0) {
2600 cpl_propertylist_append_float(plist, key_name, (
float) atof(key_value)) ;
2601 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2602 }
else if(strcmp(key_type,
"CPL_TYPE_DOUBLE") == 0) {
2603 cpl_propertylist_append_double(plist, key_name, atof(key_value)) ;
2604 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2609 cpl_free(key_value);
2614 return cpl_error_get_code();
2629 cpl_propertylist* qc_list,
2633 cpl_ensure_code(image != NULL, CPL_ERROR_NULL_INPUT);
2634 cpl_ensure_code(qc_list != NULL, CPL_ERROR_NULL_INPUT);
2635 cpl_ensure_code(prefix != NULL, CPL_ERROR_NULL_INPUT);
2636 cpl_size sx = cpl_image_get_size_x(image);
2637 cpl_size sy = cpl_image_get_size_y(image);
2638 cpl_image* ima = cpl_image_duplicate(image);
2639 cpl_image_threshold(ima, 0, 0, 0, 1);
2640 double flux = cpl_image_get_flux(ima);
2641 cpl_image_delete(ima);
2642 cpl_size nBadPix = (cpl_size) flux;
2644 cpl_size npix = sx * sy;
2645 double fracBadPix = flux / npix;
2647 cpl_msg_warning(cpl_func,
"nBadPix: %lld",nBadPix);
2648 kname = cpl_sprintf(
"%s NBADPIX",prefix);
2649 cpl_msg_info(cpl_func,
"kname: %s prefix: %s",kname, prefix);
2653 kname = cpl_sprintf(
"%s BPIXFRAC",prefix);
2655 "Fraction of bad pixels to total");
2658 return cpl_error_get_code();
2674 cpl_propertylist* qc_list,
2677 cpl_ensure_code(bp_mask != NULL, CPL_ERROR_NULL_INPUT);
2678 cpl_ensure_code(qc_list != NULL, CPL_ERROR_NULL_INPUT);
2679 cpl_ensure_code(prefix != NULL, CPL_ERROR_NULL_INPUT);
2680 cpl_size sx = cpl_mask_get_size_x(bp_mask);
2681 cpl_size sy = cpl_mask_get_size_y(bp_mask);
2682 cpl_size nBadPix = cpl_mask_count(bp_mask);
2684 cpl_size npix = sx * sy;
2685 double fracBadPix = (double) nBadPix / npix;
2688 kname = cpl_sprintf(
"%s NBADPIX",prefix);
2689 cpl_msg_info(cpl_func,
"kname: %s prefix: %s",kname, prefix);
2693 kname = cpl_sprintf(
"%s BPIXFRAC",prefix);
2695 "Fraction of bad pixels to total");
2698 return cpl_error_get_code();
2722static cpl_error_code eris_apertures_find_max_flux(
const cpl_apertures * self,
2723 int * ind,
int nfind)
2728 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2730 const int nsize = cpl_apertures_get_size(self);
2734 cpl_ensure_code(nsize > 0, CPL_ERROR_ILLEGAL_INPUT);
2735 cpl_ensure_code(ind, CPL_ERROR_NULL_INPUT);
2736 cpl_ensure_code(nfind > 0, CPL_ERROR_ILLEGAL_INPUT);
2737 cpl_ensure_code(nfind <= nsize, CPL_ERROR_ILLEGAL_INPUT);
2739 for (ifind=0; ifind < nfind; ifind++) {
2740 double maxflux = -1;
2743 for (i=1; i <= nsize; i++) {
2747 for (k=0; k < ifind; k++)
if (ind[k] == i)
break;
2751 const double flux = cpl_apertures_get_flux(self, i);
2753 if (maxind < 0 || flux > maxflux) {
2759 ind[ifind] = maxind;
2762 return CPL_ERROR_NONE;
2788eris_gaussian_maxpos(
const cpl_image * self,
2799 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2800 cpl_ensure(sigma > 0, CPL_ERROR_ILLEGAL_INPUT, CPL_ERROR_ILLEGAL_INPUT);
2804 const cpl_size nx = cpl_image_get_size_x(self);
2805 const cpl_size ny = cpl_image_get_size_y(self);
2809 const double median = cpl_image_get_median_dev(self, &med_dist);
2810 cpl_mask * selection = NULL;
2811 cpl_size nlabels = 0;
2812 cpl_image * labels = NULL;
2813 cpl_apertures * aperts;
2817 cpl_size xposmax, yposmax;
2818 double xposcen, yposcen;
2819 double valmax, valfit = -1.0;
2820 cpl_array * gauss_parameters = NULL;
2821 cpl_errorstate prestate = cpl_errorstate_get();
2822 cpl_error_code code = CPL_ERROR_NONE;
2825 cpl_ensure_code( sigma > 0.0, CPL_ERROR_ILLEGAL_INPUT);
2827 selection = cpl_mask_new(nx, ny);
2830 for (; iretry > 0 && nlabels == 0; iretry--, sigma *= 0.5) {
2833 const double threshold = median + sigma * med_dist;
2836 code = cpl_mask_threshold_image(selection, self, threshold, DBL_MAX,
2842 cpl_image_delete(labels);
2843 labels = cpl_image_labelise_mask_create(selection, &nlabels);
2847 cpl_mask_delete(selection);
2850 cpl_image_delete(labels);
2851 return cpl_error_set_where(cpl_func);
2852 }
else if (nlabels == 0) {
2853 cpl_image_delete(labels);
2854 return cpl_error_set(cpl_func, CPL_ERROR_DATA_NOT_FOUND);
2857 aperts = cpl_apertures_new_from_image(self, labels);
2860 code = eris_apertures_find_max_flux(aperts, &ifluxapert, 1);
2863 cpl_apertures_delete(aperts);
2864 cpl_image_delete(labels);
2865 return cpl_error_set(cpl_func, CPL_ERROR_DATA_NOT_FOUND);
2868 npixobj = cpl_apertures_get_npix(aperts, ifluxapert);
2869 objradius = sqrt((
double)npixobj * CPL_MATH_1_PI);
2870 winsize = CX_MIN(CX_MIN(nx, ny), (3.0 * objradius));
2872 xposmax = cpl_apertures_get_maxpos_x(aperts, ifluxapert);
2873 yposmax = cpl_apertures_get_maxpos_y(aperts, ifluxapert);
2874 xposcen = cpl_apertures_get_centroid_x(aperts, ifluxapert);
2875 yposcen = cpl_apertures_get_centroid_y(aperts, ifluxapert);
2876 valmax = cpl_apertures_get_max(aperts, ifluxapert);
2878 cpl_apertures_delete(aperts);
2879 cpl_image_delete(labels);
2881 cpl_msg_debug(cpl_func,
"Object radius at S/R=%g: %g (window-size=%u)",
2882 sigma, objradius, (
unsigned)winsize);
2883 cpl_msg_debug(cpl_func,
"Object-peak @ (%d, %d) = %g", (
int)xposmax,
2884 (
int)yposmax, valmax);
2888 gauss_parameters = cpl_array_new(7, CPL_TYPE_DOUBLE);
2889 cpl_array_set_double(gauss_parameters, 0, median);
2891 code = cpl_fit_image_gaussian(self, NULL, xposmax, yposmax,
2892 winsize, winsize, gauss_parameters,
2897 const double M_x = cpl_array_get_double(gauss_parameters, 3, NULL);
2898 const double M_y = cpl_array_get_double(gauss_parameters, 4, NULL);
2899 const double SIGMA_x = cpl_array_get_double(gauss_parameters, 5, NULL);
2900 const double SIGMA_y = cpl_array_get_double(gauss_parameters, 6, NULL);
2901 valfit = cpl_gaussian_eval_2d(gauss_parameters, M_x, M_y);
2902 if (!cpl_errorstate_is_equal(prestate)) {
2903 code = cpl_error_get_code();
2911 cpl_msg_debug(cpl_func,
"Gauss-fit @ (%g, %g) = %g, SIGMA: (%g, %g)",
2918 cpl_array_delete(gauss_parameters);
2920 if (code || valfit < valmax) {
2921 cpl_errorstate_set(prestate);
2927 return code ? cpl_error_set_where(cpl_func) : CPL_ERROR_NONE;
2942 const char* context){
2944 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
2945 cpl_ensure(parlist != NULL, CPL_ERROR_NULL_INPUT, NULL);
2946 cpl_ensure(context != NULL, CPL_ERROR_NULL_INPUT, NULL);
2962 cpl_propertylist* qchead = cpl_propertylist_new();
2963 eris_gaussian_maxpos(image, 5, &max_x, &max_y, &peak, &sigma_x, &sigma_y);
2964 FWHM_x = sigma_x * CPL_MATH_FWHM_SIG;
2965 FWHM_y = sigma_y * CPL_MATH_FWHM_SIG;
2966 cpl_msg_info(cpl_func,
"max_x: %g max_y: %g FWHM_x:%g FWHM_y: %g",
2967 max_x, max_y, FWHM_x, FWHM_y);
2969 if(cpl_error_get_code() != CPL_ERROR_NONE) {
2970 cpl_msg_error(cpl_func,
"Error fitting 2D Gaussian to object for QC. Exit");
2975 int max_ima_x = (int) (max_x + 0.5);
2976 int max_ima_y = (int) (max_y + 0.5);
2979 int wllx = ((max_ima_x - psf_sz)>0) ? (max_ima_x - psf_sz) : 1;
2980 int wlly = ((max_ima_y - psf_sz)>0) ? (max_ima_y - psf_sz) : 1;
2981 int wurx = ((max_ima_x + psf_sz)<ima_szx) ? (max_ima_x + psf_sz) : ima_szx ;
2982 int wury = ((max_ima_y + psf_sz)<ima_szy) ? (max_ima_y + psf_sz) : ima_szy ;
3004 double* pdata = cpl_image_get_data_double(image);
3005 cpl_size npix = cpl_image_get_size_x(image) * cpl_image_get_size_y(image);
3006 cpl_boolean has_nan = CPL_FALSE;
3007 for(cpl_size i =0; i < npix; i++ ) {
3014 cpl_bivector * biv = NULL;
3015 if(has_nan == CPL_FALSE) {
3016 cpl_image* fimage = cpl_image_cast(image, CPL_TYPE_FLOAT);
3018 biv = cpl_image_iqe(fimage, wllx, wlly, wurx, wury);
3019 cpl_image_delete(fimage);
3022 if( (cpl_error_get_code() == CPL_ERROR_NONE) && (has_nan == CPL_FALSE)) {
3023 const double * x = cpl_bivector_get_x_data_const(biv);
3025 "[pix] STD star X centroid position");
3027 "[pix] STD star Y centroid position");
3029 "[pix] STD star FWHM on major axis");
3031 "[pix] STD star FWHM on minor axis");
3033 "[deg] STD star ellipsis angle theta");
3034 cpl_bivector_delete(biv);
3037 "[pix] STD star X centroid position");
3039 "[pix] STD star Y centroid position");
3041 "[pix] STD star FWHM on major axis");
3043 "[pix] STD star FWHM on minor axis");
3048 double xcen = max_x;
3049 double ycen = max_y;
3050 if (has_nan == CPL_FALSE) {
3059 double fwhm_factor = 5.0;
3061 char* pname = cpl_sprintf(
"%s.fwhm-factor",context);
3065 double red_chisq = 0;
3066 cpl_matrix* covariance = NULL;
3070 cpl_array* fit_params = NULL;
3071 cpl_array* gauss2d_fit_params = cpl_array_new(7, CPL_TYPE_DOUBLE);
3072 cpl_array* gauss2d_err_params = cpl_array_new(7, CPL_TYPE_DOUBLE);
3073 cpl_matrix* phys_cov = NULL;
3076 if(CPL_ERROR_NONE == cpl_fit_image_gaussian(image, error,
3077 max_ima_x, max_ima_y, psf_sz, psf_sz, gauss2d_fit_params,
3078 gauss2d_err_params, fit_params, &rms, &red_chisq, &covariance,
3079 &major, &minor, &angle, &phys_cov) ) {
3080 sigma_x = cpl_array_get(gauss2d_fit_params, 5, &status);
3081 sigma_y = cpl_array_get(gauss2d_fit_params, 6, &status);
3083 fwhm_x = sigma_x * CPL_MATH_FWHM_SIG;
3084 fwhm_y = sigma_y * CPL_MATH_FWHM_SIG;
3086 "[pix] STD star FWHM on X");
3088 "[pix] STD star FWHM on Y");
3090 halfbox_x = (floor)(0.5 * (fwhm_x + fwhm_y) * fwhm_factor + 0.5);
3092 halfbox_y = (floor)(0.5 * (fwhm_x + fwhm_y) * fwhm_factor + 0.5);
3097 cpl_array_delete(gauss2d_fit_params);
3098 cpl_array_delete(gauss2d_err_params);
3105 "[pix] STD star FWHM on X");
3107 "[pix] STD star FWHM on Y");
3122 llx = (int)(xcen - halfbox_x);
3123 llx = (llx > 0 ) ? llx : 1;
3125 if((llx + 2 * halfbox_x) >= ima_szx) {
3126 halfbox_x = (int) ((ima_szx - llx - 1) / 2);
3130 lly = (int)(ycen - halfbox_y);
3131 lly = (lly > 0 ) ? lly : 1;
3132 if((lly + 2 * halfbox_y) >= ima_szy) {
3133 halfbox_y = (int) ((ima_szy - lly - 1) / 2);
3137 "Check on evaluation box");
3140 cpl_table_delete(qclog_tbl);
3146static cpl_error_code
3147eris_imagelist_reject_value(hdrl_imagelist* iml)
3150 cpl_ensure(iml != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3154 for(cpl_size i = 0; i < sz; i++) {
3158 return cpl_error_get_code();
3172 cpl_mask* mask_obj = NULL;
3178 cpl_image* ima_tmp = cpl_image_duplicate(image);
3181 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
3182 cpl_ensure(0.25 <= percent && percent <= 0.75, CPL_ERROR_ILLEGAL_INPUT, NULL);
3183 double* data = cpl_image_get_data(ima_tmp);
3185 cpl_size npoints = sx * sy;
3186 cpl_ensure(npoints > 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
3187 cpl_vector* v = cpl_vector_new(npoints);
3188 v = cpl_vector_wrap(npoints, data);
3190 cpl_vector_sort(v, CPL_SORT_ASCENDING);
3192 cpl_size thresh_pos = percent * npoints;
3193 double threshold_max = cpl_vector_get(v, thresh_pos);
3195 cpl_vector_unwrap(v);
3196 cpl_image_delete(ima_tmp);
3197 mask_obj = cpl_mask_threshold_image_create(image, DBL_MIN, threshold_max);
3198 cpl_mask_not(mask_obj);
3200 cpl_vector_delete(v);
3219 cpl_mask* mask_tmp = NULL;
3220 cpl_mask* mask_obj = NULL;
3221 hdrl_value median = {0, 0};
3225 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
3226 cpl_ensure(1 <= niter && niter <= 100, CPL_ERROR_ILLEGAL_INPUT, NULL);
3227 cpl_ensure(kappa > 0., CPL_ERROR_ILLEGAL_INPUT, NULL);
3231 for (cpl_size i = 0; i < niter; i++) {
3233 if (!isnan(median.data)) {
3235 double thresh_max = median.data + kappa * stdev;
3236 cpl_msg_info(cpl_func,
"median: %g stdev: %g thresh: %g max: %g",
3237 median.data, stdev, thresh_max, max);
3238 thresh_max = (thresh_max < max) ? thresh_max : 0.99 * max;
3239 cpl_msg_info(cpl_func,
"median: %g stdev: %g thresh: %g max: %g",
3240 median.data, stdev, thresh_max, max);
3245 mask_tmp = cpl_mask_threshold_image_create(ima_tmp, DBL_MIN, thresh_max);
3246 cpl_mask_not(mask_tmp);
3250 if (i == (niter -1)) {
3251 mask_obj = cpl_mask_duplicate(mask_tmp);
3253 cpl_mask_delete(mask_tmp);
3274 cpl_ensure(iml != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3275 cpl_ensure(qclog_tbl != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3276 cpl_ensure(*qclog_tbl != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3277 cpl_ensure(n >= 0, CPL_ERROR_ILLEGAL_INPUT, CPL_ERROR_ILLEGAL_INPUT);
3279 cpl_size max_ima_x = 0;
3280 cpl_size max_ima_y = 0;
3287 double max_ima_cx = 0;
3288 double max_ima_cy = 0;
3290 hdrl_image* himg = NULL;
3291 cpl_image* img_dup = NULL;
3292 cpl_image* contrib_map = NULL;
3295 eris_imagelist_reject_value(iml);
3303 cpl_image_get_maxpos(img_dup, &max_ima_x, &max_ima_y);
3304 max_ima_cx = cpl_image_get_centroid_x_window(img_dup, 1, 1, nx, ny);
3305 max_ima_cy = cpl_image_get_centroid_y_window(img_dup, 1, 1, nx, ny);
3309 xshift = max_ima_cx - (double)nx/2;
3310 yshift = max_ima_cy - (double)ny/2;
3312 key_name = cpl_sprintf(
"QC PUPIL%d SHIFTX", n);
3315 "X shift centroid - center image");
3317 key_name = cpl_sprintf(
"QC PUPIL%d SHIFTY", n);
3319 "Y shift centroid - center image");
3320 cpl_msg_info(cpl_func,
"xshift: %g yshift: %g",xshift, yshift);
3323 cpl_image_delete(contrib_map);
3325 return cpl_error_get_code();
3341 cpl_mask *mask = NULL;
3342 const double *pimg_mask = NULL;
3343 cpl_binary *pmask = NULL;
3345 cpl_ensure(img_mask != NULL, CPL_ERROR_NULL_INPUT, NULL);
3348 nx = cpl_image_get_size_x(img_mask);
3349 ny = cpl_image_get_size_y(img_mask);
3352 mask = cpl_mask_new(nx,ny));
3354 pimg_mask = cpl_image_get_data_double_const(img_mask));
3356 pmask = cpl_mask_get_data(mask));
3358 for (cpl_size x = 0; x < nx; x++) {
3359 for (cpl_size y = 0; y < ny; y++) {
3360 if (pimg_mask[x+nx*y] > 0.5) {
3362 pmask[x+nx*y] = GOOD_PIX;
3365 pmask[x+nx*y] = BAD_PIX;
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_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.
#define ASSURE(condition, error,...)
error handling macro (from fors-pipeline)
#define SET_ERROR_MSG(code, msg)
Set a new error code together with a custom error message.
#define CHECK_ERROR_STATE(void)
Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.
#define BRK_WITH_ERROR_MSG(code,...)
Set a new CPL error, and exit the try-block.
#define CATCH_MSG()
Displays an error message.
#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.
hdrl_image * eris_ifu_load_exposure_file(const char *filename, int exposureCorrectionMode, cpl_image *dqi)
Read a raw detector exposure, perform some correction, add noise data.
void eris_ifu_free_frameset(cpl_frameset **item)
free memory and set pointer to null
cpl_error_code eris_ifu_save_table_dbg(const cpl_table *tbl, const char *filename, int create)
eris_ifu_save_table_dbg
cpl_error_code eris_ifu_save_cpl_image_dbg(const cpl_image *img, const char *name, int singlefile, const cpl_propertylist *pl)
save CPL image for debug purposes
cpl_error_code eris_ifu_save_imagelist(cpl_frameset *fs, cpl_frame *inherit, const cpl_propertylist *plist, const cpl_parameterlist *parlist, const char *recipe, const char *procatg, const char *filename, cpl_type type, const cpl_imagelist *imglist)
save imagelist
cpl_error_code eris_ifu_save_imagelist_dbg(const cpl_imagelist *imglist, const char *filename, int create)
save CPL imagelist for debug purposes
void eris_ifu_free_propertylist(cpl_propertylist **item)
free memory and set pointer to null
cpl_vector * eris_ifu_idl_values_at_indices(const cpl_vector *data, const cpl_vector *indices)
Returns a vector of given indices.
void eris_ifu_free_apertures(cpl_apertures **item)
free memory and set pointer to null
void eris_ifu_free_string(char **item)
free memory and set pointer to null
char * eris_ifu_get_lampString(int lampStatus)
eris_ifu_get_lampString
cpl_error_code eris_ifu_parameterlist_append_list(cpl_parameterlist *p1, const cpl_parameterlist *p2)
Append a parameterlist to another one.
void eris_ifu_free_double_array(double **item)
free memory and set pointer to null
cpl_table * eris_qclog_init(void)
Initialize QC table.
void eris_ifu_free_vector(cpl_vector **item)
free memory and set pointer to null
cpl_error_code eris_ifu_save_vector_dbg(const cpl_vector *vec, const char *filename, int create, const cpl_propertylist *pl)
save vector
cpl_error_code eris_ifu_save_image_dbg(const cpl_image *img, const char *filename, int create, const cpl_propertylist *pl)
eris_ifu_save_image_dbg
void eris_ifu_free_table(cpl_table **item)
free memory and set pointer to null
cpl_error_code eris_ifu_save_ifu_vector_dbg(const eris_ifu_vector *vec, const char *filename, int create)
save vector
cpl_error_code eris_ifu_cut_endings(cpl_vector **vec, int *begin, int *end, int cut)
Cut leading and trailing -1 of a vector.
cpl_error_code eris_ifu_mask_nans_in_hdrlimage(hdrl_image **hima)
Flag NANs in image.
const char * eris_ifu_get_bandString(ifsBand band)
eris_ifu_get_bandString
void eris_ifu_free_ifu_vector(eris_ifu_vector **item)
free memory and set pointer to null
cpl_error_code eris_ifu_split_hdrl_imagelist(hdrl_imagelist *cube, cpl_imagelist *dataCube, cpl_imagelist *errorCube)
extract from hdrl_imagelist the data and error information
cpl_error_code eris_get_pupil_shift(hdrl_imagelist *iml, const int n, cpl_table **qclog_tbl)
Get what object shift.
cpl_mask * eris_ifu_load_badpixel_mask(const cpl_frameset *frameset, const char *category, int ext)
**
cpl_error_code eris_ifu_hdrl_image_reject_mask(hdrl_image *img, const cpl_mask *mask)
'Add' the mask to the image
cpl_error_code eris_ifu_get_plane_cut_min_max(ifsBand band, cpl_size *zmin, cpl_size *zmax)
eris_ifu_get_plane_cut_min_max
const char * eris_ifu_get_instrumentString(ifsInstrument instrument)
eris_ifu_get_instrumentString
cpl_error_code eris_pfits_put_qc(cpl_propertylist *plist, cpl_table *qclog)
convert table with QC parameter information to a propertylist
cpl_error_code eris_ifu_get_badpix_qc_from_ima(const cpl_image *image, cpl_propertylist *qc_list, const char *prefix)
compute QC keyword with number of bad pixels and fraction to total
void eris_ifu_free_polynomial(cpl_polynomial **item)
free memory and set pointer to null
hdrl_imagelist * eris_ifu_get_hdrlimagelist_by_tag(cpl_frameset *frameset, const char *tag, int exposureCorrectionMode)
Return HDRL imagelist by searching tagged frames in frameset.
void eris_ifu_free_parameter(cpl_parameter **item)
free memory and set pointer to null
cpl_propertylist * eris_compute_psf_qc(hdrl_image *hima, const cpl_parameterlist *parlist, const char *context)
compute QC parameters on a PSF STD image
cpl_error_code eris_ifu_save_bivector_dbg(const cpl_bivector *bivec, const char *filename, int col, int create)
save bivector as a vector (col=1 or col=2) or as a table
cpl_imagelist * eris_ifu_hdrl_get_imagelist(const hdrl_imagelist *hdrl_imglist, enum hdrl_t type)
Extract from a HDRL-imglist a specific CPL-imglist.
cpl_mask * eris_ifu_hima_get_obj_mask_percent(hdrl_image *hima, const double percent)
find mask flagging pixels above percent(%) pixels with lower intensity
cpl_mask * eris_ifu_mask_create_border(const cpl_mask *mask)
eris_ifu_mask_create_border
cpl_error_code eris_qclog_add_double_f(cpl_table *table, const char *key_name, const double value, const char *key_help)
add QC float info to table
void eris_ifu_free_int_array(int **item)
free memory and set pointer to null
cpl_error_code eris_qclog_add_string(cpl_table *table, const char *key_name, const char *value, const char *key_help)
add QC string info to table
cpl_error_code eris_qclog_add_double(cpl_table *table, const char *key_name, const double value, const char *key_help)
add QC double info to table
cpl_error_code eris_ifu_save_mask_dbg(const cpl_mask *mask, const char *filename, int create, const cpl_propertylist *pl)
eris_ifu_save_mask_dbg
void eris_ifu_free_imagelist(cpl_imagelist **item)
free memory and set pointer to null
cpl_vector * eris_ifu_idl_where(const cpl_vector *data, double val, int op)
Implements the where-function knownm from IDL.
cpl_mask * eris_ifu_quality2bp_mask(const cpl_image *qualityMask, deqQualityType qualityType)
transform input image (quality mask) to output mask with given bit code
cpl_error_code eris_ifu_cube_set_values(hdrl_imagelist **iml)
remove planes from input iml and bpm in the range [0, zmin), (zmax,sz]
void eris_ifu_free_frame(cpl_frame **item)
free memory and set pointer to null
cpl_error_code eris_qclog_add_bool(cpl_table *table, const char *key_name, const char *key_help)
add QC boolean info to table
cpl_error_code eris_ifu_mask_nans_in_cube(cpl_imagelist *cube)
mask NANs in input data cube
void eris_ifu_free_hdrl_imagelist(hdrl_imagelist **item)
free memory and set pointer to null
cpl_error_code eris_qclog_add_int(cpl_table *table, const char *key_name, const int value, const char *key_help)
add QC int info to table
cpl_error_code eris_ifu_save_hdrl_imagelist_dbg(const hdrl_imagelist *hdrl_img_list, const char *filename, int singlefile)
eris_ifu_save_hdrl_imagelist_dbg
cpl_error_code eris_ifu_save_cpl_imagelist_dbg(const cpl_imagelist *imglist, const char *name)
save CPL imagelist for debugging purposes
cpl_error_code eris_ifu_save_hdrl_image_dbg(const hdrl_image *hdrl_img, const char *filename, int singlefile, const cpl_propertylist *pl)
save HDRL imagelist for debugging purposes
cpl_mask * eris_ifu_mask_from_image(const cpl_image *img_mask)
eris_ifu_mask_from_image
void eris_ifu_free_float_array(float **item)
free memory and set pointer to null
void eris_ifu_free_hdrl_image(hdrl_image **item)
free memory and set pointer to null
cpl_error_code eris_ifu_cube_trim_nans(const cpl_size zmin, const cpl_size zmax, hdrl_imagelist **iml, cpl_imagelist **bpm, cpl_propertylist *header)
remove planes from input iml and bpm in the range [0, zmin), (zmax,sz]
cpl_imagelist * eris_ifu_interpolatedMask_to_maskZero(cpl_imagelist *bpmCube, double threshold)
return cube flagging (as 1) pixels above a given threshold
cpl_error_code eris_ifu_get_badpix_qc_from_mask(const cpl_mask *bp_mask, cpl_propertylist *qc_list, const char *prefix)
compute QC keyword with number of bad pixels and fraction to total
void eris_ifu_free_image(cpl_image **item)
free memory and set pointer to null
cpl_error_code eris_qclog_add_double_format(cpl_table *table, const char *key_name, const double value, const char *key_help)
add QC double (with format) info to table
void eris_ifu_free_matrix(cpl_matrix **item)
free memory and set pointer to null
void eris_ifu_free_mask(cpl_mask **item)
free memory and set pointer to null
cpl_frameset * eris_ifu_get_frameset_by_tag(const cpl_frameset *frameset, const char *tag)
Get frames with given tag from frameset.
const char * eris_ifu_get_preopticsScaleString(ifsPreopticsScale scale)
eris_ifu_get_preopticsScaleString
void eris_ifu_free_parameterlist(cpl_parameterlist **item)
free memory and set pointer to null
cpl_error_code eris_ifu_split3_hdrl_imagelist(hdrl_imagelist *cube, cpl_imagelist *dataCube, cpl_imagelist *errorCube, cpl_imagelist *qualCube)
extract from hdrl_imagelist the data and error information
cpl_error_code eris_ifu_save_image(cpl_frameset *fs, const cpl_propertylist *plist, const cpl_parameterlist *parlist, const char *recipe, const char *procatg, const char *filename, cpl_type type, const cpl_image *image)
save image
double eris_ifu_get_band_resolution(ifsBand band)
eris_ifu_get_band_resolution
void eris_ifu_free_bivector(cpl_bivector **item)
free memory and set pointer to null
void eris_ifu_free_hdrl_parameter(hdrl_parameter **item)
free memory and set pointer to null
cpl_mask * eris_ifu_hima_get_obj_mask(hdrl_image *hima, const cpl_size niter, const double kappa)
find mask flagging pixels above a threshold set by ks-clip algorithm
int eris_ifu_is_nan_or_inf(double A)
Checks if a value is nan, inf or -inf.
cpl_error_code eris_ifu_vector_save(const eris_ifu_vector *ev, const char *filename, cpl_type_bpp bpp, const cpl_propertylist *pl, unsigned mode, double rej_val)
Override for cpl_vector_save().
void eris_ifu_vector_delete(eris_ifu_vector *ev)
Delete a eris_ifu_vector.
cpl_error_code eris_parameters_get_double(const cpl_parameterlist *parlist, const char *pname, double *pvalue)
get double parameter value if changed by the user
cpl_error_code eris_check_error_code(const char *func_id)
handle CPL errors
cpl_error_code hdrl_image_set_pixel(hdrl_image *self, cpl_size xpos, cpl_size ypos, hdrl_value value)
set pixel values of hdrl_image
cpl_error_code hdrl_image_reject_value(hdrl_image *self, cpl_value mode)
Reject pixels with the specified special value(s)
cpl_error_code hdrl_image_reject_from_mask(hdrl_image *self, const cpl_mask *map)
set bpm of hdrl_image
hdrl_value hdrl_image_get_median(const hdrl_image *self)
computes the median and associated error of an image.
double hdrl_image_get_stdev(const hdrl_image *self)
computes the standard deviation of the data of an image
cpl_mask * hdrl_image_get_mask(hdrl_image *himg)
get cpl bad pixel mask from image
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
cpl_size hdrl_image_get_size_y(const hdrl_image *self)
return size of Y dimension of image
const cpl_mask * hdrl_image_get_mask_const(const hdrl_image *himg)
get cpl bad pixel mask from image
cpl_size hdrl_image_get_size_x(const hdrl_image *self)
return size of X dimension of image
const cpl_image * hdrl_image_get_error_const(const hdrl_image *himg)
get error as cpl image
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
const cpl_image * hdrl_image_get_image_const(const hdrl_image *himg)
get data as cpl image
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
hdrl_image * hdrl_imagelist_unset(hdrl_imagelist *himlist, cpl_size pos)
Remove an image from an imagelist.
cpl_error_code hdrl_imagelist_set(hdrl_imagelist *himlist, hdrl_image *himg, cpl_size pos)
Insert an image into an imagelist.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.
const hdrl_image * hdrl_imagelist_get_const(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.
cpl_size hdrl_imagelist_get_size(const hdrl_imagelist *himlist)
Get the number of images in the imagelist.
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.
cpl_error_code hdrl_imagelist_collapse_median(const hdrl_imagelist *himlist, hdrl_image **out, cpl_image **contrib)
Median collapsing of image list.
hdrl_image * hdrl_imagelist_get(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter