ERIS Pipeline Reference Manual 1.8.15
Macros | Functions
IFU Jitter Processing Static Functions

Core jitter observation processing workflows and cube reconstruction. More...

Macros

#define ERIS_IFU_SKIP_SKY_CORR_PLANES   75
 *static *‍/void
 

Functions

void eris_ifu_jitter_free_sofStruct (struct sofStruct *sof_struct)
 Free and clean up SOF structure and all contained data.
 
void eris_ifu_jitter_get_cube_type_string (cubeType type)
 Print cube type as string to log.
 
cubeType eris_ifu_jitter_get_coadd_obj_type (cubeType type)
 Convert cube type to corresponding coadded cube type.
 
cubeType eris_ifu_jitter_get_obj_type (sofModes mode)
 Get object cube type from SOF observation mode.
 
cubeType eris_ifu_jitter_get_sky_type (sofModes mode)
 Get sky cube type from SOF observation mode.
 
cpl_error_code eris_ifu_jitter_process_exposures (struct sofStruct *sof, struct stdParamStruct stdParams, struct paramStruct params, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
 Process all raw exposures into calibrated 3D data cubes.
 
cpl_error_code eris_ifu_jitter_process_cubes (struct sofStruct *sof, struct stdParamStruct stdParams, struct paramStruct params, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, cubeType *obj_type)
 Process and combine data cubes with sky tweaking and DAR correction.
 
hdrl_image * eris_ifu_jitter_subtract_background (skyTweakModes sky_tweak, int objIdx, struct sofStruct *sof, productDepthType productDepth)
 Subtract sky or dark background from raw exposure image.
 
hdrl_imagelist * eris_ifu_jitter_build_cube (hdrl_image *inputImage, int sofIdx, struct sofStruct *sof, struct paramStruct params, bool doVelocityCorrection, cpl_polynomial *ohLambdaCorrection, productDepthType productDepth)
 Build 3D data cube from 2D detector image.
 
cpl_error_code eris_image_get_valid_data_range (cpl_image *image, cpl_size *min, cpl_size *max)
 Determine valid data range in spectral direction (find NaN-dominated rows)
 
cpl_imagelist * eris_ifu_jitter_reconstruct_cube (cpl_image *resampledDetImage, slitletDetectionModes mode, int fineTuneMode, double firstCol, cpl_vector *distancesV, cpl_bivector *positionsVV)
 Function to create a 3D-data cube from a re-sampled image.
 
cpl_error_code eris_ifu_jitter_get_procatg_and_filename (cubeType type, char **proCatg, char **filenamePrefix)
 Get the value of the PRO.CATG and the filename as function of the type of cube.
 
cpl_error_code eris_ifu_extract_spec (const cpl_imagelist *data_in, const cpl_imagelist *noise_in, cpl_image *mask, cpl_vector **spec_data_out, cpl_vector **spec_noise_out)
 Extract a spectrum from 3D data cube.
 
cpl_error_code eris_ifu_extract_spec_fetch_params (const cpl_parameterlist *parlist, struct esParamStruct *params, const char *context)
 Fetch spectral extraction parameters from parameter list.
 
cpl_error_code eris_ifu_jitter_extract (cpl_frameset *frameset, const cpl_parameterlist *parlist, cubeType obj_type, const char *pcatg, struct stdParamStruct stdParams, const char *pipefile_prefix, const char *context)
 Main spectral extraction function.
 
cpl_error_code eris_ifu_jitter_extract_spec_processSof (cubeType obj_type, cpl_frameset *frames, struct esParamStruct params, struct esSofStruct *sof)
 Process SOF for spectral extraction.
 
cpl_error_code eris_ifu_dar_correction (hdrl_imagelist *cube, cpl_propertylist *hdr, int method, double radius, int length)
 Apply Differential Atmospheric Refraction (DAR) correction.
 
cpl_error_code eris_ifu_dar_cpl_shift (cpl_image *inImg, cpl_image *out1Img, cpl_image *out2Img, double xShift, double yShift, cpl_kernel kernelType, double width, cpl_size kernelSize)
 Apply DAR correction using CPL image shifting.
 
cpl_error_code eris_ifu_dar_gsl_shift (cpl_image *inImg, cpl_image *outImg, double xShift, double yShift, const gsl_interp2d_type *T)
 Apply DAR correction using GSL 2D interpolation.
 
int eris_frameset_count_tag (cpl_frameset *sof, const char *tag)
 Count frames with specified tag in frameset.
 
cpl_error_code eris_frameset_duplicate_cube_tag (cpl_frameset *frameset, const char *pcatg, cpl_boolean apply_flat)
 Duplicate a cube file with different PRODCATG for coadded version.
 
cpl_error_code eris_ifu_update_wcs_with_OCS_keywords (struct sofStruct *sof)
 Update WCS coordinates from OCS cumulative offset keywords.
 

Detailed Description

Core jitter observation processing workflows and cube reconstruction.

This module implements the complete data reduction workflow for jittered IFU observations, including data cube construction, sky subtraction, spectral extraction, and mosaicking.

Key Functionality:

Processing Workflow:

  1. Load and validate SOF structure (eris_ifu_jitter_processSof from eris_ifu_jitter_interface.c)
  2. Process individual exposures (eris_ifu_jitter_process_exposures)
    • Subtract sky/dark background
    • Apply flat field correction
    • Correct for bad pixels
    • Apply distortion correction
    • Resample wavelength scale
    • Reconstruct 3D cube
    • Apply OH-based wavelength correction
  3. Process and combine cubes (eris_ifu_jitter_process_cubes)
    • Apply sky tweaking (Davies or Austrian method)
    • Handle automatic jitter sky subtraction
    • Apply DAR correction if requested
  4. Extract spectra if point source mode
  5. Co-add multiple exposures into final products

Sky Subtraction Methods:

Data Structures:

Function Documentation

◆ eris_frameset_count_tag()

int eris_frameset_count_tag ( cpl_frameset *  sof,
const char *  tag 
)

Count frames with specified tag in frameset.

Parameters
sofInput frameset
tagTag to search for
Returns
Number of frames with matching tag, or -1 on error
Note
Simple utility function for frame counting

Definition at line 3661 of file eris_ifu_jitter_static.c.

Referenced by eris_stdstar_reduction_common().

◆ eris_frameset_duplicate_cube_tag()

cpl_error_code eris_frameset_duplicate_cube_tag ( cpl_frameset *  frameset,
const char *  pcatg,
cpl_boolean  apply_flat 
)

Duplicate a cube file with different PRODCATG for coadded version.

Parameters
framesetinput frameset containing data cube
pcatgcube PRO.CATG
apply_flatwas the cube corrected by flat?
Returns
CPL_ERROR_NONE on success
Note
This function:
  1. Finds frame with specified PRODCATG
  2. Creates new filename with "_coadd" suffix
  3. Copies file using system("cp ...") command
  4. Updates PRODCATG in copied file
  5. Adds new frame to frameset
Handles NOFLAT variants separately based on apply_flat parameter
Copies all extensions: primary HDU + 3 data extensions (DATA, ERROR, QUALITY)
Uses system() call (TODO: should use CPL file operations)

Definition at line 3700 of file eris_ifu_jitter_static.c.

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_dar_correction()

cpl_error_code eris_ifu_dar_correction ( hdrl_imagelist *  cube,
cpl_propertylist *  hdr,
int  method,
double  radius,
int  length 
)

Apply Differential Atmospheric Refraction (DAR) correction.

Parameters
cubedata cube to correct (modified in place)
hdrFITS header with WCS info
shiftMethodinterpolation method for shifting [0-8]
shiftWidthkernel radius for interpolation [pixels]
shiftLengthkernel length for interpolation
Returns
CPL_ERROR_NONE on success
Note
DAR causes wavelength-dependent image shifts due to atmospheric refraction
Correction algorithm:
  1. Collapse cube to create reference wavelength image
  2. For each wavelength plane:
    • Compute cross-correlation with reference to determine shift
    • Apply sub-pixel shift to align plane with reference
Shift methods: 0-8 correspond to different interpolation kernels
Uses either CPL shifting (shiftMethod < 5) or GSL interpolation (>= 5)
Reference wavelength typically chosen at center of band

Definition at line 3355 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, CATCH, CHECK_ERROR_STATE, eris_ifu_dar_cpl_shift(), eris_ifu_dar_gsl_shift(), eris_ifu_free_image(), eris_ifu_free_vector(), eris_ifu_lcorr_create_lambda_vector(), hdrl_dar_compute(), hdrl_dar_parameter_create(), hdrl_image_create(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_imagelist_get(), hdrl_imagelist_set(), hdrl_parameter_delete(), and TRY.

Referenced by eris_ifu_jitter_process_cubes().

◆ eris_ifu_dar_cpl_shift()

cpl_error_code eris_ifu_dar_cpl_shift ( cpl_image *  inImg,
cpl_image *  out1Img,
cpl_image *  out2Img,
double  xShift,
double  yShift,
cpl_kernel  kernelType,
double  width,
cpl_size  kernelSize 
)

Apply DAR correction using CPL image shifting.

Parameters
cubeData cube to correct (modified in place)
refImgReference image for cross-correlation
shiftMethodCPL shift method [0-4]
shiftWidthKernel radius [pixels]
shiftLengthKernel length
Returns
CPL_ERROR_NONE on success
Note
Uses cpl_image_correlate_create() to compute shifts
Uses cpl_image_shift() to apply sub-pixel shifts
Shift methods correspond to CPL_SHIFT_METHOD enum values

Definition at line 3504 of file eris_ifu_jitter_static.c.

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

Referenced by eris_ifu_dar_correction().

◆ eris_ifu_dar_gsl_shift()

cpl_error_code eris_ifu_dar_gsl_shift ( cpl_image *  inImg,
cpl_image *  outImg,
double  xShift,
double  yShift,
const gsl_interp2d_type *  T 
)

Apply DAR correction using GSL 2D interpolation.

Parameters
cubeData cube to correct (modified in place)
refImgReference image for cross-correlation
shiftMethodInterpolation method (5=bilinear, 6=bicubic)
shiftWidthNot used for GSL methods
shiftLengthNot used for GSL methods
Returns
CPL_ERROR_NONE on success
Note
Uses gsl_interp2d for sub-pixel interpolation
Method 5: Bilinear interpolation
Method 6: Bicubic interpolation
Generally provides smoother results than CPL methods

Definition at line 3586 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_dar_correction().

◆ eris_ifu_extract_spec()

cpl_error_code eris_ifu_extract_spec ( const cpl_imagelist *  data_in,
const cpl_imagelist *  noise_in,
cpl_image *  mask,
cpl_vector **  spec_data_out,
cpl_vector **  spec_noise_out 
)

Extract a spectrum from 3D data cube.

Parameters
data_ininput 3D data cube
noise_ininput 3D errors cube (can be NULL)
maskinput pixel mask for weighted extraction (can be NULL)
[out]spec_data_outextracted spectrum (allocated by function)
[out]spec_noise_outerror spectrum (allocated if noise_in provided)
Returns
cpl_error_code error status
Note
Extraction method:
  • If mask provided: weighted sum, sum(data * mask) / sum(mask)
  • If no mask: simple sum/average over spatial pixels
Skips bad pixels (marked in input image BPM) and non-finite values
Error propagation: sqrt(sum(err^2 * mask^2) / sum(mask^2))
Output vectors are allocated by this function and must be freed by caller
Loop over all wavelength planes (nz)

Definition at line 2654 of file eris_ifu_jitter_static.c.

References ASSURE, BRK_IF_NULL, CATCH, CATCH_MSG, and TRY.

Referenced by eris_ifu_lcorr_extract_spectrum().

◆ eris_ifu_extract_spec_fetch_params()

cpl_error_code eris_ifu_extract_spec_fetch_params ( const cpl_parameterlist *  parlist,
struct esParamStruct *  params,
const char *  context 
)

Fetch spectral extraction parameters from parameter list.

Parameters
parlistinput parameter list
paramsoutput parameter structure (modified in place)
recipe_namerecipe name for parameter context
Returns
CPL_ERROR_NONE on success
Note
Extracts parameters:
  • mask_method: "mask", "position", "max", "fit", "optimal"
  • center: Center position as string "x,y" (parsed to integers)
  • radius: Extraction radius [pixels]
Parses center string using sscanf to extract x,y coordinates
Validates that center coordinates are in valid range

Definition at line 3003 of file eris_ifu_jitter_static.c.

References BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, and TRY.

Referenced by eris_ifu_jitter_extract().

◆ eris_ifu_jitter_build_cube()

hdrl_imagelist * eris_ifu_jitter_build_cube ( hdrl_image *  inputImage,
int  sofIdx,
struct sofStruct *  sof,
struct paramStruct  params,
bool  doVelocityCorrection,
cpl_polynomial *  ohLambdaCorrection,
productDepthType  productDepth 
)

Build 3D data cube from 2D detector image.

Parameters
inputImageinput image (brick-wall pattern, before re-sampling)
sofIdxindex of image in input sofStruct structure
sofStructdata structure containing all input data
paramsstructure with all parameters required to reduce sci data
doVelocityCorrectionboolean switch to apply or not velocity corr
ohLambdaCorrectionpolynomial coefficients with OH wave-cal corr
productDepthproduct depth parameter
Returns
3D data cube as HDRL imagelist, or NULL on error
Note
This is the CORE cube building function that:
  1. Divides by master flat field if available
  2. Corrects bad pixels (multiple iterations if bpc_iter > 1)
  3. Applies derotator correction (shifts distortion polynomials)
  4. Warps image using distortion polynomials to correct geometric distortion
  5. Applies velocity offset correction to wavelength scale if requested
  6. Applies OH-based wavelength correction if polynomial provided
  7. Resamples wavelength scale to regular grid
  8. Reconstructs 3D cube from resampled brick-wall image
  9. Creates corresponding bad pixel mask cube
Derotator correction compensates for spectrum wrapping across detector edges
Wavelength resampling uses eris_ifu_wave_resampled_arc_image()
Cube reconstruction uses eris_ifu_jitter_reconstruct_cube()
Updates sofIdx entry with:
  • cubeHdr: Updated FITS header with WCS info
  • cubeBpm: Bad pixel mask cube (replaces previous if exists)
Saves multiple debug products if productDepth >= PD_DEBUG

Definition at line 1880 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_bpm_correction(), eris_ifu_dist_warp_bpm(), eris_ifu_dist_warp_image(), eris_ifu_free_hdrl_image(), eris_ifu_free_image(), eris_ifu_free_propertylist(), eris_ifu_free_string(), eris_ifu_jitter_reconstruct_cube(), eris_ifu_mask_nans_in_cube(), eris_ifu_save_hdrl_image_dbg(), eris_ifu_warp_polynomial_image(), eris_ifu_wave_resampled_arc_image(), hdrl_image_create(), hdrl_image_div_image(), hdrl_image_duplicate(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_image_insert(), hdrl_image_new(), hdrl_imagelist_create(), hdrl_imagelist_get_size(), and TRY.

Referenced by eris_ifu_jitter_process_exposures().

◆ eris_ifu_jitter_extract()

cpl_error_code eris_ifu_jitter_extract ( cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
cubeType  obj_type,
const char *  pcatg,
struct stdParamStruct  stdParams,
const char *  pipefile_prefix,
const char *  context 
)

Main spectral extraction function.

Parameters
framesetinput frameset
obj_cubeobject data cube
obj_cube_hdrcube FITS header
paramsextraction parameters
es_sofextraction SOF structure
productDepthproduct depth parameter
Returns
CPL_ERROR_NONE on success
Note
Creates extraction mask based on mask_method:
  • "max": Find brightest pixel in collapsed cube
  • "position": Use user-specified center
  • "fit": Fit 2D Gaussian to find center
  • "mask": Use provided mask image
  • "optimal": Optimal extraction (not fully implemented)
Collapses cube to 2D image for mask creation
Creates circular mask with specified radius around center
Extracts spectrum using eris_ifu_extract_spec()
Populates es_sof with spectrum, error, totalFlux, wavelength

Definition at line 3101 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, eris_check_error_code(), eris_compute_psf_qc(), eris_ifu_extract_spec_fetch_params(), eris_ifu_free_bivector(), eris_ifu_free_hdrl_image(), eris_ifu_free_image(), eris_ifu_free_propertylist(), eris_ifu_free_vector(), eris_ifu_jitter_extract_spec_processSof(), eris_ifu_jitter_get_coadd_obj_type(), eris_ifu_jitter_get_cube_type_string(), eris_ifu_jitter_get_procatg_and_filename(), eris_ifu_save_deq_image(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_image_get_mask(), and TRY.

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_jitter_extract_spec_processSof()

cpl_error_code eris_ifu_jitter_extract_spec_processSof ( cubeType  obj_type,
cpl_frameset *  frames,
struct esParamStruct  params,
struct esSofStruct *  sof 
)

Process SOF for spectral extraction.

Parameters
framesetinput frameset
obj_typecube type
sofinput SOF structure
paramsextraction parameters
recipe_namerecipe name
productDepthproduct depth parameter
Returns
CPL_ERROR_NONE on success
Note
Sets up extraction SOF (es_sof) structure from main SOF
Handles both regular cubes and coadded cubes
Extracts framesets for OBJ, STD, and PSF observations
Calls eris_ifu_jitter_extract() to perform actual extraction
Calls eris_ifu_jitter_spec_save_products() to save results

Definition at line 3263 of file eris_ifu_jitter_static.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_jitter_get_procatg_and_filename(), eris_ifu_load_deq_hdrl_imagelist(), hdrl_imagelist_get_size(), hdrl_imagelist_get_size_x(), hdrl_imagelist_get_size_y(), and TRY.

Referenced by eris_ifu_jitter_extract().

◆ eris_ifu_jitter_free_sofStruct()

void eris_ifu_jitter_free_sofStruct ( struct sofStruct *  sof_struct)

Free and clean up SOF structure and all contained data.

Parameters
sof_structSOF structure to free (can be NULL)
Note
This function deallocates all memory associated with the SOF structure including:
  • Exposure table with all raw images, cubes, headers, and masks
  • Master calibration frames (dark, flat)
  • Wavelength map and distortion polynomials
  • Bad pixel masks and DQI images
  • OH reference data
Some members (frame, rawImage) are commented out to avoid segmentation faults, suggesting potential ownership issues
After freeing, the structure pointer is set to NULL (but this only affects local copy)

Definition at line 154 of file eris_ifu_jitter_static.c.

References hdrl_image_delete(), and hdrl_imagelist_delete().

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_jitter_get_coadd_obj_type()

cubeType eris_ifu_jitter_get_coadd_obj_type ( cubeType  type)

Convert cube type to corresponding coadded cube type.

Parameters
typeInput cube type
Returns
Corresponding coadded cube type (e.g., OBJECT_CUBE -> OBJECT_CUBE_COADD)
Note
Returns OBJECT_CUBE_COADD as default for unrecognized types
Preserves NOFLAT variants (STD_FLUX_CUBE_NOFLAT -> STD_FLUX_CUBE_COADD_NOFLAT)

Definition at line 324 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_jitter_extract().

◆ eris_ifu_jitter_get_cube_type_string()

void eris_ifu_jitter_get_cube_type_string ( cubeType  type)

Print cube type as string to log.

Parameters
typeCube type enumeration value
Note
Outputs an informational message with the cube type name for debugging purposes
Handles all defined cube types including object, sky, standard, PSF, DAR, and coadded variants

Definition at line 230 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_jitter_extract(), and eris_stdstar_reduction_common().

◆ eris_ifu_jitter_get_obj_type()

cubeType eris_ifu_jitter_get_obj_type ( sofModes  mode)

Get object cube type from SOF observation mode.

Parameters
modeSOF observation mode (SCIENCE, STD, STD_FLUX, PSF, etc.)
Returns
Corresponding object cube type
Note
Maps observation modes to cube types:
  • SCIENCE -> OBJECT_CUBE
  • STD -> STD_CUBE
  • STD_FLUX -> STD_FLUX_CUBE
  • PSF -> PSF_CUBE
  • default -> OBJECT_CUBE

Definition at line 396 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_jitter_process_cubes(), and eris_ifu_jitter_process_exposures().

◆ eris_ifu_jitter_get_procatg_and_filename()

cpl_error_code eris_ifu_jitter_get_procatg_and_filename ( cubeType  type,
char **  proCatg,
char **  filenamePrefix 
)

Get the value of the PRO.CATG and the filename as function of the type of cube.

Parameters
typethe cube type
[out]proCatgcube PRO.CATG (caller must free)
[out]filenamePrefixcube filename prefix (caller must free)
Returns
CPL_ERROR_NONE on success
Note
Maps each cubeType enum to appropriate PRODCATG and filename
Handles all cube types: OBJECT, STD, PSF, SKY, DAR, TWEAKED, BPM, JITTER
Also handles COADD variants and NOFLAT variants
Strings returned via proCatg and filenamePrefix must be freed by caller

Definition at line 2514 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_combine(), eris_ifu_jitter_extract(), eris_ifu_jitter_extract_spec_processSof(), eris_ifu_jitter_process_cubes(), and eris_stdstar_reduction_common().

◆ eris_ifu_jitter_get_sky_type()

cubeType eris_ifu_jitter_get_sky_type ( sofModes  mode)

Get sky cube type from SOF observation mode.

Parameters
modeSOF observation mode (SCIENCE, STD, STD_FLUX, PSF, etc.)
Returns
Corresponding sky cube type
Note
Maps observation modes to sky cube types:
  • SCIENCE -> SKY_OBJECT_CUBE
  • STD -> SKY_STD_CUBE
  • STD_FLUX -> SKY_STD_FLUX_CUBE
  • PSF -> SKY_PSF_CUBE
  • default -> SKY_OBJECT_CUBE

Definition at line 437 of file eris_ifu_jitter_static.c.

Referenced by eris_ifu_jitter_process_cubes(), and eris_ifu_jitter_process_exposures().

◆ eris_ifu_jitter_process_cubes()

cpl_error_code eris_ifu_jitter_process_cubes ( struct sofStruct *  sof,
struct stdParamStruct  stdParams,
struct paramStruct  params,
cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  recipe_name,
cubeType *  obj_type 
)

Process and combine data cubes with sky tweaking and DAR correction.

Parameters
sofSOF structure containing all exposures and their cubes
stdParamsStandard pipeline parameters
paramsJitter-specific processing parameters
framesetInput frameset for DFS compliance
parlistRecipe parameter list
recipe_nameRecipe name for output products
obj_typeOutput: determined object cube type (modified in place)
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
This is a MAIN processing function that:
  1. Loops through all object exposures
  2. Applies sky tweaking if requested:
    • Davies method: Spectral scaling and stretching
    • Austrian method: Pixel-by-pixel skycorr algorithm
  3. Handles automatic jitter sky subtraction (aj-method parameter)
  4. Applies DAR correction if enabled
  5. Saves intermediate products (tweaked cubes, DAR-corrected cubes)
  6. Ensures at least one cube product exists for extraction
Sky tweaking requires paired object-sky observations
Automatic jitter (aj-method > 3) works without sky frames
DAR correction uses parameters: darShiftMethod, darShiftWidth, darShiftLength
Uses TRY/CATCH error handling with detailed error messages

Definition at line 1347 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_ifu_dar_correction(), eris_ifu_extract_frameset(), eris_ifu_free_imagelist(), eris_ifu_free_mask(), eris_ifu_free_parameterlist(), eris_ifu_free_string(), eris_ifu_free_table(), eris_ifu_jitter_get_obj_type(), eris_ifu_jitter_get_procatg_and_filename(), eris_ifu_jitter_get_sky_type(), eris_ifu_sky_tweak(), eris_ifu_split_hdrl_imagelist(), hdrl_image_reject_from_mask(), hdrl_imagelist_create(), hdrl_imagelist_get(), hdrl_imagelist_get_size(), hdrl_imagelist_get_size_x(), hdrl_imagelist_get_size_y(), sc_skycorr(), and TRY.

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_jitter_process_exposures()

cpl_error_code eris_ifu_jitter_process_exposures ( struct sofStruct *  sof,
struct stdParamStruct  stdParams,
struct paramStruct  params,
cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  recipe_name,
const char *  context 
)

Process all raw exposures into calibrated 3D data cubes.

Parameters
sofSOF structure containing all exposures and calibrations
stdParamsStandard pipeline parameters
paramsJitter-specific processing parameters
framesetInput frameset for DFS compliance
parlistRecipe parameter list
recipe_nameRecipe name for output products
contextParameter context string (e.g., "eris.eris_ifu_jitter")
Returns
CPL_ERROR_NONE on success, otherwise an error code
Note
This is a MAIN processing function that:
  1. Loops through all object and sky exposures in the SOF
  2. For each exposure:
    • Subtracts sky/dark background if available
    • Builds initial 3D cube via eris_ifu_jitter_build_cube()
    • Computes OH-based wavelength correction if OH reference available
    • Rebuilds cube with OH correction applied
    • Saves auxiliary cube products if productDepth >= PD_AUXILLIARY
    • Optionally removes NaN-heavy spectral planes (chop-nan parameter)
  3. Updates WCS from OCS keywords if USE_OCS environment variable set
OH alignment can be controlled by parameters:
  • skip_oh_align: Skip all OH alignment
  • skip_sky_oh_align: Skip OH alignment for sky frames only
  • oh_align_poly_order: Polynomial order for OH fitting [0-3]
Output cubes are stored in sof->exposureTable[ix].cube for later processing
Uses TRY/CATCH error handling for robustness

Definition at line 704 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_check_error_code(), eris_ifu_append_qc_float(), eris_ifu_cube_trim_nans(), eris_ifu_free_hdrl_image(), eris_ifu_free_hdrl_imagelist(), eris_ifu_free_polynomial(), eris_ifu_get_band(), eris_ifu_get_plane_cut_min_max(), eris_ifu_jitter_build_cube(), eris_ifu_jitter_get_obj_type(), eris_ifu_jitter_get_sky_type(), eris_ifu_jitter_subtract_background(), eris_ifu_lcorr_get(), eris_ifu_update_wcs_with_OCS_keywords(), hdrl_imagelist_get_size(), and TRY.

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_jitter_reconstruct_cube()

cpl_imagelist * eris_ifu_jitter_reconstruct_cube ( cpl_image *  resampledDetImage,
slitletDetectionModes  mode,
int  fineTuneMode,
double  firstCol,
cpl_vector *  distancesV,
cpl_bivector *  positionsVV 
)

Function to create a 3D-data cube from a re-sampled image.

Parameters
resampledDetImagethe re-sampled image
modeparameter to control the slitlet detection algorithm used
fineTuneModeSpecifies the row interpolation mode using GSL routines 0: no interpolation >2: polynomial interpolation, polynomial degree is interType-1 2: linear interpolation -1: Cubic spline with natural boundary conditions -2: cubic spline with periodic boundary conditions -3: Non-rounded Akima spline with natural boundary conditions. -4: Non-rounded Akima spline with periodic boundary conditions. -5: Steffen's method guarantees the monotonicity of the interpolating function between the given data points
firstColfirst column of each slitlet used to re-sample image
distancesVoutput computed slitlets distances (for DISTANCES mode, can be NULL)
positionsVVoutput computed slutlets positions (for EDGES mode, can be NULL)
Returns
reconstructed 3D data cube (cpl_imagelist object)
Note
This function converts the "brick-wall" detector format to a proper 3D cube
Three modes supported:
  • DISTANCES: Use measured slitlet separations from calibration
  • EDGES: Use measured slitlet edge positions from calibration
  • GRID: Simple grid-based (new ERIS method, distancesV must be NULL)
Output cube dimensions: [onx, ony, onz] where:
  • onx = input_x / SLITLET_CNT
  • ony = SLITLET_CNT * 2 (factor of 2 to make square spaxels)
  • onz = input_y (spectral direction)
Flux is divided by 2 when expanding Y dimension to conserve flux
Applies fine-tuning interpolation if fineTuneMode != 0
For GRID mode (new ERIS), x-axis is flipped to correct east direction

Definition at line 2296 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, eris_ifu_1d_interpolation(), eris_ifu_free_imagelist(), eris_ifu_mask_nans_in_cube(), and TRY.

Referenced by eris_ifu_jitter_build_cube().

◆ eris_ifu_jitter_subtract_background()

hdrl_image * eris_ifu_jitter_subtract_background ( skyTweakModes  sky_tweak,
int  objIdx,
struct sofStruct *  sof,
productDepthType  productDepth 
)

Subtract sky or dark background from raw exposure image.

Parameters
sky_tweakSky tweaking mode (NONE, DAVIES, AUSTRIAN)
objIdxIndex of object exposure in SOF
sofSOF structure containing calibrations and exposures
productDepthProduct depth parameter for debug output
Returns
Background-subtracted HDRL image, or NULL on error
Note
Background subtraction strategy:
  1. If sky_tweak == NONE:
    • Use paired sky frame if available (objEntry->skyIndex >= 0)
    • Otherwise use master dark if available
  2. If sky_tweak != NONE, return raw image without subtraction (sky subtraction will be done later via tweaking)
Creates DQI (Data Quality Image) updates for new bad pixels
Saves debug products if productDepth >= PD_DEBUG
The returned image must be deleted by the caller
Memory for the image is allocated by this function

Definition at line 1773 of file eris_ifu_jitter_static.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_free_image(), eris_ifu_free_mask(), eris_ifu_free_string(), eris_ifu_save_hdrl_image_dbg(), hdrl_image_delete(), hdrl_image_duplicate(), hdrl_image_get_mask(), hdrl_image_sub_image(), and TRY.

Referenced by eris_ifu_jitter_process_exposures().

◆ eris_ifu_update_wcs_with_OCS_keywords()

cpl_error_code eris_ifu_update_wcs_with_OCS_keywords ( struct sofStruct *  sof)

Update WCS coordinates from OCS cumulative offset keywords.

Parameters
sofSOF structure with exposure table
Returns
CPL_ERROR_NONE on success
Note
This function corrects WCS coordinates using telescope offset information:
  1. Finds reference exposure (first with CUMOFFS1=CUMOFFS2=0, or first exposure)
  2. Computes reference position: CRVAL_ref = CRVAL - CUMOFFS/3600
  3. Updates all exposures: CRVAL_new = CRVAL_ref + CUMOFFS/3600
Only active if USE_OCS environment variable is set
CUMOFFS1/CUMOFFS2 are cumulative telescope offsets in arcsec
Corrects both CRVAL1 (RA) and CRVAL2 (DEC) keywords
Logs detailed before/after coordinates for verification

Definition at line 3815 of file eris_ifu_jitter_static.c.

References CATCH, CHECK_ERROR_STATE, and TRY.

Referenced by eris_ifu_jitter_process_exposures().

◆ eris_image_get_valid_data_range()

cpl_error_code eris_image_get_valid_data_range ( cpl_image *  image,
cpl_size *  min,
cpl_size *  max 
)

Determine valid data range in spectral direction (find NaN-dominated rows)

Parameters
imageInput 2D image to analyze
minOutput: minimum valid row index (modified in place)
maxOutput: maximum valid row index (modified in place)
Returns
CPL_ERROR_NONE on success
Note
Scans first and last 200 rows to find rows with >50% NaN pixels
Sets min to last NaN-dominated row at start
Sets max to first NaN-dominated row at end
Used to trim edge planes in wavelength direction where calibration is poor

Definition at line 2222 of file eris_ifu_jitter_static.c.