ERIS Pipeline Reference Manual 1.8.15
Functions
IFU Detector Linearity Functions

Functions

cpl_error_code eris_ifu_detlin_load_frames (const cpl_frameset *frameset, int exposureCorrectionMode, hdrl_imagelist **hdrl_imglist_on, hdrl_imagelist **hdrl_imglist_off, cpl_vector **vec_dit_on, cpl_vector **vec_dit_off)
 Load linearity calibration frames from a frameset.
 
cpl_image * eris_ifu_detlin_compute_linearity (const cpl_parameterlist *parlist, const hdrl_imagelist *imglist, const cpl_vector *vec_dit, cpl_propertylist *qclog)
 Compute detector linearity bad pixel map.
 
cpl_mask * eris_ifu_detlin_filter_mask (const cpl_mask *bpm, const cpl_parameterlist *parlist)
 Apply morphological filtering to a bad pixel mask.
 
cpl_table * eris_compute_gain (cpl_frameset *frameset)
 Compute detector gain from linearity frames.
 

Detailed Description

This module provides functions for detector linearity calibration, including loading linearity frames, computing linearity corrections, filtering bad pixel masks, and computing detector gain.

Synopsis:
#include "eris_ifu_detlin_static.h"

Function Documentation

◆ eris_compute_gain()

cpl_table * eris_compute_gain ( cpl_frameset *  frameset)

Compute detector gain from linearity frames.

Parameters
framesetInput frameset containing linearity lamp-on and lamp-off frames
Returns
Table containing gain values and ADU levels, or NULL on error

Computes the detector gain using the photon transfer curve method. For each pair of on/off frames with the same DIT and exposure time, the gain is calculated using the formula:

gain = (mean_signal) / (variance_difference)

where mean_signal is the average signal level and variance_difference is computed from the difference images. The calculation is performed on a specified window region (default: [270:320, 1000:1050]) using kappa-sigma clipping to reject outliers.

The returned table contains two columns:

  • "adu": Average ADU signal level
  • "gain": Computed gain in e-/ADU
Note
The returned table must be freed by the caller using cpl_table_delete().
The function expects both lamp-on and lamp-off frames in the frameset.
Kappa-sigma clipping with kappa=5 and nclip=25 is used for robustness.

medium accuracy eris_image_estimate_noise(img_on_sub, 1, &centre, &sig_on_dif); eris_image_estimate_noise(img_of_sub, 1, &centre, &sig_of_dif);

cpl_flux_get_noise_window(img_on_dif, zone, 2, 100, &sig_on_dif, NULL); cpl_flux_get_noise_window(img_of_dif, zone, 2, 100, &sig_of_dif, NULL); eris_msg("noise=%g %g", sig_on_dif, sig_of_dif);

Definition at line 493 of file eris_ifu_detlin_static.c.

References eris_check_error_code(), eris_ifu_frame_is_on(), and eris_pfits_get_dit().

◆ eris_ifu_detlin_compute_linearity()

cpl_image * eris_ifu_detlin_compute_linearity ( const cpl_parameterlist *  parlist,
const hdrl_imagelist *  imglist,
const cpl_vector *  vec_dit,
cpl_propertylist *  qclog 
)

Compute detector linearity bad pixel map.

Parameters
parlistInput recipe parameter list
imglistInput HDRL imagelist of linearity frames
vec_ditInput vector of detector integration times
qclogOutput property list for QC parameters
Returns
Bad pixel map image indicating non-linear pixels, or NULL on error

Computes a bad pixel map for detector linearity using HDRL polynomial fitting. The function:

  1. Parses linearity fitting parameters from the parameter list
  2. Computes initial bad pixel map using HDRL bad pixel map fitting
  3. Flags bad pixels in the input image list
  4. Performs polynomial fitting to the data
  5. Logs fit coefficients as QC parameters
  6. Computes and logs bad pixel statistics
Note
The returned image must be freed by the caller using cpl_image_delete().
The number of images must match the number of DIT values.
Bad pixels are identified based on deviation from polynomial fit.

Definition at line 249 of file eris_ifu_detlin_static.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_image(), eris_ifu_get_badpix_qc_from_ima(), hdrl_bpm_fit_compute(), hdrl_bpm_fit_parameter_get_degree(), hdrl_bpm_fit_parameter_parse_parlist(), hdrl_fit_polynomial_imagelist(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_imagelist_delete(), hdrl_imagelist_get(), hdrl_imagelist_get_size(), and TRY.

◆ eris_ifu_detlin_filter_mask()

cpl_mask * eris_ifu_detlin_filter_mask ( const cpl_mask *  bpm,
const cpl_parameterlist *  parlist 
)

Apply morphological filtering to a bad pixel mask.

Parameters
bpmInput bad pixel mask to filter
parlistInput parameter list containing filter parameters
Returns
Filtered bad pixel mask, or NULL on error

Applies morphological filtering (closing or dilation) to a bad pixel mask to clean up isolated bad pixels or expand bad pixel regions. The filter parameters are read from the parameter list:

  • post-filter-x: Filter kernel size in x direction
  • post-filter-y: Filter kernel size in y direction
  • post-filter-mode: Filter mode ("closing" or "dilation")
Note
The returned mask must be freed by the caller using cpl_mask_delete().
If either filter dimension is 0 or negative, no filtering is performed and NULL is returned.
Closing is useful for removing isolated bad pixels, dilation for expanding bad regions.

Definition at line 343 of file eris_ifu_detlin_static.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_mask(), hdrl_bpm_filter(), and TRY.

◆ eris_ifu_detlin_load_frames()

cpl_error_code eris_ifu_detlin_load_frames ( const cpl_frameset *  frameset,
int  exposureCorrectionMode,
hdrl_imagelist **  hdrl_imglist_on,
hdrl_imagelist **  hdrl_imglist_off,
cpl_vector **  vec_dit_on,
cpl_vector **  vec_dit_off 
)

Load linearity calibration frames from a frameset.

Parameters
framesetInput frameset containing linearity frames
exposureCorrectionModeExposure correction mode to apply
hdrl_imglist_onOutput HDRL imagelist for lamp-on frames (pointer to imagelist pointer)
hdrl_imglist_offOutput HDRL imagelist for lamp-off frames (pointer to imagelist pointer)
vec_dit_onOutput vector of DITs for lamp-on frames (pointer to vector pointer)
vec_dit_offOutput vector of DITs for lamp-off frames (pointer to vector pointer)
Returns
CPL_ERROR_NONE on success, otherwise an error code

Loads all LINEARITY_LAMP frames from the frameset and separates them into lamp-on and lamp-off frames. For each frame, the DIT (Detector Integration Time) is extracted from the FITS header and stored in the corresponding vector.

Note
The function expects twice as many on-frames as off-frames and will issue a warning if this condition is not met.
All output data structures are allocated by this function and must be freed by the caller.
On error, all allocated output structures are freed.

Definition at line 74 of file eris_ifu_detlin_static.c.

References CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_file_exists(), eris_ifu_frame_is_on(), eris_ifu_free_hdrl_imagelist(), eris_ifu_free_propertylist(), eris_ifu_free_vector(), eris_ifu_get_dit(), eris_ifu_load_exposure_file(), hdrl_imagelist_new(), hdrl_imagelist_set(), and TRY.