45#include <irplib_utils.h>
47#include "eris_ifu_dfs.h"
48#include "eris_ifu_error.h"
49#include "eris_ifu_debug.h"
50#include "eris_ifu_functions.h"
51#include "eris_ifu_utils.h"
52#include "eris_ifu_distortion_static.h"
53#include "eris_ifu_flat_static.h"
54#include "eris_utils.h"
58static char eris_ifu_distortion_description[] =
"\
59This recipe determines the optical distortions and the slitlets distances.\n\
61-----------------------------------------------------------------------------\n\
63 DO CATG Explanation Required #Frames\n\
64 ------- ----------- -------- -------\n\
65 FIBRE_NS Fibre exposures Y [1,75]\n\
66 FLAT_NS Flatlamp on/off exposures Y 2 \n\
67 WAVE_NS Arclamp on/off exposures Y >=2 \n\
68 DARK_NS Dark exposure N [0,1]\n\
69 REF_LINE_ARC Band-specific reference arc line list Y 1 \n\
70 WAVE_SETUP Table to configure wave calibration Y 1 \n\
71 FIRST_WAVE_FIT Table for the first attempt to fit ARClines Y 1 \n\
74 DO CATG Explanation\n\
75 ------- -----------\n\
76 DISTANCES Table with slitlet distances\n\
77 BPM_DIST Badpixel frame\n\
78 SLITLET_POS Table with slitlet edge positions\n\
79 DISTORTION Table with parameters for distortion correction\n\
80 REF_LINE_ARC Table reference arc line values\n\
81 WAVE_SETUP Table with guess wavelength calib solution values\n\
82 FIRST_WAVE_FIT Table with first fit solution\n\
83-----------------------------------------------------------------------------\n\
85Information on relevant parameters may be found with\n\
86 esorex --params "REC_NAME_DISTORTION
"\n\
87 esorex --help "REC_NAME_DISTORTION
"\n";
92cpl_recipe_define(eris_ifu_distortion, ERIS_BINARY_VERSION,
"Alex Agudo Berbel",
93 PACKAGE_BUGREPORT,
"2019",
94 "This recipe performs distortion correction",
95 eris_ifu_distortion_description);
97cpl_error_code eris_ifu_dist_save_aux_products(
98 cpl_frameset *frameset,
99 const cpl_parameterlist *parlist,
100 cpl_propertylist *pl,
101 cpl_polynomial **distortion_poly,
102 cpl_table *minmax_borders,
103 hdrl_image *fibre_div_img );
117static cpl_error_code eris_ifu_distortion_fill_parameterlist(cpl_parameterlist *pl)
119 cpl_error_code err = CPL_ERROR_NONE;
120 cpl_parameter *p = NULL;
122 cpl_ensure_code(pl, CPL_ERROR_NULL_INPUT);
133 p = cpl_parameterlist_find(pl,
134 "eris.eris_ifu_distortion.instrument"));
136 cpl_parameter_set_default_string(p,
"NONE"));
144 p = cpl_parameterlist_find(pl,
145 "eris.eris_ifu_distortion.collapse.method"));
147 cpl_parameter_set_default_string(p,
"MEAN"));
155 p = cpl_parameter_new_value(
156 "eris.eris_ifu_distortion.distortion.arcs.thresh_factor",
158 "median_value(image)+ kappa*sigma is the minimum intensity "
159 "threshold of accepted image pixels",
160 "eris_ifu_distortion.distortion.arcs",
163 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
164 "distortion.arcs.thresh_factor"));
166 cpl_parameterlist_append(pl, p));
169 p = cpl_parameter_new_value(
170 "eris.eris_ifu_distortion.distortion.arcs.min_arclen_factor",
172 "factor which sets minimum arc length (1.0-2)",
173 "eris_ifu_distortion.distortion.arcs",
176 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
177 "distortion.arcs.min_arclen_factor"));
179 cpl_parameterlist_append(pl, p));
182 p = cpl_parameter_new_value(
183 "eris.eris_ifu_distortion.distortion.arcs.window_size",
185 "Size of window for low pass filter used in an horizontal "
186 "low pass filter to remove unwanted arcs (5-64)",
187 "eris_ifu_distortion.distortion.arcs",
190 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
191 "distortion.arcs.window_size"));
193 cpl_parameterlist_append(pl, p));
196 p = cpl_parameter_new_value(
197 "eris.eris_ifu_distortion.distortion.smooth_rad",
199 "Size of smoothing factor (1-11) used to prevent for "
200 "possible intensity drops from detector electronics on "
201 "fibre illuminated slitlets (1-11)",
202 "eris_ifu_distortion.distortion",
205 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"distortion.smooth_rad"));
207 cpl_parameterlist_append(pl, p));
210 p = cpl_parameter_new_value(
211 "eris.eris_ifu_distortion.wave.div",
213 "Divide masterflat from subtracted wave frame",
214 "eris_ifu_distortion.wave",
217 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
220 cpl_parameterlist_append(pl, p));
223 BRK_IF_NULL(p = cpl_parameter_new_value(
"eris.eris_ifu_distortion.pixel_saturation",
224 CPL_TYPE_DOUBLE,
"Pixel saturation level ",
225 "eris_ifu_distortion", 18000.));
226 BRK_IF_ERROR(cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
227 "pixel_saturation"));
228 cpl_parameterlist_append(pl, p);
233 err = cpl_error_get_code();
249eris_ifu_distortion(cpl_frameset *frameset,
const cpl_parameterlist *parlist)
251 int productDepth = 0;
253 const char *instr_tmp;
254 const char *fn = NULL,
259 cpl_image *qualityImage = NULL,
263 const cpl_image *masterFlatImage = NULL;
264 cpl_frameset *frameset_flat = NULL,
265 *frameset_fibre = NULL;
266 const cpl_frame *fr = NULL;
267 cpl_boolean cut_off_left = FALSE,
268 cut_off_right = FALSE;
269 int do_wave_flat_div = FALSE;
270 cpl_mask *bp_mask_flat = NULL;
271 cpl_polynomial **distortion_poly = NULL,
272 **distortion_poly_full = NULL;
273 hdrl_image *masterFlatHdrlImg_lo = NULL,
275 *fibre_on_img = NULL,
276 *fibre_div_img = NULL,
278 *warped_img_wave = NULL,
279 *warped_img_full = NULL,
281 *wave_off_img = NULL;
282 hdrl_imagelist *fibre_imglist = NULL,
283 *wave_imglist = NULL,
286 hdrl_parameter *pcollapse = NULL;
287 cpl_table **centers_fitted = NULL,
289 *minmax_borders = NULL,
290 *valid_arc_lines = NULL;
291 cpl_propertylist **qc = NULL,
294 cpl_table *qclog = NULL;
295 cpl_imagelist *tmpImgList = NULL;
296 flatMode mode = FLAT_MODE_NONE;
297 ifsPreopticsScale scale = UNDEFINED_SCALE;
299 cpl_ensure_code(frameset, CPL_ERROR_NULL_INPUT);
300 cpl_ensure_code(parlist, CPL_ERROR_NULL_INPUT);
301 cpl_ensure_code(cpl_frameset_is_empty(frameset) == FALSE,
302 CPL_ERROR_NULL_INPUT);
323 cpl_ensure_code(cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FIBRE_NS) >= 1,
324 CPL_ERROR_ILLEGAL_INPUT);
325 cpl_ensure_code((cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS) == 2) ||
326 (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS_ON) == 1 &&
327 cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS_OFF)),
328 CPL_ERROR_ILLEGAL_INPUT);
329 cpl_ensure_code((cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS) >= 2) ||
330 (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS_ON) >= 1 &&
331 cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS_OFF) >= 1),
332 CPL_ERROR_ILLEGAL_INPUT);
341 instrument = cpl_parameter_get_string(
342 cpl_parameterlist_find_const(parlist,
343 "eris.eris_ifu_distortion.instrument")));
346 fr = cpl_frameset_find_const(frameset, ERIS_IFU_RAW_FIBRE_NS));
348 fn = cpl_frame_get_filename(fr));
350 pl = cpl_propertylist_load(fn, 0));
356 if (strcmp(instrument, INSTRUMENT_NONE) == 0) {
358 ins = cpl_propertylist_get_string(pl,
"INSTRUME"));
359 if (strcmp(ins, INSTRUMENT_SINFONI) == 0) {
362 band = cpl_propertylist_get_string(pl, FHDR_S_FILTER_NAME));
364 if ((strcmp(band, S_GRATING_H_BAND) == 0) ||
365 (strcmp(band, S_GRATING_J_BAND) == 0))
367 instr_tmp = INSTRUMENT_SINFONI;
369 instr_tmp = INSTRUMENT_ERIS;
373 instr_tmp = INSTRUMENT_ERIS;
378 instr_tmp = instrument;
381 cpl_msg_info(cpl_func,
"Processing %s frames", instr_tmp);
386 cpl_msg_info(cpl_func,
"Band: %s, scale: %s", band,
397 productDepth = cpl_parameter_get_int(
398 cpl_parameterlist_find_const(parlist,
399 "eris.eris_ifu_distortion.product_depth"));
403 const char *collapse_method = NULL;
405 collapse_method = cpl_parameter_get_string(
406 cpl_parameterlist_find_const(parlist,
407 "eris.eris_ifu_distortion.collapse.method")));
408 if (strcmp(collapse_method,
"MINMAX") == 0) {
410 "collapse.method == MINMAX isn't allowed");
418 if (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS) > 0) {
420 ERIS_IFU_RAW_FLAT_NS);
421 }
else if ( (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS_ON) > 0) &&
422 (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_FLAT_NS_OFF) > 0) ) {
423 cpl_frameset* frameset_flat_off = NULL;
428 cpl_frameset_join(frameset_flat, frameset_flat_off);
429 cpl_frameset_delete(frameset_flat_off);
433 if (cpl_frameset_count_tags(frameset, ERIS_IFU_CALIB_FLATFIELD) != 0) {
438 cpl_msg_info(cpl_func,
"Using ERIS_IFU_CALIB_FLATFIELD and"
439 "ERIS_IFU_PRO_FLAT_BPM");
443 fn1 = cpl_frame_get_filename(
444 cpl_frameset_find_const(frameset, ERIS_IFU_CALIB_FLATFIELD));
445 cpl_image *flatFieldImg = cpl_image_load(fn1, CPL_TYPE_DOUBLE, 0, 0);
446 if (cpl_frameset_count_tags(frameset, ERIS_IFU_PRO_FLAT_BPM) != 0) {
447 fn1 = cpl_frame_get_filename(
448 cpl_frameset_find_const(frameset, ERIS_IFU_PRO_FLAT_BPM));
449 bp_mask_flat = cpl_mask_load(fn1, 0, 0);
450 cpl_image_set_bpm(flatFieldImg, bp_mask_flat);
452 cpl_image *ffErrorImg = cpl_image_new(2048, 2048, CPL_TYPE_DOUBLE);
454 cpl_image_delete(flatFieldImg);
455 cpl_image_delete(ffErrorImg);
457 qc_list = cpl_propertylist_new());
460 const char *tmp = cpl_parameter_get_string(
461 cpl_parameterlist_find_const(parlist,
462 "eris.eris_ifu_distortion.mode"));
463 if (!strcmp(tmp, flatModes[0])) {
464 mode = FLAT_MODE_SEGMENT;
465 }
else if (!strcmp(tmp, flatModes[1])) {
466 mode = FLAT_MODE_HDRL;
467 }
else if (!strcmp(tmp, flatModes[2])) {
468 mode = FLAT_MODE_FAST;
475 eris_ifu_flat_static(frameset_flat,
479 ERIS_IFU_PRO_DIST_DBG_MASTER_FLAT_LAMP,
484 &masterFlatHdrlImg_lo,
494 if ((masterFlatImage != NULL) && (errorImage != NULL) &&
495 (qualityImage != NULL) && ((productDepth & 1) != 0))
498 cpl_propertylist_set_string(qc_list, CPL_DFS_PRO_CATG,
499 ERIS_IFU_PRO_DIST_DBG_MASTER_FLAT_LAMP));
505 ERIS_IFU_PRO_DIST_DBG_MASTER_FLAT_LAMP_FN,
506 masterFlatImage, errorImage, rmse,
507 qualityImage, flag16bit, UNITLESS));
515 if (bp_mask_flat != NULL) {
517 bp_img_flat = cpl_image_new_from_mask(bp_mask_flat));
523 ERIS_IFU_PRO_DIST_BPM,
524 ERIS_IFU_PRO_DIST_BPM_FN,
535 qc_list = cpl_propertylist_new());
538 fr = cpl_frameset_find_const(frameset, ERIS_IFU_RAW_DARK_NS);
541 fn = cpl_frame_get_filename(fr));
546 if (bp_mask_flat != NULL) {
550 if ((productDepth & 1) != 0) {
553 ERIS_IFU_PRO_DIST_DBG_DARK_FN,
561 cpl_msg_info(cpl_func,
"Performing fibre-exposure calculation...");
566 ERIS_IFU_RAW_FIBRE_NS));
568 if (cpl_propertylist_has(pl, FHDR_DPR_TYPE)) {
570 dpr_type = cpl_propertylist_get_string(pl, FHDR_DPR_TYPE));
572 if ((strcmp(dpr_type,
"NS,SLIT") != 0) &&
573 (cpl_frameset_get_size(frameset_fibre) < 75))
576 cpl_msg_warning(cpl_func,
"Normally 75 FIBRE_NS frames are provided!"
578 (
int)cpl_frameset_get_size(frameset_fibre));
585 fr = cpl_frameset_find_const(frameset_fibre,
586 ERIS_IFU_RAW_FIBRE_NS));
590 fn = cpl_frame_get_filename(fr));
595 if (bp_mask_flat != NULL) {
604 fr = cpl_frameset_find_const(frameset_fibre, NULL);
609 parlist,
"eris.eris_ifu_distortion.collapse");
612 &fibre_on_img, &contribMap));
616 if (productDepth & 1) {
619 ERIS_IFU_PRO_DIST_DBG_STACKED_ON_FN,
623 if (dark_img != NULL) {
637 if ((productDepth & 1) != 0) {
640 ERIS_IFU_PRO_DIST_DBG_STACKED_FN,
647 cpl_msg_info(cpl_func,
"Performing wave-cal calculation...");
648 cpl_frameset* frameset_wave = NULL;
649 if (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS) > 0) {
651 ERIS_IFU_RAW_WAVE_NS);
652 }
else if ( (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS_ON) > 0) &&
653 (cpl_frameset_count_tags(frameset, ERIS_IFU_RAW_WAVE_NS_OFF) > 0) ) {
655 cpl_frameset* frameset_wave_off = NULL;
660 cpl_frameset_join(frameset_wave, frameset_wave_off);
661 cpl_frameset_delete(frameset_wave_off);
668 cpl_size frameCnt = cpl_frameset_get_size(frameset_wave);
669 for (cpl_size i = 0 ; i < frameCnt ; i++) {
671 fr = cpl_frameset_get_position_const(frameset_wave, i) ;
672 fn = cpl_frame_get_filename(fr);
677 if (bp_mask_flat != NULL) {
682 if (wave_off_img != NULL) {
686 wave_off_img = tmp_img;
694 cpl_frameset_delete(frameset_wave);
698 parlist,
"eris.eris_ifu_distortion.collapse");
701 &wave_on_img, &contribMap));
705 if ((productDepth & 2) != 0) {
707 "eris_ifu_distortion_dbg_wave_on",
710 "eris_ifu_distortion_dbg_wave_off",
719 if ((productDepth & 2) != 0) {
721 "eris_ifu_distortion_dbg_wave_sub",
726 do_wave_flat_div = cpl_parameter_get_bool(
727 cpl_parameterlist_find_const(parlist,
728 "eris.eris_ifu_distortion.wave.div"));
731 if (do_wave_flat_div) {
736 if ((productDepth & 2) != 0) {
738 "eris_ifu_distortion_dbg_wave_div",
746 cpl_msg_info(cpl_func,
"Performing trace detection of slit-mask/fibre...");
756 cpl_msg_info(cpl_func,
"Performing slitlet edge detection...");
759 cpl_image **arcImgs = NULL;
763 productDepth, &arcImgs, &arcImgCnt, parlist, &qclog));
770 &cut_off_left, &cut_off_right,
772 for (
int ix = 0; ix < arcImgCnt; ix++) {
773 cpl_image *tmpImg = arcImgs[ix];
780 cpl_msg_info(cpl_func,
"Performing calculation of distortion (slit)");
793 ERIS_IFU_PRO_DIST_DISTORTION_FN,
794 frameset, parlist, qc));
800 if (productDepth == PD_AUXILLIARY || productDepth == PD_DEBUG) {
802 eris_ifu_dist_save_aux_products(frameset, parlist, pl,
803 distortion_poly, minmax_borders, fibre_div_img));
805 if (productDepth & 4) {
806 cpl_msg_info(cpl_func,
"Distorting arc-frame by slitlet...") ;
814 ERIS_IFU_PRO_DIST_DBG_WARPED_WAVE,
815 ERIS_IFU_PRO_DIST_DBG_WARPED_WAVE_FN,
819 if (productDepth & 16) {
820 cpl_msg_info(cpl_func,
"Performing calculation of distortion (full)");
830 "eris_ifu_distortion_distortion_full.fits",
831 frameset, parlist, qc));
833 cpl_msg_info(cpl_func,
"Distorting fibre-frame full...") ;
836 distortion_poly_full,
842 ERIS_IFU_PRO_DIST_DBG_WARPED_FULL,
843 ERIS_IFU_PRO_DIST_DBG_WARPED_FULL_FN,
854 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FULL_FN, CPL_IO_CREATE));
864 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FULL_FN, CPL_IO_EXTEND));
875 cpl_table_delete(qclog);
902 if (centers_fitted != NULL) {
903 for (
int j = 0; j < SLITLET_CNT; j++) {
906 cpl_free(centers_fitted); centers_fitted = NULL;
908 if (slit_edges != NULL) {
909 for (
int j = 0; j < SLITLET_CNT; j++) {
912 cpl_free(slit_edges); slit_edges = NULL;
914 if (distortion_poly != NULL) {
915 for (
int j = 0; j < SLITLET_CNT; j++) {
918 cpl_free(distortion_poly); distortion_poly = NULL;
921 for (
int i = 0; i < SLITLET_CNT; i++) {
924 cpl_free(qc); qc = NULL;
927 return (
int) cpl_error_get_code();
945cpl_error_code eris_ifu_dist_save_aux_products(
946 cpl_frameset *frameset,
947 const cpl_parameterlist *parlist,
948 cpl_propertylist *pl,
949 cpl_polynomial **distortion_poly,
950 cpl_table *minmax_borders,
951 hdrl_image *fibre_div_img )
953 cpl_propertylist *qc_list = NULL;
954 cpl_image *tmp_cpl = NULL;
956 hdrl_image *warped_img = NULL,
958 hdrl_imagelist*cube = NULL;
962 qc_list = cpl_propertylist_new());
964 cpl_msg_info(cpl_func,
"Distorting fibre-frame by slitlet...") ;
973 ERIS_IFU_PRO_DIST_DBG_WARPED,
974 ERIS_IFU_PRO_DIST_DBG_WARPED_FN,
981 cpl_imagelist *tmpImgList = NULL;
986 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FN,
993 cpl_propertylist_set_string(pl,FHDR_PRO_CATG,
994 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FLAT_MEAN);
995 cpl_propertylist_set_string(pl,
"PIPEFILE",
996 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FLAT_MEAN_FN);
999 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FLAT_MEAN_FN,
1000 CPL_IO_CREATE, pl));
1013 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FN,
1023 ERIS_IFU_PRO_DIST_DBG_WARPED_CUBE_FLAT_MEAN_FN,
1024 CPL_IO_EXTEND, pl));
1037 return cpl_error_get_code();
ifsPreopticsScale eris_ifu_get_preopticsScale(cpl_propertylist *header)
Return the the pre-optics scaling.
cpl_error_code eris_ifu_dfs_set_groups(cpl_frameset *self)
Set the frame group (RAW, CALIB, or PRODUCT) for all frames in a frameset.
cpl_error_code eris_ifu_save_deq_image(cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const char *recipe, const cpl_propertylist *applist, const char *remregexp, const char *filename, const cpl_image *image, const cpl_image *error, deqErrorType errorType, const cpl_image *dataQualityMask, deqQualityType dataQualityType, const char *unit)
Save a DFS-compliant image product with data, error, and quality extensions.
ifsBand eris_ifu_get_band(const cpl_propertylist *header)
Determine preoptic band.
bool eris_ifu_frame_is_on(const cpl_frame *fr)
Determine if a frame has calibration lamps ON or OFF.
cpl_error_code eris_ifu_dist_warp_stats(const hdrl_image *hdrlWarpedImg, cpl_propertylist *qc_list, cpl_propertylist *pl, cpl_frameset *frameset, const cpl_parameterlist *parlist)
Compute QC statistics on warped image.
hdrl_image * eris_ifu_dist_warp_image_full(const hdrl_image *hdrl_img_in, cpl_polynomial **poly_u, int productDepth)
Warp full image using distortion polynomials (alternative method)
cpl_table ** eris_ifu_dist_calc_centers(const hdrl_image *fibre_div, const hdrl_image *fibre_on, int productDepth)
Calculate slitlet centers across the detector.
hdrl_image * eris_ifu_dist_warp_image(const hdrl_image *imgIn, cpl_polynomial **poly_u, const cpl_table *borders)
Warp full detector image by warping each slitlet.
cpl_error_code eris_ifu_dist_save_distortion(cpl_polynomial **poly2d, const cpl_table *minmax_borders, const char *fn, cpl_frameset *frameset, const cpl_parameterlist *parlist, cpl_propertylist **qc)
Save distortion polynomials to FITS file.
cpl_table ** eris_ifu_dist_calc_slitpos(cpl_image **arcImg, cpl_table **centers_array, cpl_table *valid_arc_lines, int productDepth, cpl_boolean *cut_off_left, cpl_boolean *cut_off_right, const cpl_frameset *frameset, const cpl_parameterlist *parlist)
Calculate slitlet edge positions from arc lamp images.
cpl_polynomial ** eris_ifu_dist_calc_distortion(cpl_table **slit_edges, cpl_table **centers, int productDepth, cpl_boolean cut_off_left, cpl_boolean cut_off_right, cpl_table **minmax_borders, cpl_propertylist ***qc, cpl_propertylist *pl, cpl_frameset *frameset, const cpl_parameterlist *parlist)
Calculate distortion polynomials for all slitlets.
cpl_table * eris_ifu_dist_wave(cpl_frameset *fs, cpl_table **centers_fitted, int productDepth, cpl_image ***arcImgs, int *imgCnt, const cpl_parameterlist *parlist, cpl_table **qclog)
Perform wavelength calibration to identify valid arc lines.
hdrl_imagelist * eris_ifu_stack_warped(const hdrl_image *imgIn, const int *rowIx)
Stack warped image into cube format.
cpl_polynomial ** eris_ifu_dist_calc_distortion_full(cpl_table **slit_edges, cpl_table **centers, int productDepth, cpl_boolean cut_off_left, cpl_boolean cut_off_right)
Calculate distortion polynomials (alternative method)
#define SET_ERROR_MSG(code, msg)
Set a new error code together with a custom error message.
#define BRK_IF_ERROR(function)
If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
#define 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 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.
cpl_error_code eris_parlist_config_add_flat(cpl_parameterlist *pl, const char *recname)
Add flat field configuration parameters to parameter list.
cpl_error_code eris_parlist_config_add_all_recipes(cpl_parameterlist *pl, const char *recname)
Add common configuration parameters for all recipes.
cpl_error_code eris_parlist_config_add_bpm(cpl_parameterlist *pl, const char *recname)
Add bad pixel mask configuration parameters to parameter list.
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_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.
void eris_ifu_free_string(char **item)
Free memory and set pointer to null.
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.
const char * eris_ifu_get_bandString(ifsBand band)
Convert band enum to string.
cpl_error_code eris_ifu_file_exists(const char *filename)
**
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.
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.
void eris_ifu_free_imagelist(cpl_imagelist **item)
Free memory and set pointer to null.
void eris_ifu_free_hdrl_imagelist(hdrl_imagelist **item)
Free memory and set pointer to null.
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)
void eris_ifu_free_hdrl_image(hdrl_image **item)
Free memory and set pointer to null.
void eris_ifu_free_image(cpl_image **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.
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.
void eris_ifu_free_hdrl_parameter(hdrl_parameter **item)
Free memory and set pointer to null.
hdrl_parameter * hdrl_collapse_parameter_parse_parlist(const cpl_parameterlist *parlist, const char *prefix)
parse parameterlist for imagelist reduction method
cpl_error_code hdrl_image_sub_image(hdrl_image *self, const hdrl_image *other)
Subtract two images, store the result in the first image.
cpl_error_code hdrl_image_reject_from_mask(hdrl_image *self, const cpl_mask *map)
set bpm of hdrl_image
cpl_error_code hdrl_image_div_image(hdrl_image *self, const hdrl_image *other)
Divide two images, store the result in the first image.
hdrl_image * hdrl_image_duplicate(const hdrl_image *himg)
copy hdrl_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
hdrl_image * hdrl_image_create(const cpl_image *image, const cpl_image *error)
create a new hdrl_image from to existing images by copying them
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
cpl_error_code hdrl_imagelist_collapse_mean(const hdrl_imagelist *himlist, hdrl_image **out, cpl_image **contrib)
Mean collapsing of image list.
cpl_error_code hdrl_imagelist_set(hdrl_imagelist *himlist, hdrl_image *himg, cpl_size pos)
Insert an image into an imagelist.
cpl_size hdrl_imagelist_get_size(const hdrl_imagelist *himlist)
Get the number of images in the imagelist.
cpl_error_code hdrl_imagelist_collapse(const hdrl_imagelist *himlist, const hdrl_parameter *param, hdrl_image **out, cpl_image **contrib)
collapsing of image list
hdrl_imagelist * hdrl_imagelist_new(void)
Create an empty imagelist.