---
title: Stellar Spectra and Spectral Classification
draft: false
module: Observational Foundations
moduleNumber: 2
lessonNumber: 2
order: 202
summary: >
  A stellar spectrum is a continuum crossed by absorption lines whose strengths
  are set by the temperature of the atmosphere. The Boltzmann factor governs how
  atoms populate excited states, and the Saha equation governs how they ionize;
  their product explains why each line, such as the hydrogen Balmer series, peaks
  in strength at a characteristic temperature. This behavior orders stars into
  the OBAFGKM sequence, and the luminosity classes of the MK system add a second
  dimension for surface gravity.
topics: [Observational Foundations]
sources:
  - book: Carroll & Ostlie
    ref: "Ch. 5 — The Interaction of Light and Matter; §5.1 Spectral Lines, §5.3 The Bohr Model; Ch. 8 — Classification of Stellar Spectra; §8.1 The Formation of Spectral Lines"
  - book: Maoz
    ref: "Ch. 2 — Basic Physics of Stars; Ch. 3 — Stellar Physics"
---

Broadband colors place a star roughly on a temperature scale, but the spectrum
itself — the flux resolved wavelength by wavelength — carries far more. It divides
into a smooth continuum and a forest of narrow absorption lines, and the pattern of
those lines classifies the star. The classification turns out to be a temperature
sequence, and the reason lies in two statistical relations: the Boltzmann factor,
which sets how atoms distribute over excited states, and the Saha equation, which
sets how they distribute over ionization stages. Together they explain why a given
line strengthens, peaks, and fades as temperature rises, and why the historical
letter classes reorder into O B A F G K M.

## Kirchhoff's laws and the origin of lines

Three empirical rules, Kirchhoff's laws, describe when a spectrum shows a continuum,
bright lines, or dark lines:

- **Continuous spectrum**: a hot, dense body (a solid, liquid, or optically thick
  gas) emits a continuum that approaches the blackbody form.
- **Emission-line spectrum**: a hot, diffuse gas emits bright lines at wavelengths
  set by its atomic transitions.
- **Absorption-line spectrum**: a continuous source seen through a cooler diffuse
  gas shows dark lines at those same wavelengths.

A star produces an absorption spectrum because the deep, dense layers radiate a
near-continuum, and the cooler, more transparent gas above removes photons at its
line wavelengths along the line of sight. The lines are dark relative to the
continuum, not truly black; the physics of exactly how deep a line goes belongs to
[radiative
transfer](/astrophysics-cosmology/radiation-and-matter/radiative-transfer-and-the-transfer-equation).
Here the question is which lines appear and how strong they are.[^co-kirch]

$$
% caption: A hot dense source gives a continuum; a diffuse gas emits bright lines;
% the same gas in front of the continuum removes photons and prints dark lines.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% continuous band
\draw[black] (0,3.2) rectangle (3.0,3.9);
\node[black!70, anchor=south] at (1.5,3.95) {continuous};
% emission band: dark bar with a few bright lines
\draw[black] (0,1.7) rectangle (3.0,2.4);
\foreach \x in {0.7,1.4,2.2}
  \draw[very thick] (\x,1.7) -- (\x,2.4);
\node[black!70, anchor=south] at (1.5,2.45) {emission lines};
% absorption band: light bar with a few dark lines
\draw[black] (0,0.2) rectangle (3.0,0.9);
\foreach \x in {0.7,1.4,2.2}
  \draw[black!70, very thick] (\x,0.2) -- (\x,0.9);
\node[black!70, anchor=south] at (1.5,0.95) {absorption lines};
% geometry sketch on the right
\fill[black] (6.0,3.0) circle (7pt);
\node[black!70, anchor=south] at (6.0,3.35) {hot dense};
\draw[black] (7.4,2.4) rectangle (8.2,3.6);
\node[black, anchor=north, align=center] at (7.8,2.35) {cool\\gas};
\node[black!70, anchor=west] at (8.4,3.3) {observer sees dark lines};
\draw[->, black] (6.35,3.0) -- (10.0,3.0);
\node[black!70, anchor=west] at (8.4,2.5) {to the side: bright lines};
\draw[->, black] (7.8,2.4) -- (9.0,1.7);
\end{tikzpicture}
$$

## The Boltzmann factor: populating excited states

An atom absorbs a line photon only from the lower level of the corresponding
transition. The strength of an absorption line therefore depends on how many atoms
sit in that lower level, which is a question of statistical mechanics. In thermal
equilibrium at temperature $T$, the ratio of the number of atoms in state $b$
(energy $E_b$) to the number in state $a$ (energy $E_a$) is the **Boltzmann
factor**, weighted by the statistical degeneracies $g_a$ and $g_b$ of the levels:

$$
\frac{N_b}{N_a} = \frac{g_b}{g_a}\, e^{-(E_b - E_a)/k_B T},
$$

where $k_B = 1.381 \times 10^{-23}\ \text{J}\,\text{K}^{-1}$ is the Boltzmann
constant. The degeneracy of hydrogen level $n$ is $g_n = 2n^2$. As $T$ rises, the
exponential climbs toward unity and higher levels fill; at low $T$ nearly all atoms
sit in the ground state.

For hydrogen the Balmer absorption lines (the visible series H$\alpha$, H$\beta$,
and beyond) arise from the first excited state, $n = 2$, at
$E_2 - E_1 = 10.2\ \text{eV}$ above the ground state. The fraction of neutral
hydrogen in $n = 2$ relative to $n = 1$ is

$$
\frac{N_2}{N_1} = \frac{2(2)^2}{2(1)^2}\, e^{-10.2\ \text{eV}/k_B T}
               = 4\, e^{-10.2\ \text{eV}/k_B T}.
$$

At the solar temperature, $k_B T \approx 0.5\ \text{eV}$, the exponent is about
$-20$ and only one hydrogen atom in $10^{8}$ sits in $n = 2$. The Balmer lines are
weak in the Sun not because hydrogen is scarce but because almost none of it is in
the level that produces them. Raising the temperature pushes more atoms into
$n = 2$ and strengthens the lines — but only up to a point, because a second
process removes neutral hydrogen entirely.[^co-boltz]

## The Saha equation: ionization balance

At high enough temperature, collisions and radiation strip the electron off the
atom, and an ionized hydrogen atom has no bound levels to absorb Balmer photons. The
balance between an ion in stage $i$ and the next stage $i+1$ (with a free electron
released) is governed by the **Saha equation**. For the ratio of number densities,

$$
\frac{N_{i+1}}{N_i} = \frac{2 Z_{i+1}}{n_e Z_i}
  \left( \frac{2\pi m_e k_B T}{h^2} \right)^{3/2}
  e^{-\chi_i / k_B T},
$$

where $\chi_i$ is the ionization energy from stage $i$, $n_e$ is the free-electron
number density, $Z_i$ and $Z_{i+1}$ are the **partition functions** of the two
stages, $m_e$ is the electron mass, and $h$ is Planck's constant. The factor of 2
counts the two spin states of the freed electron. The partition function is the
degeneracy-weighted Boltzmann sum over all bound levels of a stage,

$$
Z = \sum_j g_j\, e^{-(E_j - E_1)/k_B T},
$$

and reduces to the ground-state degeneracy when only the lowest level is populated.

Two features of the Saha equation matter for line strengths. First, the exponential
$e^{-\chi/k_B T}$ makes ionization rise steeply once $k_B T$ approaches the
ionization energy $\chi$ (13.6 eV for hydrogen). Second, the $1/n_e$ prefactor means
ionization also depends on density: a diffuse atmosphere, with few electrons to
recombine with, is more ionized at fixed temperature than a dense one. This density
sensitivity is the physical basis of the luminosity classes introduced below, since
a giant's extended atmosphere has a far lower gas pressure than a dwarf's.[^co-saha]

## The Balmer maximum: Boltzmann times Saha

The strength of the hydrogen Balmer lines is proportional to the number of neutral
hydrogen atoms in the $n = 2$ level. That number is the product of two competing
fractions: the fraction of hydrogen that is still neutral (from Saha) and the
fraction of that neutral hydrogen sitting in $n = 2$ (from Boltzmann). Write the
neutral fraction as $N_{\text{I}}/N_{\text{total}}$ and combine:

$$
\frac{N_2}{N_{\text{total}}}
  = \frac{N_2}{N_{\text{I}}} \cdot \frac{N_{\text{I}}}{N_{\text{total}}}
  = \underbrace{\frac{N_2}{N_1 + N_2}}_{\text{Boltzmann, rises with } T}
    \cdot
    \underbrace{\frac{1}{1 + N_{\text{II}}/N_{\text{I}}}}_{\text{Saha, falls with } T}.
$$

At low temperature the Boltzmann factor is tiny — almost no atoms are excited to
$n = 2$ — so the lines are weak. At high temperature the Saha factor is tiny —
almost all hydrogen is ionized — so the lines are again weak. The product peaks at
an intermediate temperature near $T \approx 9500\ \text{K}$, where enough hydrogen
is both neutral and excited. That temperature marks an A0 star, which is
why the Balmer lines reach their maximum strength in A stars and weaken toward both
hotter B/O stars and cooler F/G/K stars.

$$
% caption: The Boltzmann factor rises and the Saha neutral fraction falls with
% temperature; their product peaks near 9500 K, giving the Balmer strength maximum.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (0,0) -- (9.4,0) node[right, black!70] {temperature};
\draw[->, black] (0,0) -- (0,4.2) node[above, black!70] {fraction};
% Boltzmann excitation fraction: rises left to right
\draw[black, thick, dashed] (0.3,0.15) .. controls (3.0,0.3) and (5.0,2.6) .. (9.0,3.8);
\node[black, anchor=south] at (7.7,3.4) {excited (Boltzmann)};
% Saha neutral fraction: falls left to right
\draw[black, thick, densely dotted] (0.3,3.9) .. controls (4.0,3.6) and (5.5,0.8) .. (9.0,0.15);
\node[black, anchor=north] at (7.6,0.7) {neutral (Saha)};
% product: peaked curve
\draw[acc, very thick] (0.3,0.1) .. controls (2.6,0.3) and (3.6,3.5) .. (4.5,3.5)
  .. controls (5.5,3.5) and (6.6,0.4) .. (9.0,0.1);
\fill[acc] (4.5,3.5) circle (2.2pt);
\node[acc, anchor=south] at (4.5,3.55) {Balmer strength};
\draw[black, dashed] (4.5,0) -- (4.5,3.5);
\node[black, anchor=north] at (4.5,-0.05) {near 9500 K};
\end{tikzpicture}
$$

The same reasoning, applied to other atoms and ions, explains the whole
classification. Each species has its own ionization and excitation energies, so
each line peaks at its own temperature. The lines present in a spectrum therefore
act as a thermometer far more precise than a broadband color.

## The OBAFGKM sequence

The letters of the classical Harvard classification were originally assigned by
Balmer-line strength alone, in alphabetical order A, B, C, and so on. Once the
Boltzmann-Saha analysis showed the true ordering variable was temperature, the
classes were reordered and pruned into the temperature sequence

$$
\text{O} \to \text{B} \to \text{A} \to \text{F} \to \text{G} \to \text{K} \to \text{M},
$$

from hottest (O, above $30{,}000\ \text{K}$) to coolest (M, below $3900\ \text{K}$).
Each class is subdivided by a digit 0-9, so the Sun is a G2 star. The diagnostic
lines shift systematically along the sequence:

- **O**: ionized helium (He II) lines, only excitable above $\sim 25{,}000\ \text{K}$;
  hydrogen weak because it is largely ionized.
- **B**: neutral helium (He I) at maximum; hydrogen strengthening.
- **A**: hydrogen Balmer lines at maximum near $9500\ \text{K}$; He I gone.
- **F, G**: Balmer weakening; ionized metals (Ca II H and K) strengthening.
- **K**: neutral metals dominant; Ca II very strong; molecular bands appearing.
- **M**: molecular bands (titanium oxide, TiO) dominate; too cool for most atomic
  lines.

$$
% caption: Along the OBAFGKM sequence each line peaks at its own temperature:
% helium in hot stars, hydrogen near A, metals and molecules in cool stars.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (0,0) -- (9.6,0) node[right, black!70] {O hot to M cool};
\draw[->, black] (0,0) -- (0,3.9) node[above, black!70] {line strength};
\foreach \x/\lab in {0.8/O,2.1/B,3.4/A,4.7/F,6.0/G,7.3/K,8.6/M}
  \node[black, anchor=north] at (\x,-0.05) {\lab};
% He II peaked at hot end
\draw[black, densely dotted, thick] (0.4,3.2) .. controls (1.4,1.2) and (2.0,0.2) .. (3.0,0.1);
\node[black, anchor=west] at (0.5,3.35) {He II};
% hydrogen peaked near A
\draw[acc, very thick] (1.0,0.2) .. controls (2.6,0.4) and (3.0,3.4) .. (3.6,3.4)
  .. controls (4.4,3.4) and (5.0,0.5) .. (7.0,0.15);
\node[acc, anchor=south] at (3.6,3.45) {hydrogen};
% ionized metals (Ca II) peaked near G-K
\draw[black, dashed, thick] (3.4,0.15) .. controls (5.0,0.6) and (5.8,2.9) .. (6.6,2.9)
  .. controls (7.2,2.9) and (8.0,1.4) .. (9.2,1.0);
\node[black, anchor=south] at (6.6,2.95) {metals};
% molecular bands rising toward M
\draw[black, thick] (6.4,0.15) .. controls (7.6,0.4) and (8.2,1.8) .. (9.2,2.8);
\node[black, anchor=east] at (9.2,2.9) {molecules};
\end{tikzpicture}
$$

The temperature calibration of the sequence is the relation later lessons invoke:
a spectral type maps onto an effective temperature to within a few percent, and the
digit subdivides that mapping. Because the lines respond to
temperature and not to composition (to first order, all stars are mostly hydrogen
and helium), two stars of very different metal content but the same temperature look
nearly alike in the sequence.

## Luminosity classes and the MK system

Temperature alone does not fix a star's spectrum. Two stars at the same temperature
but different sizes — a main-sequence dwarf and a bloated giant — have very
different atmospheric densities, hence different electron pressures, and the Saha
$1/n_e$ term makes them differ in ionization. A giant's low-density atmosphere is
more ionized, and its lines are narrower because collisional (pressure) broadening
is weaker. The **MK (Morgan-Keenan) system** adds a Roman-numeral **luminosity
class** encoding this second dimension:

- **I** — supergiants (subdivided Ia, Ib)
- **II** — bright giants
- **III** — giants
- **IV** — subgiants
- **V** — main-sequence dwarfs (the Sun is G2V)
- **VI / sd** — subdwarfs
- **wd / D** — white dwarfs

A full MK type combines the two axes: a temperature letter with digit and a
luminosity class, such as G2V for the Sun, M2Ia for a red supergiant like
Betelgeuse, or B0V for a hot main-sequence star. The two-dimensional grid separates
the giant branch from the main sequence on a spectrum alone, without needing a
distance — which is what makes **spectroscopic parallax** possible: read the
luminosity class to get the absolute magnitude, compare to the apparent magnitude,
and solve the distance modulus for distance.

$$
% caption: The MK grid: spectral type sets temperature along one axis, luminosity
% class sets surface gravity along the other, separating dwarfs from giants.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% axes
\draw[->, black] (0,0) -- (8.6,0) node[right, black!70] {O to M};
\draw[->, black] (0,0) -- (0,4.6) node[above, black!70] {luminosity};
\foreach \x/\lab in {1.0/O,2.2/B,3.4/A,4.6/F,5.8/G,7.0/K,8.0/M}
  \node[black, anchor=north] at (\x,-0.05) {\lab};
% class labels along vertical
\foreach \y/\lab in {4.1/I,3.3/II,2.5/III,1.7/IV,0.9/V}
  \node[black, anchor=east] at (-0.1,\y) {\lab};
% main sequence (class V) diagonal
\draw[very thick] (1.2,3.9) -- (8.0,0.6);
\node[rotate=-24, anchor=south] at (4.4,2.4) {main sequence V};
% giant branch (class III) horizontal upper
\draw[thick, dashed] (4.6,2.4) .. controls (6.0,2.6) and (7.2,2.9) .. (8.1,3.0);
\node[anchor=south] at (6.6,2.85) {giants III};
% supergiants (class I) top
\draw[thick, densely dotted] (1.4,4.1) -- (8.1,4.0);
\node[anchor=south] at (4.6,4.05) {supergiants I};
\end{tikzpicture}
$$

The classification of this lesson is the bridge from raw spectra to physical
parameters: temperature from the spectral type, surface gravity (and thus
luminosity) from the class. Those parameters feed the interior physics of later
modules and, through spectroscopic parallax and main-sequence fitting, supply
distances for [the cosmic distance
ladder](/astrophysics-cosmology/observational-foundations/the-cosmic-distance-ladder).
Reading the spectrum in detail, rather than counting broadband colors, requires
collecting the light in the first place, which is the subject of the next lesson on
[telescopes and
detectors](/astrophysics-cosmology/observational-foundations/telescopes-and-detectors-across-the-spectrum).

[^co-kirch]: Carroll & Ostlie, §5.1 — Spectral Lines: Kirchhoff's laws and the formation of continuous, emission, and absorption spectra.
[^co-boltz]: Carroll & Ostlie, §8.1 — The Formation of Spectral Lines: the Boltzmann equation for level populations and its application to the hydrogen Balmer lines.
[^co-saha]: Carroll & Ostlie, §8.1 — The Formation of Spectral Lines: the Saha equation, partition functions, the combined Boltzmann-Saha Balmer maximum, and the OBAFGKM temperature sequence.
