Observatory · the spectroscope
Redshift
Almost everything we know about the universe beyond the solar system comes from reading dark lines in light. A star's atmosphere absorbs exact colours, so its spectrum carries a barcode; if the barcode arrives shifted, something happened to the light on the way. Three different things can do it, and telling them apart is the trade.
The spectroscope
Doppler: a source moving away stretches its waves; z = √((1+β)/(1−β)) − 1 with β = v/c. The nearest stars move at tens of km/s, enough to measure; the slider goes to a third of the speed of light, where the relativistic form matters.
Gravitational: 1 + z = 1/√(1 − rs/r). Light from the surface of the Sun is shifted by two millionths; from a neutron star by a fifth; from just above a black hole's horizon by as much as you like. It is the same factor as the clock above, seen in colour.
Cosmological: not the galaxy moving through space but space stretching while the light is on its way, 1 + z = (size of the universe now)/(size then). At z = 1 the universe was half its present size; the record holders sit past z = 13, their visible light stretched into the infrared, which is what the James Webb telescope was built to see.
Telling them apart
Motion shifts every line by the same factor and can go either way; Andromeda is blueshifted, coming at us at about 110 km/s. Within a galaxy, the two sides of a rotating disk are shifted opposite ways, and the width of a line tells you how fast the gas is churning.
Gravity is small for anything that is not compact: two parts in a million from the Sun's surface. Pound and Rebka first measured it on Earth in 1959–60, over a 22-metre tower at Harvard, where it is a few parts in 1015. White dwarfs show it clearly; the star S2, skimming past Sagittarius A* in 2018, showed it from a black hole, as predicted.
Expansion is the one that grows with distance, which is how Hubble found it in 1929 and how we measure the universe's age. It is not a Doppler shift, though at small z it looks like one: nothing is flying through space, space itself has stretched while the light was travelling, and the light stretched with it. The cosmic microwave background is this at z ≈ 1,100: light that left as a glow like a star's surface and arrives as microwaves.
In practice astronomers see all three at once in a single spectrum and separate them by context: the galaxy's distance gives the expansion part, the line width and asymmetry the motion, and anything left over, in a compact object, the gravity.