Skip to main content
Sandbox Physics
Stellar spectra from dark lines to abundance models

AC03 · Tutorial

Fit a frozen calibrated stellar spectrum

Keep two records side by side: a synthetic spectrum with a known answer and an observed HST/STIS spectrum of Vega. Learn the fit on the controlled record, then watch a real hydrogen line expose an inadequate profile. The download linked below contains all inputs and scripts; rerunning the extracted exercise needs no network.

Pin the file and identify which part was observed

The observed input is CALSPEC alpha_lyr_stis_011.fits, version eleven. The complete file combines observations and model spectra. This exercise selects only its header-identified STIS optical portion: eighty-two good-quality rows between 4750 and 4975 vacuum angstroms, without resampling. The original FITS remains beside the extracted CSV so the header can be checked.

Its columns contain wavelength, absolute flux, statistical error, systematic error, spectral-resolution width, quality and exposure time. The header names G430L observations o8i105060, o8i106010 and o8i106040 and records the 2022 charge-transfer-efficiency update. Both original and excerpt have SHA-256 checksums.

The script verifies the original checksum before decoding the frozen table layout. It writes the excerpt with original row numbers. This deliberately limited decoder reads one known file; a different release needs a fresh header and schema check. Run both commands from the unzipped exercise folder.

python3 calspec-tutorial.py
python3 spectrum-tutorial.py

Reading: STScI CALSPEC, alpha_lyr_stis_011.fits (25 October 2022) · MAST reference atlases and CALSPEC releases

Recover a known motion first

The controlled record has 721 wavelength-calibrated samples and random seed 2026102820261028. It contains the artificial two-line slab, a sloping continuum and a known Gaussian instrument response. The injected velocity is 18 km s−118\,\mathrm{km\,s^{-1}} and the per-sample random standard deviation is 0.0040.004. It is a separate synthetic record, not Vega data.

For trial velocity, Doppler width and central optical depth, compute the normalized profile. Solve the two linear continuum coefficients, then evaluate the standardized residual sum. A coordinate search progressively reduces its step sizes. The saved result recovers approximately 18.0 km s−118.0\,\mathrm{km\,s^{-1}}, Doppler parameter 2.38 km s−12.38\,\mathrm{km\,s^{-1}} and reference optical depth 2.862.86.

Noise and parameter correlations prevent exact recovery of every injected number. Reduced chi-square is about 1.041.04, consistent with this particular generated record. The output preserves sample count, degrees of freedom, continuum coefficients and residual scale so the comparison can be checked.

Mi=(a+bxi)qi(vr,bD,τ0),χ2=∑i(yi−Mi)2σi2M_i=(a+b x_i)q_i(v_r,b_D,\tau_0),\qquad \chi^2=\sum_i\frac{(y_i-M_i)^2}{\sigma_i^2}
a and b describe the continuum at a fixed dimensionless wavelength coordinate x. b_D is the distinct Doppler parameter. At fixed nonlinear line parameters, the continuum least-squares problem is linear.

Make two deliberate mistakes

First add 0.002 nm0.002\,\mathrm{nm} to every synthetic wavelength. The fitted velocity becomes about 19.2 km s−119.2\,\mathrm{km\,s^{-1}} with almost unchanged goodness of fit. The velocity absorbs a common wavelength error. The prescribed zero-point uncertainty of 0.0002 nm0.0002\,\mathrm{nm} corresponds to about 0.120 km s−10.120\,\mathrm{km\,s^{-1}} at this wavelength.

Next omit instrumental spreading. The fitted Doppler parameter increases to about 3.55 km s−13.55\,\mathrm{km\,s^{-1}}, optical depth falls to about 1.401.40 and reduced chi-square rises to about 3.673.67. The gas model broadens and shallows to compensate for the missing instrument. Compare these failures: one retains an attractive residual, the other produces visible model mismatch.

Measure the observed hydrogen feature

The observed script uses a chosen approximate vacuum reference 4862.683 A˚4862.683\,\mathrm{\mathring A} near hydrogen Balmer-beta. It first fits a linear continuum plus a Gaussian absorption notch within 22 A˚22\,\mathrm{\mathring A} on either side. This defines an apparent displacement; it does not resolve hydrogen fine structure, pressure shifts or the velocity reference frame.

The frozen fit gives an apparent center near 4862.20 A˚4862.20\,\mathrm{\mathring A}, an apparent Doppler value near −29.6 km s−1-29.6\,\mathrm{km\,s^{-1}} and Gaussian full width near 18.5 A˚18.5\,\mathrm{\mathring A}. A wider fit window changes the Gaussian width to about 25.1 A˚25.1\,\mathrm{\mathring A}. The profile measurement depends on which part of the real wings the model attempts to explain.

Force the broad-window continuum flat and the apparent velocity becomes about −7.4 km s−1-7.4\,\mathrm{km\,s^{-1}}. A winged Lorentz profile improves the residual but still leaves structure much larger than the statistical errors. Its enormous weighted sum is useful evidence that this empirical line shape is inadequate.

Reading: STScI CALSPEC, alpha_lyr_stis_011.fits (25 October 2022)

Write the uncertainty that the data actually support

The observed fit uses STATERROR for weights and retains SYSERROR separately. A calibration systematic can correlate wavelengths. Treating it as an independent Gaussian draw at every pixel would invent an error model absent from the file. Neither error column removes continuum or profile ambiguity.

Report the apparent center, empirical width and sensitivity to window, continuum and profile. These exercise values are not a precision systemic velocity of Vega. They do not infer temperature or elemental abundance. The STIS handbook ties wavelength accuracy to the dispersion solution, zero point and centering in the slit; a precision analysis must use the appropriate calibration for its mode and exposures.

For another star, record the release, observational provenance, wavelength medium and reference frame, selected rows, continuum, response and residual structure before interpreting physical parameters. Keep the failed fits with the successful one. A future fit with a convincing residual and wrong motion then has a concrete comparison.

Reading: STIS Data Handbook, section 4.3, Factors Limiting Flux and Wavelength Accuracy · MAST reference atlases and CALSPEC releases

Put the instrument back into the model

  1. Export high- and low-resolution spectra with the same cool layer.
  2. Compare line depth and equivalent width. Predict the consequence of omitting the response in a fit.
  3. Read the ignored-response synthetic result and explain why velocity and width do not acquire the same bias.

Exercises with explanations

  1. Why not add SYSERROR and STATERROR in quadrature per pixel and declare the observed fit adequate?

    Read the explanation

    Calibration errors can correlate across wavelengths, and no covariance has been supplied for that step. Large structured residuals also call for a better continuum or physical profile.

  2. What happens to the calibration-induced velocity bias if the synthetic random noise is halved?

    Read the explanation

    It remains almost unchanged because every wavelength still shifts together. Smaller random errors make the common bias relatively more important.

Sources and calculation scope

  1. STIS Data Handbook, section 4.3, Factors Limiting Flux and Wavelength Accuracy

    Wavelength zero point, dispersion and slit centering; used to distinguish an apparent profile displacement from a precision radial velocity.

  2. STScI CALSPEC, alpha_lyr_stis_011.fits (25 October 2022)

    Pinned FITS header and all 82 selected observed STIS rows from 4750 to 4975 vacuum angstroms. File checksum and exact source rows accompany the tutorial.

  3. MAST reference atlases and CALSPEC releases

    Data provenance and release context. The exercise deliberately pins version eleven rather than the changing current directory.

FeedbackSomething broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy