21#ifndef ERIS_IFU_FUNCTIONS_H
22#define ERIS_IFU_FUNCTIONS_H
39#include <gsl/gsl_interp.h>
40#include <gsl/gsl_spline.h>
41#include <gsl/gsl_errno.h>
44#include "eris_ifu_constants.h"
45#include "eris_ifu_dfs.h"
50#define LINE_EXPOSURE_CORRECTION 1
51#define COLUMN_EXPOSURE_CORRECTION 2
52#define COSMIC_RAY_EXPOSURE_CORRECTION 4
53#define COSMIC_RAY_EXPOSURE_DETECTION 8
55#define BAD_PIX CPL_BINARY_1
56#define GOOD_PIX CPL_BINARY_0
58#define DBL_ZERO_TOLERANCE 1e-10
67struct stdParamStruct {
68 ifsInstrument instrument;
73 int rawImageCorrectionMask;
74 productDepthType productDepth;
75 hdrl_parameter *crh_detection;
78#define stdParamStructInit {0,0,0,0,0,0,0,NULL}
80#define GAUSS_PAR_RANGE_MAX 41
81struct gaussParStruct {
90 double xdata[GAUSS_PAR_RANGE_MAX];
91 double ydata[GAUSS_PAR_RANGE_MAX];
112 int exposureCorrectionMode,
113 hdrl_parameter *laCosmicParams,
117 int exposureCorrectionMode,
121 int exposureCorrectionMode,
125 int exposureCorrectionMode);
132 const char *recipe_name,
133 hdrl_image *master_img,
134 const hdrl_imagelist *imglist_on,
135 cpl_mask **bpm2dMask,
136 cpl_mask **bpm3dMask);
139 const cpl_polynomial *poly_u,
140 const cpl_polynomial *poly_v);
143 const char *recipename);
146 const char *recipename,
147 struct stdParamStruct *stdParams);
150 const char* recname);
153 const char *recname);
156 const char *recname);
175 const int interType);
177void remove_2nans(
int size_in,
double *xin,
double *yin,
178 int *size_out,
double **xout,
double **yout);
185cpl_error_code eris_ifu_line_gauss_fit(
const cpl_vector *yIn,
188 struct gaussParStruct *gaussPar);
197 double *left_edge_pos,
198 double *right_edge_pos,
204 hdrl_image *badPixelMaskImg);
206double eris_ifu_auto_derot_corr(
double alt,
double rot);
cpl_error_code eris_ifu_exposure_line_correction(cpl_image *image)
Perform line/row correction on raw detector image.
cpl_polynomial * eris_ifu_1d_polynomial_fit(int nPoints, double *xdata, double *ydata, int degree)
Fit a 1D polynomial to arrays of data points.
cpl_error_code eris_ifu_slitpos_gauss(const cpl_image *profile_x, double *left_edge_pos, double *right_edge_pos, int llx, int productDepth)
eris_ifu_dist_slitpos_gauss
cpl_error_code eris_ifu_1d_interpolation(double *xIn, double *yIn, int nIn, double *xOut, double *yOut, int nOut, const int interType)
Perform 1D interpolation using GSL routines.
cpl_error_code eris_ifu_bpm_correction(hdrl_image *himg, hdrl_image *badPixelMaskImg)
eris_ifu_bpm_correction
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_vector * eris_ifu_calc_centers_collapse_chunk(const cpl_image *img, int chunk_center, int height)
hdrl_image * eris_ifu_load_exposure_frame(const cpl_frame *frame, int exposureCorrectionMode, cpl_image *dqi)
Load a raw detector exposure from a frame with optional corrections.
cpl_error_code eris_ifu_fetch_std_param(const cpl_parameterlist *parlist, const char *recipename, struct stdParamStruct *stdParams)
Fetch standard parameters from parameter list into structure.
void eris_ifu_free_std_param(struct stdParamStruct *stdParams)
Free memory allocated for stdParamStruct.
cpl_vector * eris_ifu_image_collapse(const cpl_image *img)
cpl_error_code eris_ifu_calc_bpm(const cpl_parameterlist *pl, const char *recipe_name, hdrl_image *master_img, const hdrl_imagelist *imglist_on, cpl_mask **bpm2dMask, cpl_mask **bpm3dMask)
Create 2D and/or 3D bad pixel masks using HDRL algorithms.
cpl_error_code eris_ifu_add_badpix_border(cpl_image *data, cpl_boolean add_ones, cpl_image *dqi)
Flag detector border pixels as bad in image and optionally set to 1.
cpl_error_code eris_ifu_add_std_params(cpl_parameterlist *pl, const char *recipename)
Add standard recipe parameters to a parameter list.
cpl_error_code eris_ifu_exposure_column_correction(cpl_image *image)
Perform column correction on raw detector image.
cpl_vector * eris_ifu_polyfit_1d(const cpl_vector *x, const cpl_vector *y, const int degree)
Fit a 1D polynomial to vector data.
cpl_mask * eris_ifu_detect_crh(hdrl_image *image, int exposureCorrectionMode, hdrl_parameter *laCosmicParams, bool maskImage)
Detect cosmic ray hits using LA-cosmic algorithm.
cpl_error_code eris_parlist_config_add_bpm(cpl_parameterlist *pl, const char *recname)
Add bad pixel mask configuration parameters to parameter list.
cpl_image * eris_ifu_calc_noise_map(const cpl_image *data, double gain, double readnoise)
Calculate a noise map for detector data.
cpl_error_code eris_ifu_saturation_detection(cpl_image *image, cpl_image *dqi)
Detect saturated pixels and flag them as bad.
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.
hdrl_imagelist * eris_ifu_load_exposure_frameset(const cpl_frameset *frameset, int exposureCorrectionMode)
Load raw exposures from a frameset with optional corrections.
ifsInstrument eris_ifu_get_instrument_frame(cpl_frame *frame)
Get instrument identifier from a CPL frame.
double eris_ifu_image_get_mean(const cpl_image *image)
**
hdrl_image * eris_ifu_raw_hdrl_image(const cpl_image *cplImage)
Create an HDRL image from a CPL image with calculated noise.
hdrl_image * eris_ifu_warp_polynomial_image(const hdrl_image *hdrlInImg, const cpl_polynomial *poly_u, const cpl_polynomial *poly_v)
Warp an HDRL image using 2D polynomial transformations.