ERIS Pipeline Reference Manual 1.8.15
Functions
IFU Miscellaneous Functions

Functions

ifsInstrument eris_ifu_get_instrument_frame (cpl_frame *frame)
 Get instrument identifier from a CPL frame.
 
hdrl_image * eris_ifu_raw_hdrl_image (const cpl_image *cplImage)
 Create an HDRL image from a CPL image with calculated noise.
 
cpl_image * eris_ifu_calc_noise_map (const cpl_image *data, double gain, double readnoise)
 Calculate a noise map for detector data.
 
hdrl_imagelist * eris_ifu_load_exposure_frameset (const cpl_frameset *frameset, int exposureCorrectionMode)
 Load raw exposures from a frameset with optional corrections.
 
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_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.
 
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.
 
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_ifu_saturation_detection (cpl_image *image, cpl_image *dqi)
 Detect saturated pixels and flag them as bad.
 
cpl_error_code eris_ifu_exposure_line_correction (cpl_image *image)
 Perform line/row correction on raw detector image.
 
cpl_error_code eris_ifu_exposure_column_correction (cpl_image *image)
 Perform column correction on raw detector image.
 
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.
 
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.
 
cpl_error_code eris_ifu_add_std_params (cpl_parameterlist *pl, const char *recipename)
 Add standard recipe parameters to a parameter list.
 
void eris_ifu_free_std_param (struct stdParamStruct *stdParams)
 Free memory allocated for stdParamStruct.
 
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.
 
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.
 
cpl_error_code eris_parlist_config_add_flat (cpl_parameterlist *pl, const char *recname)
 Add flat field configuration parameters to parameter list.
 
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_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_1d_interpolation (double *xIn, double *yIn, int nIn, double *xOut, double *yOut, int nOut, const int interType)
 Perform 1D interpolation using GSL routines.
 
double eris_ifu_image_get_mean (const cpl_image *image)
 ‍**
 
cpl_vector * eris_ifu_calc_centers_collapse_chunk (const cpl_image *img, int chunk_center, int height)
 
cpl_vector * eris_ifu_image_collapse (const cpl_image *img)
 
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_bpm_correction (hdrl_image *himg, hdrl_image *badPixelMaskImg)
 eris_ifu_bpm_correction
 

Detailed Description

This module provides a comprehensive set of utility functions for IFU data processing, including:

These functions support both ERIS and SINFONI instruments and are used throughout the pipeline for data reduction tasks.

Function Documentation

◆ eris_ifu_1d_interpolation()

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.

Parameters
xInX-values of input data points
yInY-values of input data points
nInNumber of input points
xOutX-values for output (interpolation points)
yOut(Output) Interpolated Y-values
nOutNumber of output points
interTypeInterpolation type (see below)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
interType values:
  • > 2: Polynomial interpolation with degree = interType-1 (uses moving window)
  • 2: Linear interpolation
  • -1: Cubic spline with natural boundary conditions
  • -2: Cubic spline with periodic boundary conditions
  • -3: Akima spline with natural boundary conditions
  • -4: Akima spline with periodic boundary conditions
  • -5: Steffen's monotonic interpolation
NaN and Inf values in input are automatically removed before interpolation
GSL errors (except GSL_EDOM) are converted to CPL errors
For polynomial interpolation, uses a moving window of interType points
See also
remove_2nans, gsl_interp_eval_e

Definition at line 1788 of file eris_ifu_functions.c.

References ASSURE, BRK_WITH_ERROR_MSG, CATCH, eris_check_error_code(), eris_ifu_free_double_array(), and TRY.

Referenced by eris_ifu_jitter_reconstruct_cube(), and eris_ifu_wave_resampled_arc_image().

◆ eris_ifu_1d_polynomial_fit()

cpl_polynomial * eris_ifu_1d_polynomial_fit ( int  nPoints,
double *  xdata,
double *  ydata,
int  degree 
)

Fit a 1D polynomial to arrays of data points.

Parameters
nPointsNumber of data points
xdataX-coordinates array
ydataY-values array
degreePolynomial degree
Returns
Fitted polynomial object, or NULL on error
Note
If nPoints < degree+1, returns polynomial with all coefficients set to 0
Uses CPL polynomial fitting without sample symmetry
Arrays are wrapped (not copied) for efficiency
The returned polynomial must be freed with cpl_polynomial_delete()
See also
eris_ifu_polyfit_1d, cpl_polynomial_fit

Definition at line 1716 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), and TRY.

Referenced by eris_ifu_fit_all_lines(), eris_ifu_get_first_fit(), and eris_ifu_wave_smooth_coeffs().

◆ eris_ifu_add_badpix_border()

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.

Parameters
dataInput/output image
add_onesIf TRUE, set flagged pixels to 1.0
dqi(Optional) Data quality image to update with ERIS_DQI_BP flag
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Flags ERIS_IFU_DETECTOR_BP_BORDER pixels on all four edges
Border width is defined by ERIS_IFU_DETECTOR_BP_BORDER (typically 4 pixels)
TODO: Setting flagged pixels to 1 is inconsistent with NaN convention elsewhere

Definition at line 274 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_add_std_params()

cpl_error_code eris_ifu_add_std_params ( cpl_parameterlist *  pl,
const char *  recipename 
)

Add standard recipe parameters to a parameter list.

Parameters
plParameter list to which to append parameters
recipenameRecipe name (without "eris." prefix)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Adds the following standard parameters:
  • instrument: ERIS, SINFONI, or NONE (default: ERIS)
  • product_depth: Product output depth (default: 0)
  • line_corr: Enable line correction (default: FALSE)
  • col_corr: Enable column correction (default: FALSE)
  • crh_corr: Enable cosmic ray hit correction (default: FALSE)
  • crh_detection: Enable cosmic ray hit detection (default: FALSE)
  • crh.*: LA-cosmic parameters (created with defaults: 5, 2., 3)
  • pixel_saturation: Saturation level (default: 18000.0)
All parameters are prefixed with "eris.<recipename>."
CLI aliases are set without the "eris.<recipename>." prefix
See also
eris_ifu_fetch_std_param, hdrl_lacosmic_parameter_create

Definition at line 1002 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_parameter(), eris_ifu_free_parameterlist(), eris_ifu_free_string(), eris_ifu_parameterlist_append_list(), hdrl_lacosmic_parameter_create(), hdrl_lacosmic_parameter_create_parlist(), and TRY.

Referenced by eris_ifu_jitter_fill_common_parameterlist().

◆ eris_ifu_bpm_correction()

cpl_error_code eris_ifu_bpm_correction ( hdrl_image *  himg,
hdrl_image *  badPixelMaskImg 
)

eris_ifu_bpm_correction

Parameters
image2D hdrl image to be corrected
badPixelMaskImgMaster bad pixel image
Returns
Error in case of error

Correct the bad pixels of the image by taking the average of the 4 neighboring pixels

Definition at line 2499 of file eris_ifu_functions.c.

References eris_check_error_code(), hdrl_image_get_error(), hdrl_image_get_error_const(), hdrl_image_get_image(), hdrl_image_get_image_const(), hdrl_image_get_mask(), hdrl_image_get_mask_const(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_insert(), and hdrl_image_new().

Referenced by eris_ifu_jitter_build_cube().

◆ eris_ifu_calc_bpm()

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.

Parameters
plRecipe parameter list
recipe_nameRecipe name for parameter lookup
master_imgMaster image for 2D BPM computation
imglist_onImage list for 3D BPM computation
bpm2dMask(Output) 2D bad pixel mask
bpm3dMask(Output) 3D bad pixel mask
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
BPM method is controlled by parameter eris.<recipe>.bpm.method:
  • "2": Only 2D bad pixel detection
  • "3": Only 3D bad pixel detection
  • "2d3d": Both 2D and 3D detection
2D method detects spatial outliers in master_img
3D method detects temporal outliers across imglist_on
Both masks are combined and applied to master_img
Output masks must be freed by caller with cpl_mask_delete()
Logs number of detected bad pixels for each method
See also
hdrl_bpm_2d_compute, hdrl_bpm_3d_compute

Definition at line 771 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_image(), eris_ifu_free_imagelist(), eris_ifu_free_mask(), eris_ifu_free_string(), hdrl_bpm_2d_compute(), hdrl_bpm_2d_parameter_parse_parlist(), hdrl_bpm_3d_compute(), hdrl_bpm_3d_parameter_parse_parlist(), hdrl_image_get_mask(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_reject_from_mask(), and TRY.

Referenced by eris_ifu_dark_static().

◆ eris_ifu_calc_centers_collapse_chunk()

cpl_vector * eris_ifu_calc_centers_collapse_chunk ( const cpl_image *  img,
int  chunk_center,
int  height 
)

takes horizontal chuck of an image, collapses it in y

Definition at line 2164 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_image(), eris_ifu_free_vector(), and TRY.

Referenced by eris_ifu_dist_calc_centers().

◆ eris_ifu_calc_noise_map()

cpl_image * eris_ifu_calc_noise_map ( const cpl_image *  data,
double  gain,
double  readnoise 
)

Calculate a noise map for detector data.

Parameters
dataInput image data
gainDetector gain [e-/ADU] (must be > 0)
readnoiseRead-out noise [e-] (must be >= 0)
Returns
Noise image, or NULL on error
Note
Formula: sigma = sqrt(counts * gain + readnoise^2) / gain
Assumes Poisson noise for photon counts plus Gaussian readout noise
The returned image must be freed with cpl_image_delete()

Definition at line 149 of file eris_ifu_functions.c.

References BRK_IF_NULL, CATCH, CATCH_MSG, eris_check_error_code(), eris_ifu_free_image(), and TRY.

Referenced by eris_ifu_load_exposure_file(), and eris_ifu_raw_hdrl_image().

◆ eris_ifu_detect_crh()

cpl_mask * eris_ifu_detect_crh ( hdrl_image *  image,
int  exposureCorrectionMode,
hdrl_parameter *  laCosmicParams,
bool  maskImage 
)

Detect cosmic ray hits using LA-cosmic algorithm.

Parameters
imageInput HDRL image
exposureCorrectionModeBit flags controlling detection
laCosmicParamsHDRL LA-cosmic parameters
maskImageIf true, apply mask to input image
Returns
Mask with detected cosmic ray pixels flagged, or NULL on error
Note
Only performs detection if COSMIC_RAY_EXPOSURE_DETECTION flag is set
Uses HDRL lacosmic edge detection algorithm
Prints number of detected cosmic ray hits to log
The returned mask must be freed with cpl_mask_delete()
See also
hdrl_lacosmic_edgedetect

Definition at line 466 of file eris_ifu_functions.c.

References BRK_IF_ERROR, CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_mask(), hdrl_image_reject_from_mask(), hdrl_lacosmic_edgedetect(), and TRY.

◆ eris_ifu_exposure_column_correction()

cpl_error_code eris_ifu_exposure_column_correction ( cpl_image *  image)

Perform column correction on raw detector image.

Parameters
imageInput/output detector image
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
The detector is read out vertically, so artifacts in vertical direction can be due to read-out problems. Sometimes alternating bright/dark column patterns are visible.
Processing:
  • For each column, extracts 4 top and 4 bottom reference pixels
  • Calculates median of these 8 reference pixels
  • Subtracts median from all non-border pixels in the column
Border size is 4 pixels (hard-coded constant)
Supports both float and double image types
Image must have height >= 8 pixels (2 × border size)
See also
eris_ifu_exposure_line_correction

Definition at line 675 of file eris_ifu_functions.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_exposure_line_correction()

cpl_error_code eris_ifu_exposure_line_correction ( cpl_image *  image)

Perform line/row correction on raw detector image.

Parameters
imageInput/output detector image
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
The read-out electronics subtracts the mean of 4 reference pixels at left and right borders to remove row-dependent bias. This function replaces the mean with the median to reduce impact of hot pixels.
Processing:
  • Extracts 4 leftmost and 4 rightmost pixels for each row
  • Calculates mean and median of these 8 reference pixels
  • Adds (mean - median) correction to all non-border pixels in the row
Border size is 4 pixels (hard-coded constant)
Supports both float and double image types
Image must have width >= 8 pixels (2 × border size)
See also
eris_ifu_exposure_column_correction

Definition at line 578 of file eris_ifu_functions.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_fetch_std_param()

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.

Parameters
parlistInput parameter list
recipenameRecipe name (without "eris." prefix)
stdParams(Output) Structure to populate with parameter values
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Populates stdParams structure with:
  • productDepth: Product depth level
  • line_corr, col_corr, crh_corr, crh_det: Correction flags
  • rawImageCorrectionMask: Bitwise OR of enabled correction flags
  • crh_detection: LA-cosmic HDRL parameter
  • instrument: Instrument identifier (SPIFFI, SPIFFIER, OTHER_INSTRUMENT)
rawImageCorrectionMask bits:
  • LINE_EXPOSURE_CORRECTION
  • COLUMN_EXPOSURE_CORRECTION
  • COSMIC_RAY_EXPOSURE_CORRECTION
  • COSMIC_RAY_EXPOSURE_DETECTION
Instrument mapping: "SINFONI"→SPIFFI, "ERIS"→SPIFFIER, other→OTHER_INSTRUMENT
See also
eris_ifu_add_std_params, eris_ifu_free_std_param

Definition at line 1169 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_parameter(), eris_ifu_free_string(), hdrl_lacosmic_parameter_parse_parlist(), and TRY.

Referenced by eris_ifu_jitter_fetch_params().

◆ eris_ifu_free_std_param()

void eris_ifu_free_std_param ( struct stdParamStruct *  stdParams)

Free memory allocated for stdParamStruct.

Parameters
stdParamsPointer to stdParamStruct to free
Note
Only frees the crh_detection HDRL parameter within the structure
The structure itself is not freed, only its internal hdrl_parameter
Safe to call with NULL pointer
See also
eris_ifu_fetch_std_param, eris_ifu_add_std_params

Definition at line 1132 of file eris_ifu_functions.c.

References eris_check_error_code(), and hdrl_parameter_delete().

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_get_instrument_frame()

ifsInstrument eris_ifu_get_instrument_frame ( cpl_frame *  frame)

Get instrument identifier from a CPL frame.

Parameters
frameInput CPL frame
Returns
Instrument identifier (SPIFFI, SPIFFIER, OTHER_INSTRUMENT, or UNSET_INSTRUMENT on error)
Note
Reads the INSTRUME keyword from the FITS header (extension 0)
Returns UNSET_INSTRUMENT if frame is NULL or on error
See also
eris_ifu_get_instrument

Definition at line 78 of file eris_ifu_functions.c.

References BRK_WITH_ERROR, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_propertylist(), eris_ifu_get_instrument(), and TRY.

Referenced by eris_ifu_dfs_set_groups(), and eris_ifu_jitter_get_instrument_settings().

◆ eris_ifu_image_collapse()

cpl_vector * eris_ifu_image_collapse ( const cpl_image *  img)

collapses image in y and converts to vector

Definition at line 2215 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_image(), eris_ifu_free_vector(), and TRY.

◆ eris_ifu_image_get_mean()

double eris_ifu_image_get_mean ( const cpl_image *  image)

‍**

Calculate the mean of an image ignoring NaN values.

Parameters
imageImage to be averaged.
Returns
The mean.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if data is NULL.

Definition at line 1979 of file eris_ifu_functions.c.

References BRK_IF_NULL, CATCH, CATCH_MSGS, eris_check_error_code(), and TRY.

◆ eris_ifu_load_exposure_file()

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.

Parameters
filenamePath to detector exposure FITS file
exposureCorrectionModeBit flags specifying corrections to apply
dqi(Optional) Data quality image to populate
Returns
HDRL image containing data and noise, or NULL on error
Note
The exposureCorrectionMode parameter is bitwise OR of:
  • LINE_EXPOSURE_CORRECTION: Correct bad lines (reference pixel median)
  • COLUMN_EXPOSURE_CORRECTION: Correct bad columns
  • COSMIC_RAY_EXPOSURE_CORRECTION: Cosmic ray correction (not implemented)
  • COSMIC_RAY_EXPOSURE_DETECTION: Cosmic ray detection (not implemented)
Automatic processing includes:
  • Border pixel flagging (ERIS_DQI_BP = 16)
  • Saturation detection (ERIS_DQI_SAT = 8)
  • Noise calculation from gain and readout noise
Gain and readout noise are read from FITS header keywords:
  • SPIFFIER (ERIS): Uses FHDR_DET_CHIP_GAIN and FHDR_DET_CHIP_RON
  • SPIFFI (SINFONI): Uses defaults (gain=2.1, RON=0.0)
The returned HDRL image must be freed with hdrl_image_delete()
DQI bit flags: bit 3 (value 8) = saturated, bit 4 (value 16) = border
TODO: Saturation value -45727232.0 is hard-coded, should use #define
See also
eris_ifu_exposure_line_correction, eris_ifu_exposure_column_correction

Definition at line 381 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_add_badpix_border(), eris_ifu_calc_noise_map(), eris_ifu_exposure_column_correction(), eris_ifu_exposure_line_correction(), eris_ifu_free_hdrl_image(), eris_ifu_free_image(), eris_ifu_free_propertylist(), eris_ifu_get_instrument(), eris_ifu_saturation_detection(), hdrl_image_create(), and TRY.

Referenced by eris_ifu_detlin_load_frames(), eris_ifu_get_hdrlimagelist_by_tag(), eris_ifu_load_exposure_frame(), and eris_ifu_wave_collapse_arc_images().

◆ eris_ifu_load_exposure_frame()

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.

Parameters
frameCPL frame holding the detector FITS file info
exposureCorrectionModeBit flags for corrections to apply
dqi(Optional) Data quality image to populate with DQI flags
Returns
HDRL image containing data and noise, or NULL on error
Note
Wrapper function that extracts filename from frame and calls eris_ifu_load_exposure_file()
The returned HDRL image must be freed with hdrl_image_delete()
See also
eris_ifu_load_exposure_file, eris_ifu_load_exposure_frameset

Definition at line 237 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_load_exposure_file(), and TRY.

Referenced by eris_ifu_jitter_get_objsky_exposures(), and eris_ifu_load_exposure_frameset().

◆ eris_ifu_load_exposure_frameset()

hdrl_imagelist * eris_ifu_load_exposure_frameset ( const cpl_frameset *  frameset,
int  exposureCorrectionMode 
)

Load raw exposures from a frameset with optional corrections.

Parameters
framesetCPL frameset containing detector FITS files
exposureCorrectionModeBit flags for corrections to apply
Returns
HDRL imagelist containing data and noise images, or NULL on error
Note
Applies corrections based on exposureCorrectionMode flags (bitwise OR):
  • LINE_EXPOSURE_CORRECTION: Line/row correction
  • COLUMN_EXPOSURE_CORRECTION: Column correction
  • COSMIC_RAY_EXPOSURE_CORRECTION: Cosmic ray correction (not implemented)
  • COSMIC_RAY_EXPOSURE_DETECTION: Cosmic ray detection (not implemented)
The returned imagelist must be freed with hdrl_imagelist_delete()
See also
eris_ifu_load_exposure_frame, eris_ifu_load_exposure_file

Definition at line 196 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_load_exposure_frame(), hdrl_imagelist_get_size(), hdrl_imagelist_new(), hdrl_imagelist_set(), and TRY.

◆ eris_ifu_polyfit_1d()

cpl_vector * eris_ifu_polyfit_1d ( const cpl_vector *  x,
const cpl_vector *  y,
const int  degree 
)

Fit a 1D polynomial to vector data.

Parameters
xX-coordinate vector
yY-value vector to fit
degreePolynomial degree (must be > 0)
Returns
Vector of fit coefficients (length = degree + 1), or NULL on error
Note
Fit formula: y(x) = coeff[0] + coeff[1]*x + coeff[2]*x^2 + ...
Uses CPL polynomial fitting with no sample symmetry
Minimum degree is 0 (constant), maximum is the specified degree
The returned vector must be freed with cpl_vector_delete()
Coefficient ordering: [constant, linear, quadratic, cubic, ...]
See also
cpl_polynomial_fit, eris_ifu_1d_polynomial_fit

Definition at line 1632 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

◆ eris_ifu_raw_hdrl_image()

hdrl_image * eris_ifu_raw_hdrl_image ( const cpl_image *  cplImage)

Create an HDRL image from a CPL image with calculated noise.

Parameters
cplImageInput CPL image (data only)
Returns
HDRL image containing data and noise, or NULL on error
Note
Noise is calculated using detector gain (2.10) and readout noise (0.0)
The returned HDRL image must be freed with hdrl_image_delete()
Formula: sigma = sqrt(counts * gain + readnoise^2) / gain
See also
eris_ifu_calc_noise_map

Definition at line 116 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_calc_noise_map(), hdrl_image_create(), and TRY.

◆ eris_ifu_saturation_detection()

cpl_error_code eris_ifu_saturation_detection ( cpl_image *  image,
cpl_image *  dqi 
)

Detect saturated pixels and flag them as bad.

Parameters
imageInput/output image
dqi(Optional) Data quality image to update with ERIS_DQI_SAT flag
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Saturation threshold is hard-coded as -45727232.0f (TODO: should use #define)
Saturated pixels are flagged in the image's bad pixel mask
If dqi is provided, ERIS_DQI_SAT (value 8) is added to saturated pixels
Prints debug message if more than 50 saturated pixels found
TODO: Function expects float image but should work with double
TODO: Hard-coded threshold value should be a parameter or constant

Definition at line 521 of file eris_ifu_functions.c.

References eris_check_error_code().

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_slitpos_gauss()

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

Parameters
profile_xIn y collapsed profile across detector
left_edge_pos(return) position of left edge ()
right_edge_pos(return) position of right edge
llxoffset in x for specific slitlet
productDepthlevel of verbosity
Returns
Error in case of error

The function extracts a small area around the left ascending edge and another around the descending right edge. The y-values are subtracted in order th get a peak at the edge. The peak will be fitted using a gauss-funtion.

Definition at line 2260 of file eris_ifu_functions.c.

References BRK_WITH_ERROR, CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_fit_gauss(), eris_ifu_free_vector(), eris_ifu_save_vector_dbg(), and TRY.

◆ eris_ifu_warp_polynomial_image()

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.

Parameters
hdrlInImgInput HDRL image (data and error)
poly_uPolynomial transformation for x-coordinates
poly_vPolynomial transformation for y-coordinates
Returns
Warped HDRL image, or NULL on error
Note
Warps both data and error images using polynomial distortion maps
Uses tanh kernel profile with default width for interpolation
Post-processing: Marks pixels with zero data values as bad
The returned HDRL image must be freed with hdrl_image_delete()
Polynomial format: output = poly(input_x, input_y)
See also
cpl_image_warp_polynomial

Definition at line 906 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_hdrl_image(), eris_ifu_free_image(), eris_ifu_free_vector(), hdrl_image_create(), hdrl_image_get_error_const(), hdrl_image_get_image(), hdrl_image_get_image_const(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), and TRY.

Referenced by eris_ifu_jitter_build_cube().

◆ eris_parlist_config_add_all_recipes()

cpl_error_code eris_parlist_config_add_all_recipes ( cpl_parameterlist *  pl,
const char *  recname 
)

Add common configuration parameters for all recipes.

Parameters
plParameter list to which to append
recnameRecipe name (without "eris." prefix)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Adds:
  • instrument: {ERIS, SINFONI, NONE} (default: ERIS)
  • product_depth: Output depth for auxiliary products (default: 0)
Parameters are prefixed with "eris.<recname>."
CLI aliases are set without prefix
See also
eris_parlist_config_add_bpm, eris_parlist_config_add_flat

Definition at line 1282 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_parameter(), eris_ifu_free_string(), and TRY.

◆ eris_parlist_config_add_bpm()

cpl_error_code eris_parlist_config_add_bpm ( cpl_parameterlist *  pl,
const char *  recname 
)

Add bad pixel mask configuration parameters to parameter list.

Parameters
plParameter list to which to append
recnameRecipe name (without "eris." prefix)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Adds:
  • bpm.method: {2d, 3d, 2d3d, none} - selects BPM detection method
  • collapse.*: HDRL collapse parameters (median, sigclip, minmax)
  • 2dBadPix.*: HDRL 2D BPM parameters (filter or Legendre smoothing)
  • 3dBadPix.*: HDRL 3D BPM parameters
Default method: "2d" for distortion recipe, "2d3d" for others
Default 2D method: "LEGENDRE" for distortion, "FILTER" for others
Parameters use HDRL library parameter creation functions
See also
eris_ifu_calc_bpm, hdrl_bpm_2d_compute, hdrl_bpm_3d_compute

Definition at line 1350 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_parameter(), eris_ifu_free_parameterlist(), eris_ifu_free_string(), eris_ifu_parameterlist_append_list(), hdrl_bpm_2d_parameter_create_filtersmooth(), hdrl_bpm_2d_parameter_create_legendresmooth(), hdrl_bpm_2d_parameter_create_parlist(), hdrl_bpm_3d_parameter_create(), hdrl_bpm_3d_parameter_create_parlist(), hdrl_collapse_minmax_parameter_create(), hdrl_collapse_mode_parameter_create(), hdrl_collapse_parameter_create_parlist(), hdrl_collapse_sigclip_parameter_create(), hdrl_parameter_delete(), and TRY.

◆ eris_parlist_config_add_flat()

cpl_error_code eris_parlist_config_add_flat ( cpl_parameterlist *  pl,
const char *  recname 
)

Add flat field configuration parameters to parameter list.

Parameters
plParameter list to which to append
recnameRecipe name (without "eris." prefix)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
Adds:
  • mode: Flat field mode {fast, hdrl, segment} (default: fast)
  • flat_lo.*: Low-frequency flat parameters (HDRL, filter size 5×5)
  • flat_hi.*: High-frequency flat parameters (HDRL, filter size 7×7)
  • qc.fpn.{xmin,xmax,ymin,ymax}{1,2}: Fixed pattern noise ROI parameters
FPN region 1 default: [512:1536, 512:1536]
FPN region 2 default: [1350:1390, 1000:1200]
Parameters use HDRL library flat field creation functions
See also
eris_ifu_calc_flat, eris_ifu_flat_calc_qc_pre

Definition at line 1465 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_parameterlist(), eris_ifu_free_string(), eris_ifu_parameterlist_append_list(), hdrl_flat_parameter_create(), hdrl_flat_parameter_create_parlist(), and TRY.