|
ERIS Pipeline Reference Manual 1.9.2
|
Wavelength Calibration Functions for ERIS IFU. More...
#include <stdbool.h>#include <string.h>#include <math.h>#include <eris_utils.h>#include "eris_ifu_error.h"#include "eris_ifu_utils.h"#include "eris_ifu_functions.h"#include "eris_ifu_dfs.h"#include "eris_ifu_wavecal_static.h"#include "eris_ifu_debug.h"Go to the source code of this file.
Functions | |
| cpl_error_code | eris_ifu_wave_get_arc_images (cpl_frameset *arcFrames, int exposureCorrectionMode, int *arcImgCnt, hdrl_imagelist **arcImages, int **lampStates, ifsBand *band, ifsPreopticsScale *scale, ifsInstrument *instrument, double saturation_threshold, cpl_table **qclog) |
| Load and preprocess arc lamp images for wavelength calibration. | |
| hdrl_image * | eris_ifu_wave_collapse_arc_images (cpl_table *darkTable, cpl_table *litTable, int lampState, float dit, int exposureCorrectionMode, double threshold, cpl_table **qclog) |
| Collapse multiple arc images with dark subtraction. | |
| cpl_image * | eris_ifu_wave_get_calImg (int arcImagesCnt, hdrl_imagelist *arcImages, int *lampStates, ifsBand band, ifsInstrument instrument, struct waveSetupStruct waveSetup, const char *refLineTableFileName, const char *firstFitTableFileName, cpl_bivector *slitPos, struct waveTablesStruct *tables, int productDepth, cpl_frameset *fs, const cpl_parameterlist *parlist, cpl_table *qclog) |
| Generate wavelength calibration image from arc lamp data. | |
| cpl_bivector * | eris_ifu_wave_get_refLines (const char *refLineTableFileName, ifsInstrument instrument, int lampState) |
| Load reference arc line wavelengths for specified lamp configuration. | |
| cpl_vector * | eris_ifu_wave_collapse_slitlet (const cpl_image *dataImg, int center) |
| Collapse slitlet spatially to create 1D spectrum. | |
| cpl_polynomial * | eris_ifu_get_first_fit (cpl_image **spectra, int *lampStates, int spectrumCnt, int slitlet, int ffOffsetIn, int *ffOffsetOut, struct waveSetupStruct waveSetup, cpl_table *firstFitTable, cpl_table *fittingDumpTable, cpl_table *coeffDumpTable) |
| Generate initial wavelength fit for a slitlet. | |
| cpl_error_code | eris_ifu_fit_all_lines (const char *recipe_name, int sIdx, const double *slitletStart, const double *slitletEnd, int arcImgCnt, const cpl_image **dataImg, cpl_bivector **refLines, struct waveSetupStruct waveSetup, cpl_polynomial *firstFit, cpl_polynomial *allFits[ERIS_IFU_DETECTOR_SIZE_Y], cpl_table *dumpTable, cpl_table *columnCoeffRawTable, cpl_table *columnCoeffSmoothedTable, cpl_table *smoothingCoeffTable) |
| Fit all reference lines in a slitlet across detector columns. | |
| cpl_error_code | eris_ifu_wave_smooth_coeffs (int sIdx, int start, int end, int fitDegree, cpl_polynomial *allFits[ERIS_IFU_DETECTOR_SIZE_Y], cpl_table *columnCoeffSmoothedTable, cpl_table *smoothingCoeffTable) |
| Smooth polynomial coefficients across detector columns. | |
| cpl_error_code | eris_ifu_wave_pos_err (cpl_polynomial *allFits[ERIS_IFU_DETECTOR_SIZE_Y], cpl_table *fitTable, ifsBand band) |
| Compute wavelength errors and spectral resolution. | |
| void | eris_ifu_wave_save_spectrum (cpl_image **collapsedSpectra, int aIdx, cpl_vector *collapsedSpectrum, int sIdx, cpl_size nRows, int lampStatus, ifsBand band, ifsInstrument instrument, cpl_bivector *refLines, int productDepth) |
| Save collapsed spectrum to product file. | |
| cpl_table * | eris_ifu_wave_get_firstFitTable (const char *firstFitTableFileName, ifsInstrument instrument, ifsBand band) |
| Load first fit table for instrument and band. | |
| cpl_error_code | eris_ifu_get_dispersion (ifsBand band, double *dispersion) |
| Get spectral dispersion for instrument band. | |
| cpl_image * | eris_ifu_wave_resampled_arc_image (const cpl_image *arcImg, const cpl_image *waveCalImg, ifsBand band, double minLambda, double maxLambda, cpl_propertylist *plist, int axisNumber) |
| Resample arc image to uniform wavelength grid. | |
| cpl_error_code | eris_ifu_save_resampled_arc_images (int arcImgCnt, const cpl_image **dataImg, const cpl_image *waveCalImg, ifsBand band, int *lampStates, cpl_frameset *frameset, const cpl_parameterlist *parlist) |
| Save resampled arc images as FITS product. | |
| cpl_error_code | eris_ifu_read_wave_setup (const char *filename, ifsBand band, struct waveSetupStruct *waveSetup) |
| Read wavelength setup parameters from configuration file. | |
| cpl_error_code | eris_ifu_wave_init_tables (struct waveTablesStruct *tables) |
| Initialize wavelength fitting tables. | |
| cpl_table * | eris_ifu_wave_create_fitting_table (void) |
| Create fitting table for line fit results. | |
| cpl_error_code | eris_ifu_wave_fill_fitting_table (cpl_table *table, int row, int slitlet, int index, int arcImgIdx, int position, double wavelength, struct gaussParStruct *gaussPar) |
| Fill fitting table row with Gaussian fit results. | |
| cpl_table * | eris_ifu_wave_create_coeff_table (int size, int polynomialDegree) |
| Create coefficient table for polynomial fits. | |
| cpl_error_code | eris_ifu_wave_fill_coeff_table (cpl_table *table, int row, int idx, int nLines, cpl_polynomial *polynomial) |
| Fill coefficient table row with polynomial data. | |
| cpl_error_code | eris_ifu_wave_save_fitting_tables (struct waveTablesStruct *tables, ifsInstrument instrument, ifsBand band, struct waveSetupStruct waveSetup, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name) |
| Save all wavelength fitting tables to FITS file. | |
| void | eris_ifu_wave_free_tables (struct waveTablesStruct *tables) |
| Free all wavelength fitting tables. | |
| void | eris_ifu_wave_clear_tables (struct waveTablesStruct *tables) |
| Clear wavelength table pointers without freeing. | |
Wavelength Calibration Functions for ERIS IFU.
This module provides comprehensive wavelength calibration functionality for the ERIS IFU pipeline. It implements the complete wavelength solution pipeline including:
The wavelength calibration uses arc lamp spectra (Ar, Ne, Kr, Xe) to establish the wavelength-pixel relationship across the detector. A polynomial fit is performed for each detector column, with coefficients smoothed spatially to reduce noise.
Definition in file eris_ifu_wavecal_static.c.
| cpl_error_code eris_ifu_fit_all_lines | ( | const char * | recipe_name, |
| int | sIdx, | ||
| const double * | slitletStart, | ||
| const double * | slitletEnd, | ||
| int | arcImgCnt, | ||
| const cpl_image ** | dataImg, | ||
| cpl_bivector ** | refLines, | ||
| struct waveSetupStruct | waveSetup, | ||
| cpl_polynomial * | firstFit, | ||
| cpl_polynomial * | allFits[ERIS_IFU_DETECTOR_SIZE_Y], | ||
| cpl_table * | dumpTable, | ||
| cpl_table * | columnCoeffRawTable, | ||
| cpl_table * | columnCoeffSmoothedTable, | ||
| cpl_table * | smoothingCoeffTable | ||
| ) |
Fit all reference lines in a slitlet across detector columns.
This function processes a single slitlet, fitting all reference arc lines in each detector column within the slitlet. For each column:
After all columns are processed, polynomial coefficients are smoothed spatially to reduce noise and improve wavelength solution stability.
| recipe_name | Recipe name (REC_NAME_WAVECAL or REC_NAME_DISTORTION) |
| sIdx | Slitlet index to process |
| slitletStart | Array of slitlet start positions |
| slitletEnd | Array of slitlet end positions |
| arcImgCnt | Number of arc images |
| dataImg | Array of arc lamp images |
| refLines | Array of reference line bivectors (per image) |
| waveSetup | Wavelength setup parameters |
| firstFit | Initial wavelength fit polynomial |
| allFits | Output: array of polynomial fits for all columns |
| dumpTable | Output: table of line fit results |
| columnCoeffRawTable | Output: raw polynomial coefficients |
| columnCoeffSmoothedTable | Output: smoothed polynomial coefficients |
| smoothingCoeffTable | Output: smoothing polynomial coefficients |
Definition at line 1274 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_1d_polynomial_fit(), eris_ifu_free_vector(), eris_ifu_wave_fill_coeff_table(), eris_ifu_wave_fill_fitting_table(), eris_ifu_wave_smooth_coeffs(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_error_code eris_ifu_get_dispersion | ( | ifsBand | band, |
| double * | dispersion | ||
| ) |
Get spectral dispersion for instrument band.
Returns the spectral dispersion (micrometers per pixel) for the specified instrument band. Used for wavelength axis calibration and spectral resolution calculations.
| band | Instrument band identifier |
| dispersion | Output: dispersion in µm/pixel |
Definition at line 1794 of file eris_ifu_wavecal_static.c.
Referenced by eris_ifu_wave_pos_err(), and eris_ifu_wave_resampled_arc_image().
| cpl_polynomial * eris_ifu_get_first_fit | ( | cpl_image ** | spectra, |
| int * | lampStates, | ||
| int | spectrumCnt, | ||
| int | slitlet, | ||
| int | ffOffsetIn, | ||
| int * | ffOffsetOut, | ||
| struct waveSetupStruct | waveSetup, | ||
| cpl_table * | firstFitTable, | ||
| cpl_table * | fittingDumpTable, | ||
| cpl_table * | coeffDumpTable | ||
| ) |
Generate initial wavelength fit for a slitlet.
Generates the first polynomial fit relating wavelength to pixel position for a specific slitlet. This initial fit is used as a starting point for finding lines in all detector columns. The function:
| spectra | Array of collapsed spectra images (one per lamp state) |
| lampStates | Array of lamp state codes |
| spectrumCnt | Number of spectra |
| slitlet | Slitlet number to process |
| ffOffsetIn | Input pixel offset from previous fit |
| ffOffsetOut | Output: computed pixel offset for this slitlet |
| waveSetup | Wavelength setup parameters |
| firstFitTable | Table of reference line positions |
| fittingDumpTable | Table to store fit results |
| coeffDumpTable | Table to store polynomial coefficients |
Definition at line 1099 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_ifu_1d_polynomial_fit(), eris_ifu_free_table(), eris_ifu_free_vector(), eris_ifu_get_lampString(), eris_ifu_wave_fill_coeff_table(), eris_ifu_wave_fill_fitting_table(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_error_code eris_ifu_read_wave_setup | ( | const char * | filename, |
| ifsBand | band, | ||
| struct waveSetupStruct * | waveSetup | ||
| ) |
Read wavelength setup parameters from configuration file.
Loads band-specific wavelength calibration parameters from a FITS table, including search ranges for line fitting and expected line width (FWHM). These parameters control the wavelength calibration algorithm behavior.
| filename | Path to wavelength setup FITS table |
| band | Instrument band to load parameters for |
| waveSetup | Output: structure filled with setup parameters |
Definition at line 2200 of file eris_ifu_wavecal_static.c.
References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_ifu_free_table(), eris_ifu_get_bandString(), and TRY.
Referenced by eris_ifu_dist_wave().
| cpl_error_code eris_ifu_save_resampled_arc_images | ( | int | arcImgCnt, |
| const cpl_image ** | dataImg, | ||
| const cpl_image * | waveCalImg, | ||
| ifsBand | band, | ||
| int * | lampStates, | ||
| cpl_frameset * | frameset, | ||
| const cpl_parameterlist * | parlist | ||
| ) |
Save resampled arc images as FITS product.
Resamples all arc lamp images to wavelength coordinates and saves them as a multi-extension FITS file. Each extension contains one resampled arc image with complete WCS information. This product is useful for verifying wavelength calibration quality and identifying problematic spectral regions.
| arcImgCnt | Number of arc images |
| dataImg | Array of arc lamp images |
| waveCalImg | Wavelength calibration image |
| band | Instrument band |
| lampStates | Array of lamp state codes |
| frameset | Frameset for product header |
| parlist | Parameter list for product header |
Definition at line 2105 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, CATCH_MSGS, eris_ifu_free_image(), eris_ifu_free_propertylist(), eris_ifu_get_lampString(), eris_ifu_save_image_dbg(), eris_ifu_wave_resampled_arc_image(), RECOVER, and TRY.
Referenced by eris_ifu_wave_get_calImg().
| void eris_ifu_wave_clear_tables | ( | struct waveTablesStruct * | tables | ) |
Clear wavelength table pointers without freeing.
Sets all table pointers in the structure to NULL without freeing the tables. Use when tables have been transferred elsewhere or when re-initializing the structure.
| tables | Structure to clear |
Definition at line 2736 of file eris_ifu_wavecal_static.c.
Referenced by eris_ifu_dist_wave().
| hdrl_image * eris_ifu_wave_collapse_arc_images | ( | cpl_table * | darkTable, |
| cpl_table * | litTable, | ||
| int | lampState, | ||
| float | dit, | ||
| int | exposureCorrectionMode, | ||
| double | threshold, | ||
| cpl_table ** | qclog | ||
| ) |
Collapse multiple arc images with dark subtraction.
This function processes arc lamp frames with a specific lamp state and DIT. It collapses multiple frames using median (>=3 frames) or mean (1-2 frames) combination. Dark frames with matching DIT are collapsed and subtracted. QC parameters are computed for all frames and the final difference image.
| darkTable | Table of dark frame information |
| litTable | Table of illuminated arc frame information |
| lampState | Lamp state code to process |
| dit | DIT (detector integration time) to match |
| exposureCorrectionMode | Exposure correction method |
| threshold | Saturation threshold for pixel flagging |
| qclog | Output: QC log table with frame statistics |
Definition at line 288 of file eris_ifu_wavecal_static.c.
References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_free_hdrl_image(), eris_ifu_free_hdrl_imagelist(), eris_ifu_load_exposure_file(), eris_qclog_add_double(), eris_qclog_add_int(), eris_qclog_init(), hdrl_image_delete(), hdrl_image_duplicate(), hdrl_image_get_image(), hdrl_image_get_mean(), hdrl_image_get_median(), hdrl_image_sub_image(), hdrl_imagelist_collapse_mean(), hdrl_imagelist_collapse_median(), hdrl_imagelist_get(), hdrl_imagelist_get_size(), hdrl_imagelist_new(), hdrl_imagelist_set(), and TRY.
Referenced by eris_ifu_wave_get_arc_images().
| cpl_vector * eris_ifu_wave_collapse_slitlet | ( | const cpl_image * | dataImg, |
| int | center | ||
| ) |
Collapse slitlet spatially to create 1D spectrum.
Return a CPL vector which is an collapsed spectrum of a slitlet.
Extracts a 1D spectrum from an arc image by collapsing a slitlet in the spatial direction. Uses a median of pixels within ±10 pixels of the specified center column to reduce noise while preserving line shapes.
| dataImg | Input arc lamp image |
| center | Center column of slitlet to collapse |
Definition at line 1023 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_free_vector(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_table * eris_ifu_wave_create_coeff_table | ( | int | size, |
| int | polynomialDegree | ||
| ) |
Create coefficient table for polynomial fits.
Creates a table to store polynomial coefficients with columns for:
| size | Number of rows to create |
| polynomialDegree | Maximum polynomial degree (determines array size) |
Definition at line 2468 of file eris_ifu_wavecal_static.c.
References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.
Referenced by eris_ifu_wave_init_tables().
| cpl_table * eris_ifu_wave_create_fitting_table | ( | void | ) |
Create fitting table for line fit results.
Creates a table structure to store Gaussian fit results for arc lines. The table includes columns for:
Definition at line 2345 of file eris_ifu_wavecal_static.c.
References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.
Referenced by eris_ifu_wave_init_tables().
| cpl_error_code eris_ifu_wave_fill_coeff_table | ( | cpl_table * | table, |
| int | row, | ||
| int | idx, | ||
| int | nLines, | ||
| cpl_polynomial * | polynomial | ||
| ) |
Fill coefficient table row with polynomial data.
Extracts polynomial coefficients and stores them in a table row along with metadata (index, number of lines used, polynomial degree).
| table | Coefficient table to update |
| row | Row index to fill |
| idx | Slitlet or column identifier |
| nLines | Number of lines used in polynomial fit |
| polynomial | Polynomial to extract coefficients from |
Definition at line 2508 of file eris_ifu_wavecal_static.c.
References CATCH, CATCH_MSGS, CHECK_ERROR_STATE, and TRY.
Referenced by eris_ifu_fit_all_lines(), eris_ifu_get_first_fit(), and eris_ifu_wave_smooth_coeffs().
| cpl_error_code eris_ifu_wave_fill_fitting_table | ( | cpl_table * | table, |
| int | row, | ||
| int | slitlet, | ||
| int | index, | ||
| int | arcImgIdx, | ||
| int | position, | ||
| double | wavelength, | ||
| struct gaussParStruct * | gaussPar | ||
| ) |
Fill fitting table row with Gaussian fit results.
Populates a single row of the fitting table with line fit information including position, wavelength, Gaussian parameters, and fit data.
| table | Fitting table to update |
| row | Row index to fill |
| slitlet | Slitlet number |
| index | Column or block index |
| arcImgIdx | Arc image index |
| position | Expected line position (pixels) |
| wavelength | Reference wavelength (µm) |
| gaussPar | Gaussian fit parameters structure |
Definition at line 2401 of file eris_ifu_wavecal_static.c.
References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.
Referenced by eris_ifu_fit_all_lines(), and eris_ifu_get_first_fit().
| void eris_ifu_wave_free_tables | ( | struct waveTablesStruct * | tables | ) |
Free all wavelength fitting tables.
Deletes all tables in the waveTablesStruct and sets pointers to NULL. Safe to call even if some tables are already NULL.
| tables | Structure containing table pointers to free |
Definition at line 2715 of file eris_ifu_wavecal_static.c.
References eris_ifu_free_table().
| cpl_error_code eris_ifu_wave_get_arc_images | ( | cpl_frameset * | arcFrames, |
| int | exposureCorrectionMode, | ||
| int * | arcImgCnt, | ||
| hdrl_imagelist ** | arcImages, | ||
| int ** | lampStates, | ||
| ifsBand * | band, | ||
| ifsPreopticsScale * | scale, | ||
| ifsInstrument * | instrument, | ||
| double | saturation_threshold, | ||
| cpl_table ** | qclog | ||
| ) |
Load and preprocess arc lamp images for wavelength calibration.
Extract and preprocess arc images from frameset.
This function loads raw arc lamp frames, identifies lamp states and DITs, sorts frames by lamp configuration, and collapses multiple frames with the same lamp state. Dark frames are automatically identified and subtracted. Returns a list of preprocessed arc images ready for wavelength calibration.
| arcFrames | Input frameset containing arc and dark frames |
| exposureCorrectionMode | Exposure correction method (CDS, UTR, etc.) |
| arcImgCnt | Output: number of arc images produced |
| arcImages | Output: collapsed arc images (one per lamp state) |
| lampStates | Output: array of lamp state codes for each image |
| band | Output: instrument band (must be consistent across frames) |
| scale | Output: pre-optics scale (must be consistent) |
| instrument | Output: instrument identifier (SPIFFI/SPIFFIER) |
| saturation_threshold | Threshold for pixel saturation detection |
| qclog | Output: QC log table with frame statistics |
Definition at line 84 of file eris_ifu_wavecal_static.c.
References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_ifu_free_propertylist(), eris_ifu_free_string(), eris_ifu_free_table(), eris_ifu_get_band(), eris_ifu_get_callamp_status(), eris_ifu_get_dit(), eris_ifu_get_instrument(), eris_ifu_get_lampString(), eris_ifu_get_preopticsScale(), eris_ifu_wave_collapse_arc_images(), eris_qclog_init(), hdrl_imagelist_delete(), hdrl_imagelist_get_size(), hdrl_imagelist_new(), hdrl_imagelist_set(), SET_ERROR_MSG, and TRY.
| cpl_image * eris_ifu_wave_get_calImg | ( | int | arcImagesCnt, |
| hdrl_imagelist * | arcImages, | ||
| int * | lampStates, | ||
| ifsBand | band, | ||
| ifsInstrument | instrument, | ||
| struct waveSetupStruct | waveSetup, | ||
| const char * | refLineTableFileName, | ||
| const char * | firstFitTableFileName, | ||
| cpl_bivector * | slitPos, | ||
| struct waveTablesStruct * | tables, | ||
| int | productDepth, | ||
| cpl_frameset * | fs, | ||
| const cpl_parameterlist * | parlist, | ||
| cpl_table * | qclog | ||
| ) |
Generate wavelength calibration image from arc lamp data.
Return the wavelength calibration image.
This is the main wavelength calibration function. It processes arc lamp images to create a 2D wavelength calibration image where each pixel value represents the wavelength at that detector position. The processing includes:
| arcImagesCnt | Number of arc images to process |
| arcImages | List of preprocessed arc images |
| lampStates | Array of lamp state codes for each image |
| band | Instrument band |
| instrument | Instrument identifier (SPIFFI/SPIFFIER) |
| waveSetup | Wavelength setup parameters (ranges, sigma) |
| refLineTableFileName | Path to reference line table |
| firstFitTableFileName | Path to first fit table |
| slitPos | Slitlet positions (if NULL, uses default) |
| tables | Structure containing fitting tables |
| productDepth | Bitmask for intermediate product saving |
| fs | Frameset for product headers |
| parlist | Parameter list for product headers |
| qclog | QC log table |
Definition at line 593 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_fit_all_lines(), eris_ifu_free_bivector(), eris_ifu_free_image(), eris_ifu_free_polynomial(), eris_ifu_free_table(), eris_ifu_free_vector(), eris_ifu_get_first_fit(), eris_ifu_save_image_dbg(), eris_ifu_save_resampled_arc_images(), eris_ifu_wave_collapse_slitlet(), eris_ifu_wave_get_firstFitTable(), eris_ifu_wave_get_refLines(), eris_ifu_wave_pos_err(), eris_ifu_wave_save_spectrum(), eris_pfits_put_qc(), eris_qclog_add_double(), hdrl_image_add_image(), hdrl_image_get_image(), hdrl_image_get_image_const(), hdrl_imagelist_get(), hdrl_imagelist_get_const(), and TRY.
| cpl_table * eris_ifu_wave_get_firstFitTable | ( | const char * | firstFitTableFileName, |
| ifsInstrument | instrument, | ||
| ifsBand | band | ||
| ) |
Load first fit table for instrument and band.
Loads the table of initial fit parameters (reference line positions) for the specified instrument and spectral band. The table contains expected pixel positions of strong arc lines used to bootstrap the wavelength calibration.
| firstFitTableFileName | Path to first fit FITS table |
| instrument | Instrument identifier (SPIFFI/SPIFFIER) |
| band | Instrument band |
Definition at line 1726 of file eris_ifu_wavecal_static.c.
References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_ifu_free_string(), eris_ifu_free_table(), eris_ifu_get_bandString(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_bivector * eris_ifu_wave_get_refLines | ( | const char * | refLineTableFileName, |
| ifsInstrument | instrument, | ||
| int | lampState | ||
| ) |
Load reference arc line wavelengths for specified lamp configuration.
Return a bivector (lambda, intensitry) holding the arc lamp reference lines.
Loads reference arc line wavelengths and intensities from a FITS table for the specified instrument and lamp state. The table contains multiple extensions, one for each instrument/lamp combination. Lines marked as ignored are skipped. Wavelengths in nanometers are automatically converted to micrometers.
| refLineTableFileName | Path to reference line FITS table |
| instrument | Instrument identifier (SPIFFI/SPIFFIER) |
| lampState | Lamp state code (combination of AR, NE, KR, XE lamps) |
Definition at line 879 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_ifu_free_propertylist(), eris_ifu_free_table(), eris_ifu_free_vector(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_error_code eris_ifu_wave_init_tables | ( | struct waveTablesStruct * | tables | ) |
Initialize wavelength fitting tables.
Creates all tables needed to store wavelength calibration results:
| tables | Output: structure with pointers to created tables |
Definition at line 2295 of file eris_ifu_wavecal_static.c.
References CATCH, CHECK_ERROR_STATE, eris_ifu_wave_create_coeff_table(), eris_ifu_wave_create_fitting_table(), and TRY.
Referenced by eris_ifu_dist_wave().
| cpl_error_code eris_ifu_wave_pos_err | ( | cpl_polynomial * | allFits[ERIS_IFU_DETECTOR_SIZE_Y], |
| cpl_table * | fitTable, | ||
| ifsBand | band | ||
| ) |
Compute wavelength errors and spectral resolution.
For each successfully fitted reference line, this function:
The spectral resolution uses the Gaussian sigma from line fits converted to FWHM (2.355σ) and multiplied by the band dispersion.
| allFits | Array of wavelength polynomials for all columns |
| fitTable | Fitting table to update (modified in place) |
| band | Instrument band (for dispersion lookup) |
Definition at line 1543 of file eris_ifu_wavecal_static.c.
References CATCH, CHECK_ERROR_STATE, eris_ifu_get_dispersion(), and TRY.
Referenced by eris_ifu_wave_get_calImg().
| cpl_image * eris_ifu_wave_resampled_arc_image | ( | const cpl_image * | arcImg, |
| const cpl_image * | waveCalImg, | ||
| ifsBand | band, | ||
| double | minLambda, | ||
| double | maxLambda, | ||
| cpl_propertylist * | plist, | ||
| int | axisNumber | ||
| ) |
Resample arc image to uniform wavelength grid.
Resamples an arc lamp image from detector coordinates (pixel, row) to wavelength coordinates (pixel, wavelength) using the wavelength calibration image. Each detector column is interpolated from its non-uniform wavelength sampling to a uniform grid with constant dispersion. This enables direct visualization of arc line positions and wavelength coverage.
The wavelength axis is constructed with:
| arcImg | Input arc lamp image (detector coordinates) |
| waveCalImg | Wavelength calibration image |
| band | Instrument band (for dispersion) |
| minLambda | Minimum wavelength in output grid (µm) |
| maxLambda | Maximum wavelength in output grid (µm) |
| plist | Property list to update with WCS keywords |
| axisNumber | FITS axis number for wavelength (usually 2) |
Definition at line 1945 of file eris_ifu_wavecal_static.c.
References ASSURE, BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_1d_interpolation(), eris_ifu_free_double_array(), eris_ifu_free_string(), eris_ifu_free_vector(), eris_ifu_get_dispersion(), and TRY.
Referenced by eris_ifu_jitter_build_cube(), and eris_ifu_save_resampled_arc_images().
| cpl_error_code eris_ifu_wave_save_fitting_tables | ( | struct waveTablesStruct * | tables, |
| ifsInstrument | instrument, | ||
| ifsBand | band, | ||
| struct waveSetupStruct | waveSetup, | ||
| cpl_frameset * | frameset, | ||
| const cpl_parameterlist * | parlist, | ||
| const char * | recipe_name | ||
| ) |
Save all wavelength fitting tables to FITS file.
Saves all wavelength calibration fitting tables as extensions in a single FITS file. The primary header contains metadata (instrument, band, setup parameters), and each table is saved as a separate extension with descriptive EXTNAME keywords.
Tables saved (if not NULL):
| tables | Structure containing all fitting tables |
| instrument | Instrument identifier |
| band | Instrument band |
| waveSetup | Wavelength setup parameters |
| frameset | Frameset for product header |
| parlist | Parameter list for product header |
| recipe_name | Recipe name for product header |
Definition at line 2572 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_free_propertylist(), eris_ifu_get_bandString(), and TRY.
Referenced by eris_ifu_dist_wave().
| void eris_ifu_wave_save_spectrum | ( | cpl_image ** | collapsedSpectra, |
| int | aIdx, | ||
| cpl_vector * | collapsedSpectrum, | ||
| int | sIdx, | ||
| cpl_size | nRows, | ||
| int | lampStatus, | ||
| ifsBand | band, | ||
| ifsInstrument | instrument, | ||
| cpl_bivector * | refLines, | ||
| int | productDepth | ||
| ) |
Save collapsed spectrum to product file.
Internal helper function to collect and save collapsed spectra.
Organizes collapsed slitlet spectra into an image for saving. Spectra are arranged by slitlet block to match the detector geometry. On first call (sIdx=0), initializes the output image. On last call (sIdx=SLITLET_CNT-1), saves the complete image to FITS with appropriate headers including lamp state, band, and instrument information.
| collapsedSpectra | Array of spectrum images (one per arc image) |
| aIdx | Arc image index |
| collapsedSpectrum | Current collapsed spectrum to add |
| sIdx | Slitlet index |
| nRows | Number of rows in spectrum |
| lampStatus | Lamp state code |
| band | Instrument band |
| instrument | Instrument identifier |
| refLines | Reference line bivector |
| productDepth | Bitmask controlling product saving (bit 0) |
Definition at line 1607 of file eris_ifu_wavecal_static.c.
References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_free_propertylist(), eris_ifu_get_bandString(), eris_ifu_get_lampString(), and TRY.
Referenced by eris_ifu_dist_wave(), and eris_ifu_wave_get_calImg().
| cpl_error_code eris_ifu_wave_smooth_coeffs | ( | int | sIdx, |
| int | start, | ||
| int | end, | ||
| int | fitDegree, | ||
| cpl_polynomial * | allFits[ERIS_IFU_DETECTOR_SIZE_Y], | ||
| cpl_table * | columnCoeffSmoothedTable, | ||
| cpl_table * | smoothingCoeffTable | ||
| ) |
Smooth polynomial coefficients across detector columns.
Smooths wavelength polynomial coefficients spatially across columns within a slitlet to reduce noise and improve wavelength solution stability. For each polynomial coefficient:
This spatial smoothing assumes wavelength solutions vary slowly across neighboring columns, which is generally valid for well-aligned spectrographs.
| sIdx | Slitlet index |
| start | First column in slitlet |
| end | Last column in slitlet |
| fitDegree | Degree of wavelength polynomial (per column) |
| allFits | Array of polynomial fits (modified in place) |
| columnCoeffSmoothedTable | Output: smoothed polynomial coefficients |
| smoothingCoeffTable | Output: smoothing polynomial coefficients |
Definition at line 1455 of file eris_ifu_wavecal_static.c.
References CATCH, eris_ifu_1d_polynomial_fit(), eris_ifu_free_polynomial(), eris_ifu_wave_fill_coeff_table(), and TRY.
Referenced by eris_ifu_fit_all_lines().