Wavelength Fitting Algorithm
Overview
Wavelength calibration establishes the mapping between CCD pixel positions and wavelengths using arc lamp emission lines. pyKOSMOS++ uses Chebyshev polynomial fitting with Bayesian Information Criterion (BIC) order selection.
Method
Detect arc lines in 1D collapsed arc spectrum
Match to catalog wavelengths (He-Ne-Ar, Ar, Kr, Ne)
Fit Chebyshev polynomial with iterative sigma-clipping
Select optimal order using BIC to balance fit quality vs overfitting
Validate RMS residual < threshold (default 0.1Å)
Chebyshev Polynomials
Chebyshev polynomials are preferred over standard polynomials for numerical stability:
where \(T_i\) are Chebyshev polynomials and \(x_{norm}\) is pixel position normalized to [-1, 1].
Advantages:
Numerically stable for high orders (up to n=10)
Orthogonal basis reduces coefficient correlations
Better conditioned than power series
BIC Order Selection
Bayesian Information Criterion balances fit quality with model complexity:
where:
n = number of arc lines
σ² = variance of residuals
k = number of parameters (polynomial order + 1)
Algorithm:
Fit polynomials for orders 3-7 (configurable)
Compute BIC for each order
Select order with minimum BIC
Validate RMS < 0.1Å threshold
Iterative Sigma-Clipping
Removes outlier lines from fit:
Fit polynomial to all matched lines
Compute residuals: \(r_i = \\lambda_i - f(x_i)\)
Calculate RMS: \(\\sigma = \\sqrt{\\sum r_i^2 / n}\)
Reject lines with \(|r_i| > 3\\sigma\)
Repeat until convergence or max iterations (default 5)
Typical results:
80-95% of lines retained
RMS improves by 20-40% after clipping
Parameters
- order_range: (3, 7)
Range of polynomial orders to test
- sigma_clip: 3.0
Threshold for outlier rejection (sigma)
- max_iterations: 5
Maximum sigma-clipping iterations
- rms_threshold: 0.1
Maximum acceptable RMS in Angstroms
Performance
Typical Metrics:
Lines detected: 40-60 for He-Ne-Ar
Lines used in fit: 35-55 (after clipping)
RMS residual: 0.05-0.15Å
Optimal order: 5-7 for KOSMOS
References
Chebyshev polynomials: Press et al. “Numerical Recipes” Ch. 5
BIC: Schwarz, G. 1978, Annals of Statistics, 6, 461
pyKOSMOS: Davenport et al. 2023, DOI:10.5281/zenodo.10152905
See Also
Wavelength Module - API reference
Configuration Reference - Wavelength parameters
Troubleshooting - Wavelength calibration issues