In the previous post, we discussed how a dispersive spectrometer encodes wavelength as position on a detector array. The raw data from a spectrometer is a list of pixel index with associated intensity. The process of wavelength calibration is to map pixel index to wavelength to yield a wavelength-calibrated spectrum.
The wavelength solution for a given instrument is not static in time. Environmental changes in temperature or humidity, mechanical changes such as shock or vibration, and optical configuration changes such as slit replacement or fiber illumination all impact the wavelength scale. Depending on the precision and accuracy required for a specific application, wavelength calibration may be needed at a minimum for each new set-up or, for critical applications, for each new measurement.
If we observe a source of atomic emission lines of known wavelength from a Hg/Ar or Ne lamp, we can identify the pattern of lines and associate each line with its measured pixel position. The mapping between line wavelength and pixel position depends on the grating geometry, groove density, camera focal length, and pixel size. However, rather than fitting a physical model, it is convenient and conventional to capture this relationship empirically as a polynomial.
The code below provides an example of how to perform your own wavelength calibration, avoiding the costly and time-consuming process of returning your spectrometer to the manufacturer for calibration.
Code Description
The below code is an embedded trinket written in Python, which can be run in your browser without downloading data or software. You can customize the code for your own specific application or change it to explore how it works. The four included files are the code itself (main.py), the calibration Hg/Ar spectrum used for establishing the relationship between pixel position and wavelength (hgar.csv), a dark spectrum taken immediately following the Hg/Ar spectrum and with the same exposure time (dark.csv), and a line list for Hg I and Ar I developed for this particular spectrum that associates observed line positions with known NIST wavelengths (atlas.csv).
If you have not used trinket before, to run the code, choose the "play" button. To edit the code, select the appropriate file tab and click in the window. You can toggle to full-screen mode from the hamburger menu in the upper left. You can download the code from this menu as well.
Exploring the Code
To see the uncalibrated spectrum and a list of algorithmically-identified peak positions, set identify_peaks on line 32 to True. This first figure marks each prospective line with a red tick. Type "c" in the results frame continue. These line positions are used with the NIST atomic lines database to construct a spectral atlas (atlas.csv) for wavelength calibration of the spectrum. On line 81, setting determine_poly_degree = True allows testing the results of different polynomial orders for the wavelength solution. With good centroid measurements and the appropriate polynomial, the rms for the wavelength solution is 0.28 pix or 0.07 nm. Again type "c" in the results frame to continue. The final figure applies the polynomial wavelength solution to the reference spectrum, with "Calibrated wavelength" shown on the x-axis.
Wavelength Calibrating your Spectrometer
Here is a textual summary of the procedure to collect and analyze the measurements you need to update your spectrometer wavelength calibration.
- Illuminate your spectrometer with a spectrometer calibration lamp.
- Collect a spectrum with high signal-to-noise and high dynamic range. If bright lines are saturating, use a shorter exposure time and average an ensemble of frames.
- Collect a dark spectrum, if necessary.
- Export your data to CSV and dark subtract.
- Identify pixel positions for peaks manually or algorithmically.
- Compare your spectrum with the NIST database for the atomic species appropriate for your lamp (e.g, Hg I, Ne I, Ar I). Discard closely-spaced, blended lines.
- Construct a list mapping peak pixel positions to NIST wavelengths (atlas.csv in this example).
- Use this list to calculate the line centroids (line 64 in the above code).
- Determine the appropriate order of polynomial for the wavelength solution and confirm the residuals are satisfactory.
- Print the coefficients for the polynomial that returns wavelength for a given pixel position. Inspect the current coefficients uploaded in your spectrometer's control software. Before modifying the coefficients in your firmware, check your newly derived coefficients for large departures from the default. Optionally, upload the new coefficients to your spectrometer.
© Eikonal Optics