2#ifndef ERISP_ERIS_ERIS_IFU_COMBINE_STATIC_H_
3#define ERISP_ERIS_ERIS_IFU_COMBINE_STATIC_H_
9#define MAX_NAME_SIZE 512
10#define KEY_NAME_MJD_OBS "MJD-OBS"
13#define TABSPERPIX (1000)
14#define KERNEL_WIDTH (2.0)
15#define KERNEL_SAMPLES (1+(int)(TABSPERPIX * KERNEL_WIDTH))
16#define TANH_STEEPNESS (5.0)
18#define EXTNAME_DATA "DATA"
19#define EXTNAME_DQ "CONTRIB"
20#define EXTNAME_ERROR "ERROR"
21#define EXTNAME_DATA_COMMENT "This extension contains data values"
22#define EXTNAME_ERROR_COMMENT "This extension contains data errors"
23#define EXTNAME_DQ_COMMENT "This extension contains contribution values in seconds"
32#include <eris_ifu_vector.h>
34 cpl_image **imagesData,
35 cpl_image **imagesError,
38 cpl_image **mergedImageData,
39 cpl_image **mergedImageError,
40 cpl_image **mergedImageDIT,
44 const double *exptimes,
46 const char *compute_mode,
50 cpl_imagelist **cubesData,
52 const double *exptimes);
64 cpl_imagelist **cubesDataShifted,
65 cpl_image *mergedImgDIT,
69 const double *exptimes);
72 cpl_image **imagesDataShifted,
73 cpl_image **mergedCubeDIT_img,
76 const double *exptimes,
86 const double *exptimes,
87 cpl_image **mergedCubeData_img,
88 cpl_image **mergedCubeError_img,
89 cpl_image *mergedCubeDIT_img,
90 cpl_image **imagesDataShifted,
91 cpl_image **imagesErrorShifted,
92 const char *compute_mode,
93 const int pclip,
const int nx_out,
const int ny_out);
97 const int n_contributions,
98 const int x,
const int y,
102 const char *compute_mode,
106 cpl_image **imgMergedCubeError,
107 cpl_image *mergedImgDIT,
108 cpl_image **cubesDataShifted,
109 cpl_image **cubesErrorShifted,
110 const double *exptimes,
113 const char *compute_mode,
const int nx_out,
const int ny_out);
117 const int *llx,
const int *lly,
118 const int x,
const int y);
126 const float *offsetx,
const float *offsety,
127 float *min_offx,
float *max_offx,
128 float *min_offy,
float *max_offy);
134 const cpl_image *img_in,
135 const double shift_x,
136 const double shift_y,
137 const double *kernel);
143 eris_ifu_vector *data_vec,
144 eris_ifu_vector *error_vec,
145 const char *compute_mode);
148 const cpl_frameset *frameset,
149 cpl_image **imagesData,
150 cpl_image **imagesError,
153 bool subtract_background);
177enum extrapolationType {
191 const enum extrapolationType extrapolation);
void eris_ifu_combine_get_xy_min_max(const int nframes, const float *offsetx, const float *offsety, float *min_offx, float *max_offx, float *min_offy, float *max_offy)
eris_ifu_combine_get_xy_min_max
void eris_ifu_combine_convert_0_to_NaN_img(cpl_image *img)
eris_ifu_combine_convert_0_to_NaN_img
int eris_ifu_combine_nearest_int(const double x)
Determine the nearest integer to a specified real value.
cpl_error_code eris_ifu_combine_build_mask_cube(cpl_image **imagesDataShifted, cpl_image **mergedCubeDIT_img, const int *llx, const int *lly, const double *exptimes, int n_cubes, cpl_size nx_out, cpl_size ny_out)
Build the mask data cube.
int eris_ifu_combine_min_cube_size(const cpl_frameset *fs)
eris_ifu_combine_min_cube_size
double eris_ifu_combine_calc_error(eris_ifu_vector *data_vec, eris_ifu_vector *error_vec, const char *compute_mode)
Calculate error for coadded pixel.
cpl_error_code eris_ifu_combine_read_image_planes(const cpl_frameset *frameset, cpl_image **imagesData, cpl_image **imagesError, int z, int edge_trim, bool subtract_background)
Read image planes from a frameset.
cpl_error_code eris_ifu_combine_coadd_ks_clip_internal(cpl_image **cubesDataShifted, const int n_frames, const int n_contributions, const int x, const int y, int *llx, int *lly, const double kappa, cpl_vector **msk, const char *compute_mode, const int pclip)
Internal routine for kappa-sigma clipping at a single pixel.
cpl_image * eris_ifu_combine_shift_image_kmos(const cpl_image *img_in, double xshift, double yshift, const char *method, const enum extrapolationType extrapolation)
Shifts each image of an image cube.
cpl_image * eris_ifu_combine_shift_image(const cpl_image *img_in, const double shift_x, const double shift_y, const double *kernel)
Shift an image by a given (non-integer) 2d offset.
cpl_error_code eris_ifu_combine_divide_DIT(cpl_imagelist **cubesData, const int n_cubes, const double *exptimes)
Divide each cube in a list by its exposure time.
int eris_ifu_combine_calc_contributions(cpl_image **cubesDataShifted, const int n_cubes, const int *llx, const int *lly, const int x, const int y)
Calculate the number of frames contributing to a pixel.
cpl_error_code eris_ifu_combine_coadd(const int n_cubes, cpl_image **imgMergedCubeData, cpl_image **imgMergedCubeError, cpl_image *mergedImgDIT, cpl_image **cubesDataShifted, cpl_image **cubesErrorShifted, const double *exptimes, int *llx, int *lly, const char *compute_mode, const int nx_out, const int ny_out)
Compute weighted mean or median of shifted images.
cpl_error_code eris_ifu_combine_coadd_ks_clip(const int n_cubes, const double kappa, int *llx, int *lly, const double *exptimes, cpl_image **mergedCubeData_img, cpl_image **mergedCubeError_img, cpl_image *mergedCubeDIT_img, cpl_image **imagesDataShifted, cpl_image **imagesErrorShifted, const char *compute_mode, const int pclip, const int nx_out, const int ny_out)
Coadd images with kappa-sigma clipping.
cpl_error_code eris_ifu_combine_subtract_background(cpl_image *img, bool *warn)
Subtract spatial median from an image.
cpl_error_code eris_ifu_combine_jittered_images(cpl_image **imagesData, cpl_image **imagesError, int size_x, int size_y, cpl_image **mergedImageData, cpl_image **mergedImageError, cpl_image **mergedImageDIT, int n_cubes, const float *offsetx, const float *offsety, const double *exptimes, const double kappa, const char *compute_mode, const int pclip)
Combine jittered images into a merged image with optional kappa-sigma clipping.
cpl_error_code eris_ifu_combine_auto_size_cube(const float *offsetx, const float *offsety, const int nframes, float *ref_offx, float *ref_offy, int *size_x, int *size_y)
Computes size of coadded cube.
cpl_error_code eris_ifu_combine_build_mask(cpl_imagelist **cubesDataShifted, cpl_image *mergedImgDIT, const int n_cubes, const int *llx, const int *lly, const double *exptimes)
Build the mask data image.