# Spectrum Detective model

Version: `vacuum-balmer-radial-doppler-1`. The original dependency-free [JavaScript module](spectrum-model.mjs) is the same implementation imported by the website. Code is covered by the repository's MIT license; observed data have separate credit and provenance.

The four hydrogen Balmer reference positions are Hδ 410.289 nm, Hγ 434.168 nm, Hβ 486.268 nm and Hα 656.461 nm, taken from the [SDSS DR4 vacuum spectral-line table](https://www.sdss2.org/dr4/algorithms/linestable.php) by dividing its ångström values by ten. These reference positions are suitable for a beginner pattern comparison, not resolved atomic fine-structure components. The transitions connect principal levels 6, 5, 4 and 3 to level 2; absorption reverses the downward emission transitions. Compare [NIST's hydrogen atomic-data notes](https://physics.nist.gov/PhysRefData/Handbook/Tables/hydrogentable1.htm) on multiplets and fine structure.

Template markers all have the same height and fixed screen stroke width. Those graphical choices encode **position only**, not abundance, intensity, equivalent width, spectral resolution or a physical broadening law. No stellar-atmosphere intensity model is present.

For an inertial source in purely radial motion, with positive velocity v for recession, beta = v/c and c = 299792.458 km/s exactly, the special-relativistic wavelength ratio is sqrt((1+beta)/(1-beta)). Bounds are −3000 to +3000 km/s. The module rejects nonfinite and unsupported inputs. All four lines are multiplied by one ratio; no common additive displacement is applied. Cosmological/gravitational redshift, transverse motion, temperature changes and line-strength inference are outside this model.

At +1500 km/s, the ratio is 1.005016041607202. Hδ shifts by 2.0580266949773165 nm and Hα by 3.292835689505457 nm. The fractional shift is 0.005016041607202, the same for both. Reversing the speed gives the reciprocal ratio; zero velocity gives the original wavelengths.

The selected-line plot uses a fixed window of reference wavelength ±8 nm. Velocity changes never alter those axes. Changing the selected line changes the labeled window explicitly. The maximum permitted shift remains inside the window for every line. Each component instance keeps its own controls and event listeners; it uses no storage or network requests.

The measured Vega data are **separate** and are never passed through this adjustable model. See the [observed-data notes](../data/vega-stis-balmer-README.md). A successful match in this teaching model is not a velocity or abundance measurement of Vega.

From the repository root:

```sh
node scripts/test-universe-spectrum.mjs
python3 scripts/universe/prepare-spectrum-data.py --input scripts/universe/fixtures/alpha_lyr_stis_012.fits --check
```

The model test independently transforms a photon energy with a Lorentz boost, recovers the velocity from the wavelength ratio, checks opposite-speed reciprocity, unit conversion, drawing coordinates, bounded inputs and state independence. It also decodes the original FITS directly in Node and compares all selected samples to CSV/JSON. These checks do not replace rendered layout or interaction testing.
