ERIS Pipeline Reference Manual 1.8.15
eris_ifu_combine_static.h
1
2#ifndef ERISP_ERIS_ERIS_IFU_COMBINE_STATIC_H_
3#define ERISP_ERIS_ERIS_IFU_COMBINE_STATIC_H_
4
5#ifdef HAVE_CONFIG_H
6#include <config.h>
7#endif
8
9#define MAX_NAME_SIZE 512
10#define KEY_NAME_MJD_OBS "MJD-OBS"
11
12/* Number of tabulations in kernel */
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)
17
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"
24
25/*-----------------------------------------------------------------------------
26 Includes
27 -----------------------------------------------------------------------------*/
28
29#include <cpl.h>
30#include "hdrl.h"
31#include <stdbool.h>
32#include <eris_ifu_vector.h>
34 cpl_image **imagesData,
35 cpl_image **imagesError,
36 int size_x,
37 int size_y,
38 cpl_image **mergedImageData,
39 cpl_image **mergedImageError,
40 cpl_image **mergedImageDIT,
41 int n_cubes,
42 const float *offsetx,
43 const float *offsety,
44 const double *exptimes,
45 const double kappa,
46 const char *compute_mode,
47 const int pclip);
48
49cpl_error_code eris_ifu_combine_divide_DIT(
50 cpl_imagelist **cubesData,
51 const int n_cubes,
52 const double *exptimes);
53
55 const float *offsetx,
56 const float *offsety,
57 const int nframes,
58 float *ref_offx,
59 float *ref_offy,
60 int *size_x,
61 int *size_y);
62
63cpl_error_code eris_ifu_combine_build_mask(
64 cpl_imagelist **cubesDataShifted,
65 cpl_image *mergedImgDIT,
66 const int n_cubes,
67 const int *llx,
68 const int *lly,
69 const double *exptimes);
70
72 cpl_image **imagesDataShifted,
73 cpl_image **mergedCubeDIT_img,
74 const int *llx,
75 const int *lly,
76 const double *exptimes,
77 int n_cubes,
78 cpl_size nx_out,
79 cpl_size ny_out);
80
82 const int n_cubes,
83 const double kappa,
84 int *llx,
85 int *lly,
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);
94
95cpl_error_code eris_ifu_combine_coadd_ks_clip_internal(cpl_image **cubesDataShifted,
96 const int n_frames,
97 const int n_contributions,
98 const int x, const int y,
99 int *llx, int *lly,
100 const double kappa,
101 cpl_vector **msk,
102 const char *compute_mode,
103 const int pclip);
104
105cpl_error_code eris_ifu_combine_coadd(const int n_cubes, cpl_image **imgMergedCubeData,
106 cpl_image **imgMergedCubeError,
107 cpl_image *mergedImgDIT,
108 cpl_image **cubesDataShifted,
109 cpl_image **cubesErrorShifted,
110 const double *exptimes,
111 int *llx,
112 int *lly,
113 const char *compute_mode, const int nx_out, const int ny_out);
114
115int eris_ifu_combine_calc_contributions(cpl_image **cubesDataShifted,
116 const int n_cubes,
117 const int *llx, const int *lly,
118 const int x, const int y);
119
121 cpl_image *img,
122 bool *warn);
123
125 const int nframes,
126 const float *offsetx, const float *offsety,
127 float *min_offx, float *max_offx,
128 float *min_offy, float *max_offy);
129
131 const double x);
132
134 const cpl_image *img_in,
135 const double shift_x,
136 const double shift_y,
137 const double *kernel);
138
140 cpl_image *img);
141
143 eris_ifu_vector *data_vec,
144 eris_ifu_vector *error_vec,
145 const char *compute_mode);
146
148 const cpl_frameset *frameset,
149 cpl_image **imagesData,
150 cpl_image **imagesError,
151 int z,
152 int edge_trim,
153 bool subtract_background);
154
155int eris_ifu_combine_min_cube_size(const cpl_frameset *fs);
156
157/* --- simple shifting from KMOS pipeline --- */
158
177enum extrapolationType {
178 NONE_NANS,
179 NONE_CLIPPING,
180 BCS_NATURAL,
181 BCS_ESTIMATED,
182 RESIZE_NANS,
183 RESIZE_BCS_NATURAL,
184 RESIZE_BCS_ESTIMATED
185};
186
187cpl_image *eris_ifu_combine_shift_image_kmos(const cpl_image *img_in,
188 double xshift,
189 double yshift,
190 const char *method,
191 const enum extrapolationType extrapolation);
192
193#endif
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.