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"
144 cpl_vector *ret_vec = NULL;
145 double *pret_vec = NULL;
146 const double *pdata = NULL;
150 cpl_ensure(data, CPL_ERROR_NULL_INPUT, NULL);
154 size = cpl_vector_get_size(data);
158 ret_vec = cpl_vector_new(size);
159 pret_vec = cpl_vector_get_data(ret_vec);
161 cpl_vector_fill(ret_vec, -1.0);
164 pdata = cpl_vector_get_data_const(data);
167 for (
int i = 0; i < size; i++) {
174 if (fabs(pdata[i]-val) > 0.0001)
233 const cpl_vector *indices)
235 cpl_vector* ret_vec = NULL;
236 double *pret_vec = NULL;
237 const double *pdata = NULL,
241 cpl_ensure(data, CPL_ERROR_NULL_INPUT, NULL);
242 cpl_ensure(indices, CPL_ERROR_NULL_INPUT, NULL);
246 pdata = cpl_vector_get_data_const(data);
247 pindices = cpl_vector_get_data_const(indices);
249 size = cpl_vector_get_size(indices);
251 ret_vec = cpl_vector_new(size);
252 pret_vec = cpl_vector_get_data(ret_vec);
254 for (
int i = 0; i < size; i++) {
255 if ((
int)pindices[i] < 0) {
257 "One of the indices is < 0!");
259 pret_vec[i] = pdata[(int)pindices[i]];
298 int *begin,
int *end,
int cut)
300 cpl_error_code err = CPL_ERROR_NONE;
304 cpl_vector *tmp_vec = NULL;
306 cpl_ensure_code(vec, CPL_ERROR_NULL_INPUT);
307 cpl_ensure_code(*vec, CPL_ERROR_NULL_INPUT);
311 pvec = cpl_vector_get_data(*vec);
313 max = cpl_vector_get_size(*vec)-1;
316 for (
int i = 0; i < cpl_vector_get_size(*vec); i++) {
324 if (min != cpl_vector_get_size(*vec)) {
326 for (
int i = cpl_vector_get_size(*vec)-1; i >= 0; i--) {
336 tmp_vec = cpl_vector_extract(*vec, min, max, 1);
338 cpl_vector_delete(*vec); *vec= NULL;
345 cpl_vector_delete(*vec); *vec = NULL;
364 err = cpl_error_get_code();
396 int exposureCorrectionMode)
398 hdrl_imagelist *hdrl_list = NULL;
399 cpl_frameset *frames = NULL;
400 hdrl_image *tmp_img = NULL;
401 const cpl_frame *fr = NULL;
402 const char *fn = NULL;
404 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
405 cpl_ensure(tag, CPL_ERROR_NULL_INPUT, NULL);
416 fr = cpl_frameset_find_const(frames, tag);
419 fn = cpl_frame_get_filename(fr);
424 if (cpl_frame_get_tag(fr) != NULL) {
426 exposureCorrectionMode, NULL);
435 fr = cpl_frameset_find_const(frames, NULL);
456 const cpl_frameset *frameset,
459 cpl_frameset *frames = NULL;
460 const cpl_frame *curFrame ;
461 cpl_frame *locFrame ;
465 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
466 cpl_ensure(tag, CPL_ERROR_NULL_INPUT, NULL);
471 frameCnt = cpl_frameset_count_tags(frameset, tag);
476 "frameset contains no frames with tag %s", tag);
480 frames = cpl_frameset_new() ;
483 frameCnt = cpl_frameset_get_size(frameset) ;
484 for (i=0 ; i<frameCnt ; i++) {
485 curFrame = cpl_frameset_get_position_const(frameset, i) ;
486 if (!strcmp(cpl_frame_get_tag(curFrame), tag)) {
487 locFrame = cpl_frame_duplicate(curFrame) ;
488 cpl_frameset_insert(frames, locFrame) ;
509 cpl_parameterlist *p1,
510 const cpl_parameterlist *p2)
512 cpl_error_code err = CPL_ERROR_NONE;
513 const cpl_parameter *p = NULL;
515 cpl_ensure_code(p1, CPL_ERROR_NULL_INPUT);
516 cpl_ensure_code(p2, CPL_ERROR_NULL_INPUT);
520 p = cpl_parameterlist_get_first_const(p2);
521 cpl_parameterlist_append(p1, cpl_parameter_duplicate(p));
522 while ((p = cpl_parameterlist_get_next_const(p2)) != NULL) {
523 cpl_parameterlist_append(p1, cpl_parameter_duplicate(p));
529 err = cpl_error_get_code();
543 if ((item != NULL) && (*item != NULL)) {
557 if ((item != NULL) && (*item != NULL)) {
571 if ((item != NULL) && (*item != NULL)) {
572 cpl_image_delete(*item);
585 if ((item != NULL) && (*item != NULL)) {
586 cpl_imagelist_delete(*item);
599 if ((item != NULL) && (*item != NULL)) {
600 cpl_mask_delete(*item);
613 if ((item != NULL) && (*item != NULL)) {
614 cpl_matrix_delete(*item);
627 if ((item != NULL) && (*item != NULL)) {
628 cpl_propertylist_delete(*item);
641 if ((item != NULL) && (*item != NULL)) {
642 cpl_vector_delete(*item);
655 if ((item != NULL) && (*item != NULL)) {
670 if ((item != NULL) && (*item != NULL)) {
684 if ((item != NULL) && (*item != NULL)) {
685 cpl_frameset_delete(*item);
698 if ((item != NULL) && (*item != NULL)) {
699 cpl_frame_delete(*item);
712 if ((item != NULL) && (*item != NULL)) {
726 if ((item != NULL) && (*item != NULL)) {
727 cpl_parameter_delete(*item);
740 if ((item != NULL) && (*item != NULL)) {
741 cpl_parameterlist_delete(*item);
754 if ((item != NULL) && (*item != NULL)) {
755 cpl_table_delete(*item);
769 if ((item != NULL) && (*item != NULL)) {
784 if ((item != NULL) && (*item != NULL)) {
799 if ((item != NULL) && (*item != NULL)) {
813 if ((item != NULL) && (*item != NULL)) {
814 cpl_polynomial_delete(*item);
827 if ((item != NULL) && (*item != NULL)) {
828 cpl_bivector_delete(*item);
841 if ((item != NULL) && (*item != NULL)) {
842 cpl_apertures_delete(*item);
866 const cpl_propertylist *plist,
867 const cpl_parameterlist *parlist,
870 const char *filename,
872 const cpl_image *image)
874 cpl_error_code err = CPL_ERROR_NONE;
875 char *pckgName = NULL;
876 cpl_propertylist *plistdup = NULL;
878 cpl_ensure_code(fs, CPL_ERROR_NULL_INPUT);
879 cpl_ensure_code(plist, CPL_ERROR_NULL_INPUT);
880 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
881 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
882 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
883 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
884 cpl_ensure_code(image, CPL_ERROR_NULL_INPUT);
888 plistdup = cpl_propertylist_duplicate(plist);
890 pckgName = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
892 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_CATG, procatg);
894 cpl_dfs_save_image(fs, NULL, parlist, fs, NULL, image, type,
895 recipe, plistdup,
"RADECSYS", pckgName, filename);
897 cpl_propertylist_delete(plistdup);
902 err = cpl_error_get_code();
932 const cpl_propertylist *plist,
933 const cpl_parameterlist *parlist,
936 const char *filename,
938 const cpl_imagelist *imglist)
940 cpl_error_code err = CPL_ERROR_NONE;
941 char *pckgName = NULL;
942 cpl_propertylist *plistdup = NULL;
944 cpl_ensure_code(fs, CPL_ERROR_NULL_INPUT);
945 cpl_ensure_code(plist, CPL_ERROR_NULL_INPUT);
946 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
947 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
948 cpl_ensure_code(procatg, CPL_ERROR_NULL_INPUT);
949 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
950 cpl_ensure_code(imglist, CPL_ERROR_NULL_INPUT);
954 plistdup = cpl_propertylist_duplicate(plist);
955 pckgName = cpl_sprintf(
"%s%s%s", PACKAGE,
"/", PACKAGE_VERSION);
956 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_CATG, procatg);
958 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_TYPE,
"CUBE");
959 cpl_propertylist_update_string(plistdup, CPL_DFS_PRO_TECH,
"CUBE");
961 cpl_propertylist_erase(plistdup,
"RADECSYS");
965 cpl_dfs_save_imagelist(fs, NULL, parlist, fs, inherit, imglist, type,
966 recipe, plistdup,
"RADECSYS", pckgName, filename);
972 err = cpl_error_get_code();
976 cpl_propertylist_delete(plistdup);
1000 const cpl_mask *mask)
1002 cpl_error_code err = CPL_ERROR_NONE;
1003 const cpl_binary *pmask = NULL;
1004 cpl_mask *img_mask = NULL;
1005 cpl_binary *pimg_mask = NULL;
1009 cpl_ensure_code(img, CPL_ERROR_NULL_INPUT);
1010 cpl_ensure_code(mask, CPL_ERROR_NULL_INPUT);
1012 CPL_ERROR_ILLEGAL_INPUT);
1014 CPL_ERROR_ILLEGAL_INPUT);
1020 pimg_mask = cpl_mask_get_data(img_mask);
1021 pmask = cpl_mask_get_data_const(mask);
1025 for (cpl_size y = 0; y < nRows; y++) {
1026 for (cpl_size x = 0; x < nCols; x++) {
1027 if ((pmask[x+y*nCols] == BAD_PIX) &&
1028 (pimg_mask[x+y*nCols] == GOOD_PIX))
1030 pimg_mask[x+y*nCols] = BAD_PIX;
1038 err = cpl_error_get_code();
1058 const char* filename,
int create,
1059 const cpl_propertylist *pl)
1061 cpl_ensure_code(vec,CPL_ERROR_NULL_INPUT);
1063 return cpl_vector_save(vec, filename, CPL_TYPE_DOUBLE, pl, create);
1079 const char* filename,
int create)
1102 const char* filename,
int col,
int create)
1107 const cpl_vector *x = NULL,
1111 x = cpl_bivector_get_x_const(bivec);
1113 }
else if (col == 2) {
1114 y = cpl_bivector_get_x_const(bivec);
1116 }
else if (col == 0) {
1117 x = cpl_bivector_get_x_const(bivec);
1118 y = cpl_bivector_get_y_const(bivec);
1122 return CPL_ERROR_ILLEGAL_INPUT;
1140 const char* filename,
int create,
1141 const cpl_propertylist *pl)
1143 cpl_ensure_code(img,CPL_ERROR_NULL_INPUT);
1146 return cpl_image_save(img, filename,
1147 CPL_TYPE_INT, pl, create);
1148 }
else if (cpl_image_get_type(img) == CPL_TYPE_FLOAT) {
1149 return cpl_image_save(img, filename,
1150 CPL_TYPE_FLOAT, pl, create);
1151 }
else if (cpl_image_get_type(img) == CPL_TYPE_DOUBLE) {
1152 return cpl_image_save(img, filename,
1153 CPL_TYPE_DOUBLE, pl, create);
1154 }
else if (cpl_image_get_type(img) == CPL_TYPE_INT) {
1155 return cpl_image_save(img, filename,
1156 CPL_TYPE_INT, pl, create);
1158 return CPL_ERROR_ILLEGAL_INPUT;
1174 const char* filename,
int create)
1176 return cpl_table_save(tbl, NULL, NULL, filename, create);
1192 const char* filename,
int create,
1193 const cpl_propertylist *pl)
1195 return cpl_mask_save(mask, filename, pl, create);
1211 const char* filename,
int create)
1213 cpl_ensure_code(imglist, CPL_ERROR_NULL_INPUT);
1214 cpl_ensure_code(cpl_imagelist_get_size(imglist) >= 0,
1215 CPL_ERROR_ILLEGAL_INPUT);
1217 const cpl_image *img = cpl_imagelist_get_const(imglist, 0);
1219 if (cpl_image_get_type(img) == CPL_TYPE_FLOAT) {
1220 return cpl_imagelist_save(imglist, filename,
1221 CPL_TYPE_FLOAT, NULL, create);
1222 }
else if (cpl_image_get_type(img) == CPL_TYPE_DOUBLE) {
1223 return cpl_imagelist_save(imglist, filename,
1224 CPL_TYPE_DOUBLE, NULL, create);
1226 return CPL_ERROR_ILLEGAL_INPUT;
1245 const char* name,
int singlefile,
1246 const cpl_propertylist *pl)
1249 const cpl_mask *mask = NULL;
1250 cpl_error_code err = CPL_ERROR_NONE;
1251 int create = CPL_IO_CREATE;
1256 fn = cpl_sprintf(
"%s.fits", name);
1258 fn = cpl_sprintf(
"%s_data.fits", name);
1261 cpl_free(fn); fn = NULL;
1264 fn = cpl_sprintf(
"%s.fits", name);
1265 create = CPL_IO_EXTEND;
1267 fn = cpl_sprintf(
"%s_mask.fits", name);
1268 create = CPL_IO_CREATE;
1270 mask = cpl_image_get_bpm_const(img);
1272 cpl_free(fn); fn = NULL;
1277 err = cpl_error_get_code();
1279 cpl_free(fn); fn = NULL;
1299 cpl_error_code err = CPL_ERROR_NONE;
1303 fn = cpl_sprintf(
"%s.fits", name);
1310 err = cpl_error_get_code();
1334 const char* filename,
int singlefile,
1335 const cpl_propertylist *pl)
1338 const cpl_image *img = NULL;
1339 const cpl_mask *mask = NULL;
1340 cpl_error_code err = CPL_ERROR_NONE;
1341 int create = CPL_IO_CREATE;
1346 fn = cpl_sprintf(
"%s.fits", filename);
1348 fn = cpl_sprintf(
"%s_data.fits", filename);
1352 cpl_free(fn); fn = NULL;
1355 fn = cpl_sprintf(
"%s.fits", filename);
1356 create = CPL_IO_EXTEND;
1358 fn = cpl_sprintf(
"%s_err.fits", filename);
1359 create = CPL_IO_CREATE;
1363 cpl_free(fn); fn = NULL;
1366 fn = cpl_sprintf(
"%s.fits", filename);
1367 create = CPL_IO_EXTEND;
1369 fn = cpl_sprintf(
"%s_mask.fits", filename);
1370 create = CPL_IO_CREATE;
1376 cpl_free(fn); fn = NULL;
1381 err = cpl_error_get_code();
1404 const hdrl_imagelist *hdrl_img_list,
1405 const char* filename,
int singlefile)
1408 cpl_imagelist *img_list = NULL;
1409 const hdrl_image *tmp_hdrl_img = NULL;
1410 const cpl_mask *mask = NULL;
1411 const cpl_binary *pmask = NULL;
1412 cpl_image *img = NULL;
1413 cpl_error_code err = CPL_ERROR_NONE;
1417 create = CPL_IO_CREATE;
1423 fn = cpl_sprintf(
"%s.fits", filename);
1425 fn = cpl_sprintf(
"%s_data.fits", filename);
1431 cpl_free(fn); fn = NULL;
1435 fn = cpl_sprintf(
"%s.fits", filename);
1436 create = CPL_IO_EXTEND;
1438 fn = cpl_sprintf(
"%s_err.fits", filename);
1439 create = CPL_IO_CREATE;
1445 cpl_free(fn); fn = NULL;
1449 fn = cpl_sprintf(
"%s.fits", filename);
1450 create = CPL_IO_EXTEND;
1452 fn = cpl_sprintf(
"%s_mask.fits", filename);
1453 create = CPL_IO_CREATE;
1455 img_list = cpl_imagelist_new();
1461 nx = cpl_mask_get_size_x(mask);
1462 ny = cpl_mask_get_size_y(mask);
1464 img = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
1465 pimg = cpl_image_get_data_float(img);
1466 pmask = cpl_mask_get_data_const(mask);
1468 for (
int j = 0; j < nx*ny; j++) {
1469 if (pmask[j] == BAD_PIX) {
1476 cpl_imagelist_set(img_list, img, i);
1480 cpl_free(fn); fn = NULL;
1485 err = cpl_error_get_code();
1548 const cpl_frameset *frameset,
1549 const char *category,
1552 const cpl_frame *frame = NULL;
1553 cpl_mask *bp_mask = NULL;
1555 cpl_ensure(frameset, CPL_ERROR_NULL_INPUT, NULL);
1556 cpl_ensure(category, CPL_ERROR_NULL_INPUT, NULL);
1561 CPL_ERROR_ILLEGAL_INPUT,
1562 "ext must be 0 or larger!");
1564 frame = cpl_frameset_find_const(frameset, category);
1567 if (frame != NULL) {
1568 bp_mask = cpl_mask_load(cpl_frame_get_filename(frame), 0, ext);
1670 cpl_error_code err = CPL_ERROR_NONE;
1673 cpl_ensure_code(filename, CPL_ERROR_NULL_INPUT);
1677 fh = fopen(filename,
"r");
1681 err = cpl_error_get_code();
1706 cpl_imagelist *data = NULL;
1707 const hdrl_image *tmp_hdrl_img = NULL;
1708 cpl_image *tmp_img = NULL;
1710 cpl_ensure(hdrl_imglist, CPL_ERROR_NULL_INPUT, NULL);
1714 data = cpl_imagelist_new();
1719 if (type == eris_hdrl_data) {
1721 tmp_img = cpl_image_duplicate(
1723 }
else if (type == eris_hdrl_error) {
1725 tmp_img = cpl_image_duplicate(
1735 cpl_imagelist_set(data, tmp_img, i);
1765 const char *arLampString =
"";
1766 const char *krLampString =
"";
1767 const char *neLampString =
"";
1768 const char *xeLampString =
"";
1770 if ((lampStatus & AR_LAMP) == AR_LAMP) {arLampString =
"Ar";}
1771 if ((lampStatus & KR_LAMP) == KR_LAMP) {krLampString =
"Kr";}
1772 if ((lampStatus & NE_LAMP) == NE_LAMP) {neLampString =
"Ne";}
1773 if ((lampStatus & XE_LAMP) == XE_LAMP) {xeLampString =
"Xe";}
1774 lampString = cpl_sprintf(
"%s%s%s%s",
1775 arLampString, krLampString, neLampString, xeLampString);
1792 const char *bandString;
1794 case UNDEFINED_BAND:
1798 bandString =
"J_LOW";
1801 bandString =
"H_LOW";
1804 bandString =
"K_LOW";
1807 bandString =
"J_SHORT";
1810 bandString =
"J_MIDDLE";
1813 bandString =
"J_LONG";
1816 bandString =
"H_SHORT";
1819 bandString =
"H_MIDDLE";
1822 bandString =
"H_LONG";
1825 bandString =
"K_SHORT";
1828 bandString =
"K_MIDDLE";
1831 bandString =
"K_LONG";
1834 bandString =
"J_SPIFFI";
1837 bandString =
"H_SPIFFI";
1840 bandString =
"K_SPIFFI";
1843 bandString =
"HK_SPIFFI";
1846 bandString =
"Unknown";
1871 case UNDEFINED_BAND: resolution = 0;
break;
1872 case J_LOW: resolution = 5000;
break;
1873 case H_LOW: resolution = 5200;
break;
1874 case K_LOW: resolution = 5600;
break;
1875 case J_SHORT: resolution = 10000;
break;
1876 case J_MIDDLE: resolution = 10000;
break;
1877 case J_LONG: resolution = 10000;
break;
1878 case H_SHORT: resolution = 10400;
break;
1879 case H_MIDDLE: resolution = 10400;
break;
1880 case H_LONG: resolution = 10400;
break;
1881 case K_SHORT: resolution = 11200;
break;
1882 case K_MIDDLE: resolution = 11200;
break;
1883 case K_LONG: resolution = 11200;
break;
1884 case J_SPIFFI: resolution = 5000;
break;
1885 case H_SPIFFI: resolution = 5000;
break;
1886 case K_SPIFFI: resolution = 5000;
break;
1887 case HK_SPIFFI: resolution = 3000;
break;
1888 default: resolution = 0;
break;
1912 cpl_ensure_code(zmin >= 0, CPL_ERROR_ILLEGAL_INPUT);
1915 case UNDEFINED_BAND:
break;
1916 case J_LOW: *zmin = 46; *zmax = 2015;
break;
1917 case H_LOW: *zmin = 48; *zmax = 2023;
break;
1918 case K_LOW: *zmin = 62; *zmax = 2022;
break;
1919 case J_SHORT: *zmin = 50; *zmax = 2034;
break;
1920 case J_MIDDLE: *zmin = 57; *zmax = 2040;
break;
1921 case J_LONG: *zmin = 48; *zmax = 2033;
break;
1922 case H_SHORT: *zmin = 52; *zmax = 2034;
break;
1923 case H_MIDDLE: *zmin = 47; *zmax = 2034;
break;
1924 case H_LONG: *zmin = 56; *zmax = 2042;
break;
1925 case K_SHORT: *zmin = 54; *zmax = 2036;
break;
1926 case K_MIDDLE: *zmin = 49; *zmax = 2029;
break;
1927 case K_LONG: *zmin = 50; *zmax = 2034;
break;
1928 case J_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1929 case H_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1930 case K_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1931 case HK_SPIFFI: *zmin = 32; *zmax = 2058;
break;
1935 return cpl_error_get_code();
1957 cpl_msg_info(cpl_func,
"org size: %lld", size);
1958 hdrl_image* hima = NULL;
1960 hdrl_value hvalue = {0, 0};
1961 for(cpl_size k = 0; k < size; k++) {
1963 for(cpl_size j = 10; j < 20; j++) {
1964 for(cpl_size i = 10; i < 20; i++) {
1965 hvalue.data = k * 10.;
1976 return cpl_error_get_code();
2002 hdrl_imagelist** iml, cpl_imagelist** bpm, cpl_propertylist* header) {
2004 cpl_ensure_code(iml,CPL_ERROR_NULL_INPUT);
2005 cpl_ensure_code(bpm,CPL_ERROR_NULL_INPUT);
2006 cpl_ensure_code(header,CPL_ERROR_NULL_INPUT);
2007 cpl_ensure_code(zmin <= zmax,CPL_ERROR_ILLEGAL_INPUT);
2009 cpl_msg_debug(cpl_func,
"org size: %lld", size);
2013 for(cpl_size i = size-1; i > zmax; i--) {
2015 cpl_imagelist_unset(*bpm, i);
2021 for(cpl_size i = 0; i < zmin; i++) {
2023 cpl_imagelist_unset(*bpm, 0);
2026 double crval3 = cpl_propertylist_get_double(header,
"CRVAL3");
2027 const double cd3_3 = cpl_propertylist_get_double(header,
"CD3_3");
2028 int naxis3 = cpl_propertylist_get_int(header,
"NAXIS3");
2030 crval3 += cd3_3 * zmin;
2031 naxis3 = zmax - zmin +1;
2032 cpl_propertylist_set_double(header,
"CRVAL3", crval3);
2033 cpl_propertylist_set_int(header,
"NAXIS3", naxis3);
2036 return cpl_error_get_code();
2050 const char *instrumentString;
2051 switch (instrument) {
2052 case OTHER_INSTRUMENT: instrumentString =
"unknown instrument";
break;
2053 case SPIFFI: instrumentString =
"SPIFFI";
break;
2054 case SPIFFIER: instrumentString =
"SPIFFIER";
break;
2055 case NIX: instrumentString =
"NIX";
break;
2056 case UNSET_INSTRUMENT: instrumentString =
"unset instrument";
break;
2057 default: instrumentString =
"unset instrument";
break;
2060 return instrumentString;
2075 const char *scaleString;
2077 case UNDEFINED_SCALE:
2081 scaleString =
"250mas";
2084 scaleString =
"100mas";
2087 scaleString =
"25mas";
2090 scaleString =
"PUPIL";
2093 scaleString =
"Unknown";
2115 double *pimg_window = NULL;
2116 const double *pimg = NULL;
2117 cpl_image *img_window = NULL;
2118 const cpl_mask *mask = NULL;
2119 cpl_mask *mask_window = NULL;
2120 const cpl_binary *pmask = NULL;
2121 cpl_binary *pmask_window = NULL;
2123 cpl_ensure(img, CPL_ERROR_NULL_INPUT, NULL);
2127 nx = cpl_image_get_size_x(img);
2128 ny = cpl_image_get_size_y(img);
2130 img_window = cpl_image_new(nx-2*ERIS_IFU_DETECTOR_BP_BORDER,
2131 ny-2*ERIS_IFU_DETECTOR_BP_BORDER,
2132 cpl_image_get_type(img));
2134 pimg = cpl_image_get_data_const(img);
2135 mask = cpl_image_get_bpm_const(img);
2136 pmask = cpl_mask_get_data_const(mask);
2137 pimg_window = cpl_image_get_data(img_window);
2138 mask_window = cpl_image_get_bpm(img_window);
2139 pmask_window = cpl_mask_get_data(mask_window);
2141 for (
int x = 0; x < nx-2*ERIS_IFU_DETECTOR_BP_BORDER; x++) {
2142 for (
int y = 0; y < ny-2*ERIS_IFU_DETECTOR_BP_BORDER; y++) {
2143 cpl_size nx_new = nx-2*ERIS_IFU_DETECTOR_BP_BORDER,
2144 x_old = x+ERIS_IFU_DETECTOR_BP_BORDER,
2145 y_old = y+ERIS_IFU_DETECTOR_BP_BORDER;
2146 pimg_window[x+y*nx_new] = pimg[x_old+y_old*nx];
2147 pmask_window[x+y*nx_new] = pmask[x_old+y_old*nx];
2175 cpl_binary *pmask_border = NULL;
2176 const cpl_binary *pmask = NULL;
2177 cpl_mask *mask_border = NULL;
2179 cpl_ensure(mask, CPL_ERROR_NULL_INPUT, NULL);
2183 nx = cpl_mask_get_size_x(mask);
2184 ny = cpl_mask_get_size_y(mask);
2187 mask_border = cpl_mask_new(nx+2*ERIS_IFU_DETECTOR_BP_BORDER,
2188 ny+2*ERIS_IFU_DETECTOR_BP_BORDER);
2190 pmask = cpl_mask_get_data_const(mask);
2191 pmask_border = cpl_mask_get_data(mask_border);
2193 for (
int x = 0; x < nx; x++) {
2194 for (
int y = 0; y < ny; y++) {
2195 cpl_size x_new = x+ERIS_IFU_DETECTOR_BP_BORDER,
2196 y_new = y+ERIS_IFU_DETECTOR_BP_BORDER,
2197 nx_new = nx+2*ERIS_IFU_DETECTOR_BP_BORDER;
2198 pmask_border[x_new+y_new*nx_new] = pmask[x+y*nx];
2228 double* pdata = NULL;
2229 double* perrs = NULL;
2230 cpl_binary* pbpm = NULL;
2233 cpl_size npoints = 0;
2234 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2245 cpl_size nan_pix = 0;
2246 for(cpl_size i = 0; i < npoints; i++) {
2249 if(isnan(pdata[i]) || isnan(perrs[i]) ){
2257 return cpl_error_get_code();
2276 cpl_error_code retVal = CPL_ERROR_NONE;
2281 cpl_image *tmpImg = NULL;
2282 cpl_mask *mask = NULL;
2283 cpl_binary *maskData = NULL;
2284 const double *imgDataD = NULL;
2285 const float *imgDataF = NULL;
2286 cpl_type imgType = CPL_TYPE_INVALID;
2288 cpl_ensure(cube, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2292 nz = cpl_imagelist_get_size(cube);
2294 tmpImg = cpl_imagelist_get(cube,0);
2295 imgType = cpl_image_get_type(tmpImg);
2296 if (! (imgType == CPL_TYPE_FLOAT || imgType == CPL_TYPE_DOUBLE)) {
2298 "unsupported image type within cube");
2300 nx = cpl_image_get_size_x(tmpImg);
2301 ny = cpl_image_get_size_y(tmpImg);
2304 for (cpl_size z=0; z < nz; z++) {
2305 tmpImg = cpl_imagelist_get(cube,z);
2307 case CPL_TYPE_FLOAT:
2308 imgDataF = cpl_image_get_data_float_const(tmpImg);
2310 case CPL_TYPE_DOUBLE:
2311 imgDataD = cpl_image_get_data_double_const(tmpImg);
2315 mask = cpl_image_get_bpm(tmpImg);
2316 maskData = cpl_mask_get_data(mask);
2317 for (cpl_size y=0; y < ny; y++) {
2318 for (cpl_size x=0; x < nx; x++) {
2321 case CPL_TYPE_FLOAT:
2322 if (!isfinite(imgDataF[idx])) {
2323 maskData[idx] = BAD_PIX;
2326 case CPL_TYPE_DOUBLE:
2327 if (!isfinite(imgDataD[idx])) {
2328 maskData[idx] = BAD_PIX;
2340 retVal = cpl_error_get_code();
2389 deqQualityType qualityType)
2391 cpl_mask *bpmMask = NULL;
2394 ASSURE((qualityMask != NULL), CPL_ERROR_NULL_INPUT, NULL);
2395 bpmMask = cpl_mask_threshold_image_create(
2396 qualityMask, .5, 4294967296.5 );
2397 switch(qualityType) {
2399 cpl_mask_not(bpmMask);
2408 cpl_mask_delete(bpmMask);
2410 "Unspecified DEQ quality type");
2415 "Unknown DEQ quality type");
2437 cpl_imagelist *maskOneCube = NULL;
2438 cpl_image *img = NULL;
2439 cpl_image *maskOneImg = NULL;
2440 int *maskOneImgPtr = NULL;
2441 float *floatPtr = NULL;
2442 double *doublePtr = NULL;
2443 float floatThreshold;
2444 cpl_size imgPixelCnt = 0,
2451 ASSURE(bpmCube != NULL, CPL_ERROR_NULL_INPUT,
"bpmCube must not be NULL");
2453 maskOneCube = cpl_imagelist_new();
2455 img = cpl_imagelist_get(bpmCube, 0);
2456 bpmType = cpl_image_get_type(img);
2457 ASSURE(bpmType == CPL_TYPE_FLOAT || bpmType == CPL_TYPE_DOUBLE,
2458 CPL_ERROR_ILLEGAL_INPUT,
"bpmCube must be of type float or double");
2460 nx = cpl_image_get_size_x(img);
2461 ny = cpl_image_get_size_y(img);
2462 imgPixelCnt = nx * ny;
2464 floatThreshold = (float) threshold;
2466 for (cpl_size cx=0; cx < cpl_imagelist_get_size(bpmCube); cx++) {
2467 img = cpl_imagelist_get(bpmCube, cx);
2469 maskOneImg = cpl_image_new(nx, ny, CPL_TYPE_INT);
2470 maskOneImgPtr = cpl_image_get_data_int(maskOneImg);
2472 if (bpmType == CPL_TYPE_FLOAT) {
2473 floatPtr = cpl_image_get_data_float(img);
2474 for (cpl_size px=0; px < imgPixelCnt; px++) {
2475 if (floatPtr[px] > floatThreshold) {
2476 maskOneImgPtr[px] = 1;
2478 maskOneImgPtr[px] = 0;
2481 }
else if (bpmType == CPL_TYPE_DOUBLE) {
2482 doublePtr = cpl_image_get_data_double(img);
2483 for (cpl_size px=0; px < imgPixelCnt; px++) {
2484 if (doublePtr[px] > threshold) {
2485 maskOneImgPtr[px] = 1;
2487 maskOneImgPtr[px] = 0;
2493 cpl_imagelist_set(maskOneCube, maskOneImg, cx);
2515 cpl_imagelist *dataCube,
2516 cpl_imagelist *errorCube)
2518 cpl_error_code retVal = CPL_ERROR_NONE;
2519 hdrl_image *image = NULL;
2523 cpl_ensure(cube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2524 cpl_ensure(dataCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2525 cpl_ensure(errorCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2553 cpl_imagelist *dataCube,
2554 cpl_imagelist *errorCube,
2555 cpl_imagelist *qualCube)
2557 cpl_error_code retVal = CPL_ERROR_NONE;
2558 hdrl_image *image = NULL;
2561 cpl_ensure(cube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2562 cpl_ensure(dataCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2563 cpl_ensure(errorCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2564 cpl_ensure(qualCube != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
2568 cpl_imagelist_set(dataCube,
2570 cpl_imagelist_set(errorCube,
2572 cpl_imagelist_set(qualCube,
2597 table = cpl_table_new(0);
2598 cpl_table_new_column(table,
"key_name", CPL_TYPE_STRING);
2599 cpl_table_new_column(table,
"key_type", CPL_TYPE_STRING);
2600 cpl_table_new_column(table,
"key_value", CPL_TYPE_STRING);
2601 cpl_table_new_column(table,
"key_help", CPL_TYPE_STRING);
2619 const char* key_name,
2621 const char* key_help)
2624 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2625 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2626 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2628 int sz = cpl_table_get_nrow(table);
2633 key_value = cpl_sprintf(
"%d",value);
2634 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_INT");
2636 cpl_table_set_size(table,sz+1);
2638 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2639 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2640 cpl_table_set_string(table,
"key_value",raw,key_value);
2641 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2643 cpl_free(key_value);
2646 return cpl_error_get_code();
2664 const char* key_name,
2665 const char* key_help)
2667 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2668 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2669 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2671 int sz = cpl_table_get_nrow(table);
2676 key_value = cpl_sprintf(
"%s",key_name);
2677 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_BOOL");
2679 cpl_table_set_size(table,sz+1);
2681 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2682 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2683 cpl_table_set_string(table,
"key_value",raw,key_value);
2684 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2685 cpl_free(key_value);
2688 return cpl_error_get_code();
2706 const char* key_name,
2708 const char* key_help)
2710 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2711 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2712 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2714 int sz = cpl_table_get_nrow(table);
2720 key_value = cpl_sprintf(
"%g",value);
2722 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2724 cpl_table_set_size(table,sz+1);
2726 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2727 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2728 cpl_table_set_string(table,
"key_value",raw,key_value);
2729 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2731 cpl_free(key_value);
2734 return cpl_error_get_code();
2751 const char* key_name,
2753 const char* key_help)
2756 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2757 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2758 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2760 int sz = cpl_table_get_nrow(table);
2765 key_value = cpl_sprintf(
"%f",value);
2766 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2768 cpl_table_set_size(table,sz+1);
2770 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2771 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2772 cpl_table_set_string(table,
"key_value",raw,key_value);
2773 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2774 cpl_free(key_value);
2777 return cpl_error_get_code();
2794 const char* key_name,
2796 const char* key_help)
2799 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2800 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2801 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2803 int sz = cpl_table_get_nrow(table);
2808 key_value = cpl_sprintf(
"%13.6f",value);
2809 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_DOUBLE");
2811 cpl_table_set_size(table,sz+1);
2813 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2814 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2815 cpl_table_set_string(table,
"key_value",raw,key_value);
2816 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2817 cpl_free(key_value);
2820 return cpl_error_get_code();
2837 const char* key_name,
2839 const char* key_help)
2842 cpl_ensure_code(table != NULL, CPL_ERROR_NULL_INPUT);
2843 cpl_ensure_code(key_name != NULL, CPL_ERROR_NULL_INPUT);
2844 cpl_ensure_code(key_help != NULL, CPL_ERROR_NULL_INPUT);
2846 int sz = cpl_table_get_nrow(table);
2851 key_value = cpl_sprintf(
"%s",value);
2852 key_type = cpl_sprintf(
"%s",
"CPL_TYPE_STRING");
2854 cpl_table_set_size(table,sz+1);
2856 cpl_table_set_string(table,
"key_name" ,raw,key_name);
2857 cpl_table_set_string(table,
"key_type" ,raw,key_type);
2858 cpl_table_set_string(table,
"key_value",raw,key_value);
2859 cpl_table_set_string(table,
"key_help" ,raw,key_help);
2860 cpl_free(key_value);
2863 return cpl_error_get_code();
2879 cpl_propertylist * plist,
2884 cpl_ensure_code(plist != NULL, CPL_ERROR_NULL_INPUT);
2885 cpl_ensure_code(qclog != NULL, CPL_ERROR_NULL_INPUT);
2886 char* key_name = NULL;
2887 char* key_value = NULL;
2888 char* key_type = NULL;
2889 char* key_help = NULL;
2900 if (plist == NULL) {
2901 cpl_msg_error(cpl_func,
"plist=NULL, something strange");
2902 return CPL_ERROR_NULL_INPUT ;
2907 n = cpl_table_get_nrow(qclog);
2908 for(i = 0; i < n; i++) {
2910 key_name = cpl_sprintf(
"ESO %s",cpl_table_get_string(qclog,
"key_name", i));
2912 key_type = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_type", i));
2914 key_value = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_value", i));
2916 key_help = cpl_sprintf(
"%s", cpl_table_get_string(qclog,
"key_help", i));
2922 if( !cpl_propertylist_has(plist, key_name) ) {
2923 if(strcmp(key_type,
"CPL_TYPE_STRING") == 0) {
2924 cpl_propertylist_append_string(plist, key_name, key_value) ;
2925 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2926 }
else if(strcmp(key_type,
"CPL_TYPE_BOOL") == 0) {
2927 cpl_propertylist_append_bool(plist, key_name, atoi(key_value)) ;
2928 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2929 }
else if(strcmp(key_type,
"CPL_TYPE_INT") == 0) {
2930 cpl_propertylist_append_int(plist, key_name, atoi(key_value)) ;
2931 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2932 }
else if(strcmp(key_type,
"CPL_TYPE_FLOAT") == 0) {
2933 cpl_propertylist_append_float(plist, key_name, (
float) atof(key_value)) ;
2934 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2935 }
else if(strcmp(key_type,
"CPL_TYPE_DOUBLE") == 0) {
2936 cpl_propertylist_append_double(plist, key_name, atof(key_value)) ;
2937 cpl_propertylist_set_comment(plist, key_name, key_help) ;
2942 cpl_free(key_value);
2947 return cpl_error_get_code();
2962 cpl_propertylist* qc_list,
2966 cpl_ensure_code(image != NULL, CPL_ERROR_NULL_INPUT);
2967 cpl_ensure_code(qc_list != NULL, CPL_ERROR_NULL_INPUT);
2968 cpl_ensure_code(prefix != NULL, CPL_ERROR_NULL_INPUT);
2969 cpl_size sx = cpl_image_get_size_x(image);
2970 cpl_size sy = cpl_image_get_size_y(image);
2971 cpl_image* ima = cpl_image_duplicate(image);
2972 cpl_image_threshold(ima, 0, 0, 0, 1);
2973 double flux = cpl_image_get_flux(ima);
2974 cpl_image_delete(ima);
2975 cpl_size nBadPix = (cpl_size) flux;
2977 cpl_size npix = sx * sy;
2978 double fracBadPix = flux / npix;
2980 cpl_msg_warning(cpl_func,
"nBadPix: %lld",nBadPix);
2981 kname = cpl_sprintf(
"%s NBADPIX",prefix);
2982 cpl_msg_info(cpl_func,
"kname: %s prefix: %s",kname, prefix);
2986 kname = cpl_sprintf(
"%s BPIXFRAC",prefix);
2988 "Fraction of bad pixels to total");
2991 return cpl_error_get_code();
3007 cpl_propertylist* qc_list,
3010 cpl_ensure_code(bp_mask != NULL, CPL_ERROR_NULL_INPUT);
3011 cpl_ensure_code(qc_list != NULL, CPL_ERROR_NULL_INPUT);
3012 cpl_ensure_code(prefix != NULL, CPL_ERROR_NULL_INPUT);
3013 cpl_size sx = cpl_mask_get_size_x(bp_mask);
3014 cpl_size sy = cpl_mask_get_size_y(bp_mask);
3015 cpl_size nBadPix = cpl_mask_count(bp_mask);
3017 cpl_size npix = sx * sy;
3018 double fracBadPix = (double) nBadPix / npix;
3021 kname = cpl_sprintf(
"%s NBADPIX",prefix);
3022 cpl_msg_info(cpl_func,
"kname: %s prefix: %s",kname, prefix);
3026 kname = cpl_sprintf(
"%s BPIXFRAC",prefix);
3028 "Fraction of bad pixels to total");
3031 return cpl_error_get_code();
3055static cpl_error_code eris_apertures_find_max_flux(
const cpl_apertures * self,
3056 int * ind,
int nfind)
3061 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3063 const int nsize = cpl_apertures_get_size(self);
3067 cpl_ensure_code(nsize > 0, CPL_ERROR_ILLEGAL_INPUT);
3068 cpl_ensure_code(ind, CPL_ERROR_NULL_INPUT);
3069 cpl_ensure_code(nfind > 0, CPL_ERROR_ILLEGAL_INPUT);
3070 cpl_ensure_code(nfind <= nsize, CPL_ERROR_ILLEGAL_INPUT);
3072 for (ifind=0; ifind < nfind; ifind++) {
3073 double maxflux = -1;
3076 for (i=1; i <= nsize; i++) {
3080 for (k=0; k < ifind; k++)
if (ind[k] == i)
break;
3084 const double flux = cpl_apertures_get_flux(self, i);
3086 if (maxind < 0 || flux > maxflux) {
3092 ind[ifind] = maxind;
3095 return CPL_ERROR_NONE;
3121eris_gaussian_maxpos(
const cpl_image * self,
3132 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3133 cpl_ensure(sigma > 0, CPL_ERROR_ILLEGAL_INPUT, CPL_ERROR_ILLEGAL_INPUT);
3137 const cpl_size nx = cpl_image_get_size_x(self);
3138 const cpl_size ny = cpl_image_get_size_y(self);
3142 const double median = cpl_image_get_median_dev(self, &med_dist);
3143 cpl_mask * selection = NULL;
3144 cpl_size nlabels = 0;
3145 cpl_image * labels = NULL;
3146 cpl_apertures * aperts;
3150 cpl_size xposmax, yposmax;
3151 double xposcen, yposcen;
3152 double valmax, valfit = -1.0;
3153 cpl_array * gauss_parameters = NULL;
3154 cpl_errorstate prestate = cpl_errorstate_get();
3155 cpl_error_code code = CPL_ERROR_NONE;
3158 cpl_ensure_code( sigma > 0.0, CPL_ERROR_ILLEGAL_INPUT);
3160 selection = cpl_mask_new(nx, ny);
3163 for (; iretry > 0 && nlabels == 0; iretry--, sigma *= 0.5) {
3166 const double threshold = median + sigma * med_dist;
3169 code = cpl_mask_threshold_image(selection, self, threshold, DBL_MAX,
3175 cpl_image_delete(labels);
3176 labels = cpl_image_labelise_mask_create(selection, &nlabels);
3180 cpl_mask_delete(selection);
3183 cpl_image_delete(labels);
3184 return cpl_error_set_where(cpl_func);
3185 }
else if (nlabels == 0) {
3186 cpl_image_delete(labels);
3187 return cpl_error_set(cpl_func, CPL_ERROR_DATA_NOT_FOUND);
3190 aperts = cpl_apertures_new_from_image(self, labels);
3193 code = eris_apertures_find_max_flux(aperts, &ifluxapert, 1);
3196 cpl_apertures_delete(aperts);
3197 cpl_image_delete(labels);
3198 return cpl_error_set(cpl_func, CPL_ERROR_DATA_NOT_FOUND);
3201 npixobj = cpl_apertures_get_npix(aperts, ifluxapert);
3202 objradius = sqrt((
double)npixobj * CPL_MATH_1_PI);
3203 winsize = CX_MIN(CX_MIN(nx, ny), (3.0 * objradius));
3205 xposmax = cpl_apertures_get_maxpos_x(aperts, ifluxapert);
3206 yposmax = cpl_apertures_get_maxpos_y(aperts, ifluxapert);
3207 xposcen = cpl_apertures_get_centroid_x(aperts, ifluxapert);
3208 yposcen = cpl_apertures_get_centroid_y(aperts, ifluxapert);
3209 valmax = cpl_apertures_get_max(aperts, ifluxapert);
3211 cpl_apertures_delete(aperts);
3212 cpl_image_delete(labels);
3214 cpl_msg_debug(cpl_func,
"Object radius at S/R=%g: %g (window-size=%u)",
3215 sigma, objradius, (
unsigned)winsize);
3216 cpl_msg_debug(cpl_func,
"Object-peak @ (%d, %d) = %g", (
int)xposmax,
3217 (
int)yposmax, valmax);
3221 gauss_parameters = cpl_array_new(7, CPL_TYPE_DOUBLE);
3222 cpl_array_set_double(gauss_parameters, 0, median);
3224 code = cpl_fit_image_gaussian(self, NULL, xposmax, yposmax,
3225 winsize, winsize, gauss_parameters,
3230 const double M_x = cpl_array_get_double(gauss_parameters, 3, NULL);
3231 const double M_y = cpl_array_get_double(gauss_parameters, 4, NULL);
3232 const double SIGMA_x = cpl_array_get_double(gauss_parameters, 5, NULL);
3233 const double SIGMA_y = cpl_array_get_double(gauss_parameters, 6, NULL);
3234 valfit = cpl_gaussian_eval_2d(gauss_parameters, M_x, M_y);
3235 if (!cpl_errorstate_is_equal(prestate)) {
3236 code = cpl_error_get_code();
3244 cpl_msg_debug(cpl_func,
"Gauss-fit @ (%g, %g) = %g, SIGMA: (%g, %g)",
3251 cpl_array_delete(gauss_parameters);
3253 if (code || valfit < valmax) {
3254 cpl_errorstate_set(prestate);
3260 return code ? cpl_error_set_where(cpl_func) : CPL_ERROR_NONE;
3275 const char* context){
3277 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
3278 cpl_ensure(parlist != NULL, CPL_ERROR_NULL_INPUT, NULL);
3279 cpl_ensure(context != NULL, CPL_ERROR_NULL_INPUT, NULL);
3295 cpl_propertylist* qchead = cpl_propertylist_new();
3296 eris_gaussian_maxpos(image, 5, &max_x, &max_y, &peak, &sigma_x, &sigma_y);
3297 FWHM_x = sigma_x * CPL_MATH_FWHM_SIG;
3298 FWHM_y = sigma_y * CPL_MATH_FWHM_SIG;
3299 cpl_msg_info(cpl_func,
"max_x: %g max_y: %g FWHM_x:%g FWHM_y: %g",
3300 max_x, max_y, FWHM_x, FWHM_y);
3302 if(cpl_error_get_code() != CPL_ERROR_NONE) {
3303 cpl_msg_error(cpl_func,
"Error fitting 2D Gaussian to object for QC. Exit");
3308 int max_ima_x = (int) (max_x + 0.5);
3309 int max_ima_y = (int) (max_y + 0.5);
3312 int wllx = ((max_ima_x - psf_sz)>0) ? (max_ima_x - psf_sz) : 1;
3313 int wlly = ((max_ima_y - psf_sz)>0) ? (max_ima_y - psf_sz) : 1;
3314 int wurx = ((max_ima_x + psf_sz)<ima_szx) ? (max_ima_x + psf_sz) : ima_szx ;
3315 int wury = ((max_ima_y + psf_sz)<ima_szy) ? (max_ima_y + psf_sz) : ima_szy ;
3337 double* pdata = cpl_image_get_data_double(image);
3338 cpl_size npix = cpl_image_get_size_x(image) * cpl_image_get_size_y(image);
3339 cpl_boolean has_nan = CPL_FALSE;
3340 for(cpl_size i =0; i < npix; i++ ) {
3347 cpl_bivector * biv = NULL;
3348 if(has_nan == CPL_FALSE) {
3349 cpl_image* fimage = cpl_image_cast(image, CPL_TYPE_FLOAT);
3351 biv = cpl_image_iqe(fimage, wllx, wlly, wurx, wury);
3352 cpl_image_delete(fimage);
3355 if( (cpl_error_get_code() == CPL_ERROR_NONE) && (has_nan == CPL_FALSE)) {
3356 const double * x = cpl_bivector_get_x_data_const(biv);
3358 "[pix] STD star X centroid position");
3360 "[pix] STD star Y centroid position");
3362 "[pix] STD star FWHM on major axis");
3364 "[pix] STD star FWHM on minor axis");
3366 "[deg] STD star ellipsis angle theta");
3367 cpl_bivector_delete(biv);
3370 "[pix] STD star X centroid position");
3372 "[pix] STD star Y centroid position");
3374 "[pix] STD star FWHM on major axis");
3376 "[pix] STD star FWHM on minor axis");
3381 double xcen = max_x;
3382 double ycen = max_y;
3383 if (has_nan == CPL_FALSE) {
3392 double fwhm_factor = 5.0;
3394 char* pname = cpl_sprintf(
"%s.fwhm-factor",context);
3398 double red_chisq = 0;
3399 cpl_matrix* covariance = NULL;
3403 cpl_array* fit_params = NULL;
3404 cpl_array* gauss2d_fit_params = cpl_array_new(7, CPL_TYPE_DOUBLE);
3405 cpl_array* gauss2d_err_params = cpl_array_new(7, CPL_TYPE_DOUBLE);
3406 cpl_matrix* phys_cov = NULL;
3409 if(CPL_ERROR_NONE == cpl_fit_image_gaussian(image, error,
3410 max_ima_x, max_ima_y, psf_sz, psf_sz, gauss2d_fit_params,
3411 gauss2d_err_params, fit_params, &rms, &red_chisq, &covariance,
3412 &major, &minor, &angle, &phys_cov) ) {
3413 sigma_x = cpl_array_get(gauss2d_fit_params, 5, &status);
3414 sigma_y = cpl_array_get(gauss2d_fit_params, 6, &status);
3416 fwhm_x = sigma_x * CPL_MATH_FWHM_SIG;
3417 fwhm_y = sigma_y * CPL_MATH_FWHM_SIG;
3419 "[pix] STD star FWHM on X");
3421 "[pix] STD star FWHM on Y");
3423 halfbox_x = (floor)(0.5 * (fwhm_x + fwhm_y) * fwhm_factor + 0.5);
3425 halfbox_y = (floor)(0.5 * (fwhm_x + fwhm_y) * fwhm_factor + 0.5);
3430 cpl_array_delete(gauss2d_fit_params);
3431 cpl_array_delete(gauss2d_err_params);
3438 "[pix] STD star FWHM on X");
3440 "[pix] STD star FWHM on Y");
3455 llx = (int)(xcen - halfbox_x);
3456 llx = (llx > 0 ) ? llx : 1;
3458 if((llx + 2 * halfbox_x) >= ima_szx) {
3459 halfbox_x = (int) ((ima_szx - llx - 1) / 2);
3463 lly = (int)(ycen - halfbox_y);
3464 lly = (lly > 0 ) ? lly : 1;
3465 if((lly + 2 * halfbox_y) >= ima_szy) {
3466 halfbox_y = (int) ((ima_szy - lly - 1) / 2);
3470 "Check on evaluation box");
3473 cpl_table_delete(qclog_tbl);
3479static cpl_error_code
3480eris_imagelist_reject_value(hdrl_imagelist* iml)
3483 cpl_ensure(iml != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3487 for(cpl_size i = 0; i < sz; i++) {
3491 return cpl_error_get_code();
3505 cpl_mask* mask_obj = NULL;
3511 cpl_image* ima_tmp = cpl_image_duplicate(image);
3514 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
3515 cpl_ensure(0.25 <= percent && percent <= 0.75, CPL_ERROR_ILLEGAL_INPUT, NULL);
3516 double* data = cpl_image_get_data(ima_tmp);
3518 cpl_size npoints = sx * sy;
3519 cpl_ensure(npoints > 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
3520 cpl_vector* v = cpl_vector_new(npoints);
3521 v = cpl_vector_wrap(npoints, data);
3523 cpl_vector_sort(v, CPL_SORT_ASCENDING);
3525 cpl_size thresh_pos = percent * npoints;
3526 double threshold_max = cpl_vector_get(v, thresh_pos);
3528 cpl_vector_unwrap(v);
3529 cpl_image_delete(ima_tmp);
3530 mask_obj = cpl_mask_threshold_image_create(image, DBL_MIN, threshold_max);
3531 cpl_mask_not(mask_obj);
3533 cpl_vector_delete(v);
3552 cpl_mask* mask_tmp = NULL;
3553 cpl_mask* mask_obj = NULL;
3554 hdrl_value median = {0, 0};
3558 cpl_ensure(hima != NULL, CPL_ERROR_NULL_INPUT, NULL);
3559 cpl_ensure(1 <= niter && niter <= 100, CPL_ERROR_ILLEGAL_INPUT, NULL);
3560 cpl_ensure(kappa > 0., CPL_ERROR_ILLEGAL_INPUT, NULL);
3564 for (cpl_size i = 0; i < niter; i++) {
3566 if (!isnan(median.data)) {
3568 double thresh_max = median.data + kappa * stdev;
3569 cpl_msg_info(cpl_func,
"median: %g stdev: %g thresh: %g max: %g",
3570 median.data, stdev, thresh_max, max);
3571 thresh_max = (thresh_max < max) ? thresh_max : 0.99 * max;
3572 cpl_msg_info(cpl_func,
"median: %g stdev: %g thresh: %g max: %g",
3573 median.data, stdev, thresh_max, max);
3578 mask_tmp = cpl_mask_threshold_image_create(ima_tmp, DBL_MIN, thresh_max);
3579 cpl_mask_not(mask_tmp);
3583 if (i == (niter -1)) {
3584 mask_obj = cpl_mask_duplicate(mask_tmp);
3586 cpl_mask_delete(mask_tmp);
3607 cpl_ensure(iml != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3608 cpl_ensure(qclog_tbl != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3609 cpl_ensure(*qclog_tbl != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
3610 cpl_ensure(n >= 0, CPL_ERROR_ILLEGAL_INPUT, CPL_ERROR_ILLEGAL_INPUT);
3612 cpl_size max_ima_x = 0;
3613 cpl_size max_ima_y = 0;
3620 double max_ima_cx = 0;
3621 double max_ima_cy = 0;
3623 hdrl_image* himg = NULL;
3624 cpl_image* img_dup = NULL;
3625 cpl_image* contrib_map = NULL;
3628 eris_imagelist_reject_value(iml);
3636 cpl_image_get_maxpos(img_dup, &max_ima_x, &max_ima_y);
3637 max_ima_cx = cpl_image_get_centroid_x_window(img_dup, 1, 1, nx, ny);
3638 max_ima_cy = cpl_image_get_centroid_y_window(img_dup, 1, 1, nx, ny);
3642 xshift = max_ima_cx - (double)nx/2;
3643 yshift = max_ima_cy - (double)ny/2;
3645 key_name = cpl_sprintf(
"QC PUPIL%d SHIFTX", n);
3648 "X shift centroid - center image");
3650 key_name = cpl_sprintf(
"QC PUPIL%d SHIFTY", n);
3652 "Y shift centroid - center image");
3653 cpl_msg_info(cpl_func,
"xshift: %g yshift: %g",xshift, yshift);
3656 cpl_image_delete(contrib_map);
3658 return cpl_error_get_code();
3674 cpl_mask *mask = NULL;
3675 const double *pimg_mask = NULL;
3676 cpl_binary *pmask = NULL;
3678 cpl_ensure(img_mask != NULL, CPL_ERROR_NULL_INPUT, NULL);
3681 nx = cpl_image_get_size_x(img_mask);
3682 ny = cpl_image_get_size_y(img_mask);
3685 mask = cpl_mask_new(nx,ny));
3687 pimg_mask = cpl_image_get_data_double_const(img_mask));
3689 pmask = cpl_mask_get_data(mask));
3691 for (cpl_size x = 0; x < nx; x++) {
3692 for (cpl_size y = 0; y < ny; y++) {
3693 if (pimg_mask[x+nx*y] > 0.5) {
3695 pmask[x+nx*y] = GOOD_PIX;
3698 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)
Load a raw detector exposure from file with corrections and noise.
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)
Save table for debugging (quick, no DFS overhead)
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 with mask for debugging.
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 with DFS compliance.
cpl_error_code eris_ifu_save_imagelist_dbg(const cpl_imagelist *imglist, const char *filename, int create)
Save CPL imagelist for debugging (quick, no DFS overhead)
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)
Convert lamp status bitmask to string.
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 for debugging (quick, no DFS overhead)
cpl_error_code eris_ifu_save_image_dbg(const cpl_image *img, const char *filename, int create, const cpl_propertylist *pl)
Save image for debugging (quick, no DFS overhead)
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 eris_ifu_vector for debugging (quick, no DFS overhead)
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 HDRL image.
const char * eris_ifu_get_bandString(ifsBand band)
Convert band enum to string.
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 mask to HDRL image (reject masked pixels)
cpl_error_code eris_ifu_file_exists(const char *filename)
**
cpl_error_code eris_ifu_get_plane_cut_min_max(ifsBand band, cpl_size *zmin, cpl_size *zmax)
Get band-specific plane indices for NaN trimming.
const char * eris_ifu_get_instrumentString(ifsInstrument instrument)
Convert instrument enum to string.
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 for debugging (as vector or table)
cpl_imagelist * eris_ifu_hdrl_get_imagelist(const hdrl_imagelist *hdrl_imglist, enum hdrl_t type)
Extract from an HDRL imagelist a specific CPL imagelist.
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)
Add bad pixel border around mask.
cpl_image * eris_ifu_image_create_window(const cpl_image *img)
Create sub-image by removing bad pixel 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)
Save mask for debugging (quick, no DFS overhead)
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 known 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)
Set specific pixel values in HDRL imagelist (debugging utility)
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 and Infs in CPL imagelist (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)
Save HDRL imagelist for debugging (data + error + mask planes)
cpl_error_code eris_ifu_save_cpl_imagelist_dbg(const cpl_imagelist *imglist, const char *name)
Save CPL imagelist for debugging.
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 image for debugging (data + error + mask)
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)
Trim NaN-dominated planes from cube edges.
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)
Convert pre-optics scale enum to string.
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 with DFS compliance.
double eris_ifu_get_band_resolution(ifsBand band)
Get nominal spectral resolution for a given band.
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
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().
int eris_ifu_is_nan_or_inf(double A)
Checks if a value is nan, inf or -inf.
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