ERIS Pipeline Reference Manual 1.9.2
Functions
ESO Science Data Product (SDP) Format Support

Functions

eris_ifu_sdp_properties * eris_ifu_sdp_properties_new (void)
 Allocate and initialize new SDP properties structure.
 
void eris_ifu_sdp_properties_delete (eris_ifu_sdp_properties *aProperties)
 Free SDP properties structure and all contained data.
 
const char * eris_ifu_pfits_get_origfile (const cpl_propertylist *aHeaders)
 Get ORIGFILE keyword value from FITS header.
 
eris_ifu_sdp_properties * eris_ifu_sdp_properties_collect (hdrl_resample_result *aCube, cpl_frameset *set, const cpl_parameterlist *parlist, const char *recipe_name)
 Collect all SDP metadata from cube, frameset, and parameters.
 
cpl_error_code eris_ifu_cplarray_sort (cpl_array *aArray, cpl_boolean aOrder)
 Sort CPL array in place using quicksort.
 
cpl_error_code eris_ifu_sdp_properties_update (cpl_propertylist *aHeader, const eris_ifu_sdp_properties *aProperties)
 Update FITS header with ESO Science Data Product keywords.
 

Detailed Description

This module provides functionality for creating ESO Science Data Product (SDP) compliant FITS headers and managing Phase 3 metadata for ERIS IFU data products.

The module handles:

The SDP properties structure aggregates all required metadata which is then written to FITS headers using standardized ESO keywords and formatting.

Function Documentation

◆ eris_ifu_cplarray_sort()

cpl_error_code eris_ifu_cplarray_sort ( cpl_array *  aArray,
cpl_boolean  aOrder 
)

Sort CPL array in place using quicksort.

Sorts the elements of a CPL array in ascending or descending order using the standard library quicksort function. Supports arrays of type double, float, int, long, and string.

Parameters
aArrayArray to sort (modified in place)
aOrderSort order: CPL_TRUE for ascending, CPL_FALSE for descending
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
The array must not contain invalid values
The array is sorted in place - original order is lost
String arrays are sorted lexicographically
Returns CPL_ERROR_ILLEGAL_INPUT for unsupported array types

Definition at line 1440 of file eris_ifu_sdp.c.

Referenced by eris_ifu_sdp_properties_update().

◆ eris_ifu_pfits_get_origfile()

const char * eris_ifu_pfits_get_origfile ( const cpl_propertylist *  aHeaders)

Get ORIGFILE keyword value from FITS header.

Retrieves the original filename from the FITS header ORIGFILE keyword. This tracks the name of the file as originally created by the instrument.

Parameters
aHeadersProperty list (FITS header) to query
Returns
Pointer to ORIGFILE string value, or NULL on error
Note
The returned pointer is to internal data - do not free
Sets CPL error if keyword is missing or wrong type

Definition at line 851 of file eris_ifu_sdp.c.

Referenced by eris_ifu_sdp_properties_collect().

◆ eris_ifu_sdp_properties_collect()

eris_ifu_sdp_properties * eris_ifu_sdp_properties_collect ( hdrl_resample_result *  aCube,
cpl_frameset *  set,
const cpl_parameterlist *  parlist,
const char *  recipe_name 
)

Collect all SDP metadata from cube, frameset, and parameters.

Main function for gathering ESO Science Data Product metadata from various sources. Processes raw and calibrated data to compute quality metrics and collect observation information required for Phase 3 compliant headers.

The function performs:

  • Frame organization (raw/processed object/sky/std frames)
  • Observation metadata collection (OBIDs, program IDs, MJDs, exposure times)
  • FWHM computation from ASM data with wavelength correction
  • Exposure time calculation from exposure map
  • Provenance tracking (ARCFILE/ANCESTOR/raw filenames)
  • Pixel noise computation from flux-calibrated cubes
  • Spectral resolution from wavelength calibration
  • AB magnitude limit calculation using HDRL
  • Wavelength range determination from cube WCS
  • Associated file list creation (ASSON keywords)
Parameters
aCubeHDRL resampling result with cube and header
setComplete frameset with raw and processed data
parlistRecipe parameters
recipe_nameRecipe name ("jitter" or "stdstar")
Returns
Pointer to populated eris_ifu_sdp_properties structure, or NULL on error
Note
The returned structure must be freed with eris_ifu_sdp_properties_delete()
FWHM calculation differs for jitter (from ASM) vs stdstar (hardcoded 7.18") @note Spectral resolution is obtained from wavelength calibration map @note AB magnitude limit is computed using both HDRL method and simple formula @note For single object cubes, first product in associated file list is skipped @note Flux calibration status is set to ABSOLUTE (CPL_TRUE) @note SPECSYS is set to "TOPOCENT" (topocentric reference frame)
Wavelength range is converted from microns to nm for FITS keywords
Fallback wavelength error of 0.026 Angstrom is used

Definition at line 1092 of file eris_ifu_sdp.c.

References eris_check_error_code(), eris_ifu_get_band(), eris_ifu_get_band_resolution(), eris_ifu_pfits_get_origfile(), eris_ifu_sdp_properties_new(), eris_pfits_get_ancestor(), eris_pfits_get_arcfile(), eris_pfits_get_dit(), eris_pfits_get_mjdobs(), eris_pfits_get_ndit(), eris_pfits_get_obsid(), eris_pfits_get_pipefile(), eris_pfits_get_progid(), eris_pfits_get_raw_filename(), hdrl_collapse_mode_parameter_create(), hdrl_image_delete(), hdrl_image_get_image(), hdrl_imagelist_get_size(), hdrl_maglim_compute(), and hdrl_parameter_delete().

Referenced by eris_ifu_resample_save_cube().

◆ eris_ifu_sdp_properties_delete()

void eris_ifu_sdp_properties_delete ( eris_ifu_sdp_properties *  aProperties)

Free SDP properties structure and all contained data.

Deallocates an eris_ifu_sdp_properties structure including all dynamically allocated members (arrays, property lists, strings).

Parameters
aPropertiesPointer to SDP properties structure to free
Note
Safe to call with NULL pointer (no-op)
Frees: obid array, progid array, prov propertylist, asson array, assoc array (deprecated), prodcatg, specsys, obstech, referenc strings
procsoft string is NOT freed (points to header data)

Definition at line 813 of file eris_ifu_sdp.c.

Referenced by eris_ifu_resample_save_cube().

◆ eris_ifu_sdp_properties_new()

eris_ifu_sdp_properties * eris_ifu_sdp_properties_new ( void  )

Allocate and initialize new SDP properties structure.

Creates a new eris_ifu_sdp_properties structure with all fields initialized to zero/NULL. This structure holds all metadata required for ESO Science Data Product headers.

Returns
Pointer to allocated structure, or NULL on allocation failure
Note
The returned structure must be freed with eris_ifu_sdp_properties_delete()
All pointer fields are initialized to NULL
All numeric fields are initialized to 0

Definition at line 791 of file eris_ifu_sdp.c.

Referenced by eris_ifu_sdp_properties_collect().

◆ eris_ifu_sdp_properties_update()

cpl_error_code eris_ifu_sdp_properties_update ( cpl_propertylist *  aHeader,
const eris_ifu_sdp_properties *  aProperties 
)

Update FITS header with ESO Science Data Product keywords.

Writes all collected SDP metadata to the FITS header in ESO Phase 3 compliant format. This includes observation information, data quality metrics, provenance, wavelength range, flux calibration status, and associated files.

The function:

  • Clears existing SDP keywords using regex pattern
  • Validates input arrays match expected sizes
  • Writes spatial center (RA, DEC)
  • Writes temporal information (MJD-OBS, MJD-END, EXPTIME, TEXPTIME, NCOMBINE)
  • Writes observation blocks (OBID1, OBID2, ...) removing duplicates
  • Writes program IDs (PROG_ID, PROGID1, ...) with MULTI for multiple programs
  • Writes provenance (PROV1, PROV2, ...)
  • Writes associated files (ASSON1, ASSON2, ...)
  • Writes product metadata (PRODCATG, PROCSOFT, OBSTECH, FLUXCAL)
  • Writes wavelength info (WAVELMIN, WAVELMAX in nm, SPEC_RES, SPECSYS)
  • Writes quality metrics (SKY_RES, PIXNOISE, ABMAGLIM)
  • Writes reference (REFERENC)
Parameters
aHeaderFITS header propertylist to update (modified in place)
aPropertiesSDP properties structure with all metadata
Returns
CPL_ERROR_NONE on success, error code otherwise
Note
Header is validated: obid/progid arrays must match ncombine size
OBID values are sorted and duplicates removed before writing
Program IDs: single program writes PROG_ID directly, multiple writes "MULTI" + PROGIDn
Wavelength range is converted from microns to nanometers (* 1000)
SKY_RES comment indicates "measured" or "default" based on sign
Negative skyres values indicate defaults, absolute value is written
Associated files list skips first entry if nobj==1 (uncalibrated cube)

Definition at line 1509 of file eris_ifu_sdp.c.

References eris_check_error_code(), and eris_ifu_cplarray_sort().

Referenced by eris_ifu_resample_save_cube().