ERIS Pipeline Reference Manual 1.8.15
Functions
Sky Tweaking and Subtraction

Functions

int eris_ifu_plot_cube_background (cpl_imagelist *obj)
 Extract background spectrum from cube and plot it.
 
cpl_imagelist * eris_ifu_sky_tweak (cpl_imagelist *obj, cpl_imagelist *sky, const cpl_propertylist *header, float min_frac, int tbsub, int skip_last, int stretch, int stretch_degree, int stretch_resampling, int plot, cpl_imagelist **new_sky)
 Main sky tweaking and subtraction function.
 

Detailed Description

This module provides advanced sky subtraction algorithms for IFU spectroscopy, including OH line emission correction and thermal background removal.

Sky tweaking corrects for temporal variations in sky emission between object and sky observations. The main operations include:

The algorithm separates the sky spectrum into continuum and line regions, fits scaling factors for OH line bands, and models thermal emission.

Function Documentation

◆ eris_ifu_plot_cube_background()

int eris_ifu_plot_cube_background ( cpl_imagelist *  obj)

Extract background spectrum from cube and plot it.

Parameters
objInput data cube
Returns
0 on success, -1 on error

This function creates an object mask to identify background pixels, extracts the background spectrum, and displays it using gnuplot.

Note
Requires gnuplot for visualization
Uses 30% threshold for mask creation

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if input is NULL

Definition at line 173 of file eris_ifu_sky_tweak.c.

References eris_ifu_lcorr_create_object_mask().

◆ eris_ifu_sky_tweak()

cpl_imagelist * eris_ifu_sky_tweak ( cpl_imagelist *  obj,
cpl_imagelist *  sky,
const cpl_propertylist *  header,
float  min_frac,
int  tbsub,
int  skip_last,
int  stretch,
int  stretch_degree,
int  stretch_resampling,
int  plot,
cpl_imagelist **  new_sky 
)

Main sky tweaking and subtraction function.

Parameters
objObject cube to be sky-subtracted
skySky observation cube
headerProperty list with WCS keywords (NAXIS3/CRVAL3/CDELT3/CRPIX3)
min_fracMinimum fraction of pixels for background (e.g., 0.3 = 30%)
tbsubFlag: subtract thermal background from obj (1=yes, 0=no)
skip_lastFlag: skip last wavelength sub-band in scaling (1=yes, 0=no)
stretchFlag: apply sky stretching before subtraction (1=yes, 0=no)
stretch_degreePolynomial degree for sky stretching (typically 2-4)
stretch_resamplingResampling method: 1=linear, 2=spline
plotDebug plotting flag (>0 enables plots)
new_skyOutput: corrected sky cube (allocated by function)
Returns
Sky-subtracted object cube, or NULL on error

This is the main entry point for advanced sky subtraction. The algorithm:

  1. Optionally stretches sky spectrum to align OH lines with object
  2. Creates object mask to identify background pixels
  3. Extracts background spectra from object and sky cubes
  4. Fits OH vibrational band scaling factors (19-20 sub-bands)
  5. Models and removes thermal background emission
  6. Applies corrections to sky cube and subtracts from object
Note
The new_sky cube is created by this function and must be deallocated by caller
Input cubes must have identical dimensions
Thermal background uses Planck function fit with 3 parameters
If thermal background fit fails, retry with 98% clipping

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any input pointer is NULL
  • CPL_ERROR_ILLEGAL_INPUT if dimensions mismatch or invalid parameters

Definition at line 235 of file eris_ifu_sky_tweak.c.

References eris_check_error_code(), eris_ifu_lcorr_create_lambda_vector(), and eris_ifu_lcorr_create_object_mask().

Referenced by eris_ifu_jitter_process_cubes().