Write the instrument response before the fit
Let denote the normalized slab intensity. An ideal instrument would record it directly. A real response spreads each input across nearby wavelengths; adding those contributions defines a convolution.
The response must integrate to one. A constant continuum then remains constant, and a complete line retains its integrated missing area. The implementation convolves and extends that deficit by zero outside the domain. This supplies a unit continuum beyond the edges instead of creating artificial dark edge pixels.
Reading: Condon & Ransom, Essential Radio Astronomy, Appendix E · Krumholz, ASTR 4003/8003 (2019), Class 1, Radiative transfer I
Estimate the continuum with the line
A calibrated spectrum can retain a local slope. Forcing that continuum flat can make a fit move the line or change its depth to compensate. Use locally, where is a dimensionless wavelength coordinate relative to a fixed origin.
The prediction is . At fixed line velocity, width and optical depth, the continuum coefficients remain linear. Solve their two normal equations directly and search only over the nonlinear line parameters.
Set and , with and weights . The prediction becomes . Differentiate the weighted residual sum with respect to each continuum coefficient. Both derivatives vanish at the minimum, giving the two equations below.
The matrix simply groups two simultaneous equations. Compute the five weighted sums and solve for intercept and slope. Its determinant is nonzero only when the two basis columns provide distinct information: a single wavelength cannot determine both continuum height and slope.
A good residual can hide a wrong velocity
The controlled tutorial injects into a saved synthetic record at resolving power . Fitting continuum, velocity, Doppler parameter and reference optical depth recovers about with reduced chi-square near . This checks recovery from those particular saved samples.
Now add to every wavelength without changing intensity or noise. The fitted velocity becomes about with almost the same residual. A shared wavelength zero-point error closely imitates common gas motion.
A specified zero-point uncertainty of corresponds to at five hundred nanometres. More pixels under the same calibration do not average away that common shift.
Let a real spectrum expose model shortcomings
The observed tutorial pins a CALSPEC Vega spectrum and selects only the optical region identified in its header as STIS observations. Its broad hydrogen line has wings. A simple Gaussian leaves a huge weighted residual when compared with the small statistical errors. Changing the window, continuum or profile changes its apparent center and width.
That is a useful transition from a teaching spectrum to astronomical data. A numerical optimizer needs a physical description that survives residual checks before it can yield reliable stellar parameters. First report line-measurement sensitivity. Interpreting abundance then requires a fuller atmospheric calculation.
Reading: STScI CALSPEC, alpha_lyr_stis_011.fits (25 October 2022) · MAST reference atlases and CALSPEC releases · Amarsi, Liljegren & Nissen (2022), 3D non-LTE iron abundances in FG-type dwarfs, arXiv:2209.13449v3