Spectral Class Estimator Formula

Understand the math behind the spectral class estimator. Each variable explained with a worked example.

Formulas Used

Spectral Class Code

class_number = (temperature > 30000) * 7 + (temperature > 10000) * (temperature <= 30000) * 6 + (temperature > 7500) * (temperature <= 10000) * 5 + (temperature > 6000) * (temperature <= 7500) * 4 + (temperature > 5200) * (temperature <= 6000) * 3 + (temperature > 3700) * (temperature <= 5200) * 2 + (temperature <= 3700) * 1

Peak Wavelength

peak_nm = 2.8978e6 / temperature

Variables

VariableDescriptionDefault
temperatureEffective Temperature(K)5778

How It Works

Spectral Classification (OBAFGKM)

Stars are classified by surface temperature into spectral types:

ClassTemperature RangeColour O> 30 000 KBlue B10 000 - 30 000 KBlue-white A7 500 - 10 000 KWhite F6 000 - 7 500 KYellow-white G5 200 - 6 000 KYellow K3 700 - 5 200 KOrange M< 3 700 KRed

The output code: 7=O, 6=B, 5=A, 4=F, 3=G, 2=K, 1=M.

Worked Example

The Sun at 5778 K.

temperature = 5778
  1. 015778 K falls between 5200 and 6000 K.
  2. 02Spectral class: G (code 3)
  3. 03Peak wavelength: 2897800 / 5778 = 501.5 nm (green)
  4. 04The Sun is a G2V star.

Frequently Asked Questions

What does OBAFGKM stand for?

The mnemonic "Oh Be A Fine Guy/Girl, Kiss Me" helps remember the order from hottest to coolest.

What are the subclasses (0-9)?

Each letter class is divided into 10 subclasses (0 = hotter, 9 = cooler). The Sun is G2, meaning near the hot end of the G class.

What about L, T, and Y classes?

These extend the sequence below M for brown dwarfs: L (1300-2000 K), T (500-1300 K), Y (< 500 K).

Ready to run the numbers?

Open Spectral Class Estimator