ERIS Pipeline Reference Manual 1.9.2
Functions
IFU Cube Resampling and Combination

Functions

cpl_error_code eris_ifu_resample_save_cube (hdrl_resample_result *aCube, const char *procatg, const char *recipe, const char *filename, const cpl_parameterlist *parlist, cpl_frameset *frameset, cpl_boolean gen_phase3)
 Save resampled cube to FITS file in DEQ (Data-Error-Quality) format.
 
cpl_error_code eris_ifu_cube_collapse_mean_and_save (const char *pro_catg, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, cpl_boolean apply_flat, cpl_boolean is_pupil)
 -------------------------------------------------------------------------—‍/
 
cpl_error_code eris_ifu_combine (cubeType obj_type, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *pipefile_prefix)
 Resample and combine multiple IFU cubes into a single cube.
 
cpl_error_code eris_ifu_resample_trim_edge (hdrl_image *himg, int edge_trim)
 Trim edge pixels from hdrl_image by rejecting them.
 
cpl_error_code eris_ifu_combine_pbp (cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *input_cube_pro_catg, const char *filenameSpec, float *offsetx, float *offsety, const char *offunit, const char *recipe_name, const char *pipefile_prefix)
 Resample and combine cubes plane-by-plane (2D spatial resampling per wavelength)
 

Detailed Description

This module provides functions for resampling and combining IFU data cubes using the HDRL (High-level Data Reduction Library) resampling framework.

The module handles:

The resampling process transforms irregularly sampled IFU data onto a regular output grid defined by RA, DEC, and wavelength parameters. This is essential for combining observations with offsets (jitter/dithering) and for generating uniformly sampled data cubes.

Function Documentation

◆ eris_ifu_combine()

cpl_error_code eris_ifu_combine ( cubeType  obj_type,
cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  recipe_name,
const char *  pipefile_prefix 
)

Resample and combine multiple IFU cubes into a single cube.

Main function for combining multiple offset IFU cubes using HDRL resampling. Converts cube data to resampling tables, sets up the output grid, applies the specified resampling method, and saves the result.

Parameters
obj_typeCube type (OBJ, STD, PSF, etc.)
framesetInput frameset containing cubes to combine
parlistRecipe parameters
recipe_nameRecipe name
pipefile_prefixOutput filename prefix
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
Checks maximum distance between cube centers against threshold
Supports various resampling methods (nearest, linear, Lanczos, drizzle, etc.)
Output saved with DFS-compliant headers and Phase 3 keywords
Edge trimming applied to input cubes if specified

Definition at line 2142 of file eris_ifu_resample.c.

References eris_check_error_code(), eris_ifu_extract_frameset(), eris_ifu_free_propertylist(), eris_ifu_free_string(), eris_ifu_jitter_get_procatg_and_filename(), eris_ifu_resample_save_cube(), eris_ifu_save_image(), hdrl_image_delete(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_image_get_mask(), hdrl_imagelist_collapse_mean(), hdrl_parameter_delete(), hdrl_resample_compute(), and hdrl_resample_result_delete().

◆ eris_ifu_combine_pbp()

cpl_error_code eris_ifu_combine_pbp ( cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  input_cube_pro_catg,
const char *  filenameSpec,
float *  offsetx,
float *  offsety,
const char *  offunit,
const char *  recipe_name,
const char *  pipefile_prefix 
)

Resample and combine cubes plane-by-plane (2D spatial resampling per wavelength)

Combines multiple IFU cubes by resampling each wavelength plane independently in 2D spatial coordinates. This approach is used when full 3D resampling would exceed size limits or when spatial-only resampling is preferred.

Parameters
framesetInput frameset containing cubes
parlistRecipe parameters
input_cube_pro_catgProduct category of input cubes
filenameSpecOutput filename suffix
offsetxUser-defined X offsets (or NULL)
offsetyUser-defined Y offsets (or NULL)
offunitOffset units ("pix" or "arcsec")
recipe_nameRecipe name
pipefile_prefixOutput filename prefix
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
Each wavelength plane is resampled independently in RA-DEC space
Output cube has same wavelength sampling as inputs
More memory efficient than full 3D resampling for large cubes
Exposure time maps are computed for flux calibration

Definition at line 2462 of file eris_ifu_resample.c.

References eris_check_error_code(), eris_ifu_extract_frameset(), eris_ifu_free_string(), eris_ifu_resample_save_cube(), eris_ifu_resample_trim_edge(), eris_ifu_save_deq_image(), eris_ifu_save_image_phase3(), eris_pfits_get_dit(), eris_pfits_get_ndit(), hdrl_image_create(), hdrl_image_delete(), hdrl_image_duplicate(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_image_get_mask(), hdrl_image_get_median(), hdrl_image_reject_from_mask(), hdrl_image_sub_scalar(), hdrl_imagelist_collapse_mean(), hdrl_imagelist_delete(), hdrl_imagelist_get_const(), hdrl_imagelist_new(), hdrl_imagelist_set(), hdrl_parameter_delete(), hdrl_resample_compute(), hdrl_resample_image_to_table(), and hdrl_resample_result_delete().

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_cube_collapse_mean_and_save()

cpl_error_code eris_ifu_cube_collapse_mean_and_save ( const char *  pro_catg,
cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  recipe_name,
cpl_boolean  apply_flat,
cpl_boolean  is_pupil 
)

-------------------------------------------------------------------------—‍/

‍** ‍**

Collapse cube along wavelength axis to mean image and save with QC parameters

Loads a cube from frameset, performs mean collapse along the wavelength (Z) axis, and saves the resulting 2D image in DEQ format. For pupil frames, computes QC parameters for pupil centering shifts. Optionally creates an exposure map at the central wavelength plane.

Parameters
pro_catgCube product category tag
framesetInput frameset containing the cube
parlistRecipe parameters
recipe_nameRecipe name for output file naming
apply_flatIf TRUE, creates exposure map at central wavelength
is_pupilIf TRUE, computes and adds pupil shift QC parameters
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
Output filenames depend on pro_catg: *_obj_cube_mean.fits, *_std_cube_mean.fits, etc.
Exposure map output: <recipe_name>_exposure_map.fits
For pupil frames: adds QC PUPIL0 SHIFTX/SHIFTY keywords (offset from center in pixels)
NaN values and bad pixels are rejected before collapse
Edge trimming is applied if specified in recipe parameters

Definition at line 1752 of file eris_ifu_resample.c.

References eris_check_error_code(), eris_ifu_free_propertylist(), eris_ifu_resample_trim_edge(), eris_ifu_save_deq_image(), eris_ifu_save_image_phase3(), eris_pfits_get_dit(), eris_pfits_get_ndit(), eris_pfits_put_qc(), eris_qclog_add_double_f(), eris_qclog_init(), hdrl_image_create(), hdrl_image_delete(), hdrl_image_get_error(), hdrl_image_get_image(), hdrl_image_get_mask(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_reject_from_mask(), hdrl_imagelist_collapse_mean(), hdrl_imagelist_create(), and hdrl_imagelist_delete().

Referenced by eris_stdstar_reduction_common().

◆ eris_ifu_resample_save_cube()

cpl_error_code eris_ifu_resample_save_cube ( hdrl_resample_result *  aCube,
const char *  procatg,
const char *  recipe,
const char *  filename,
const cpl_parameterlist *  parlist,
cpl_frameset *  frameset,
cpl_boolean  gen_phase3 
)

Save resampled cube to FITS file in DEQ (Data-Error-Quality) format.

Saves the resampled cube produced by HDRL to a multi-extension FITS file with:

  • Primary HDU: Empty with header only
  • Extension 1 (DATA): Data cube
  • Extension 2 (ERRS): Error cube (RMSE type)
  • Extension 3 (QUAL): Quality/bad pixel map cube (16-bit flags)

The function handles proper header construction including WCS, PRODCATG keywords, and optional Phase 3 metadata.

Parameters
aCubeHDRL resampling result containing cube and header
procatgFITS product category (e.g., "OBJ_CUBE_COMBINED")
recipeRecipe name
filenameOutput FITS filename
parlistInput recipe parameters
framesetInput frameset for DFS product saving
gen_phase3If TRUE, add ESO Phase 3 compliant keywords
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
CDELT3 keyword is removed and replaced with CD3_3
CUNIT3 is set to "um" (microns) if not present
BUNIT is set to default ADU units if not present
The cube is saved in native data type (preserving precision)

Definition at line 900 of file eris_ifu_resample.c.

References eris_check_error_code(), eris_ifu_free_propertylist(), eris_ifu_heades_add_hduclass_common(), eris_ifu_heades_add_hduclass_data(), eris_ifu_heades_add_hduclass_errs(), eris_ifu_heades_add_hduclass_qual(), eris_ifu_sdp_properties_collect(), eris_ifu_sdp_properties_delete(), eris_ifu_sdp_properties_update(), and eris_ifu_split3_hdrl_imagelist().

Referenced by eris_ifu_combine(), and eris_ifu_combine_pbp().

◆ eris_ifu_resample_trim_edge()

cpl_error_code eris_ifu_resample_trim_edge ( hdrl_image *  himg,
int  edge_trim 
)

Trim edge pixels from hdrl_image by rejecting them.

Rejects edge_trim pixels from all four edges of the image by marking them as bad pixels in the hdrl_image bad pixel mask.

Parameters
himgHDRL image to be trimmed (modified in place)
edge_trimNumber of pixels to trim from each edge
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
If edge_trim >= half the image size, edge_trim is reset to 0 with warning
Uses FITS pixel convention (1-indexed)
Image data is not deleted, just marked as bad

Definition at line 2387 of file eris_ifu_resample.c.

References eris_check_error_code(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), and hdrl_image_reject().

Referenced by eris_ifu_combine_pbp(), and eris_ifu_cube_collapse_mean_and_save().