Astronomical temperatures are usually estimated from spectroscopic measurements.
The spectroscope was invented in 1859 by two German scientists, Robert Wilhelm Bunsen of Bunsen burner fame and Gustav Robert Kirchoff.
It was first used to analyze the elements in a substance heated to incandescence, each element gave off characteristic wavelengths of visible light.
Bunsen used the device to identify two new elements, cesium and rubidium.
It was later discovered that the presence of certain elements in distant heavenly bodies, and their corresponding temperatures, could be analyzed by the same color yardstick, and by spectral lines, the patterns created by the emission and absorption spectra of the elements in stars and other heavenly bodies.
Over the years, scientists refined their classification of stars.
One early scheme was alphabetical, based on the strength of hydrogen absorption lines in the stellar spectrum, with the classification running from A to P.
A later rearrangement was designed to correspond to a sequence of decreasing surface temperatures, most stars could be divided into seven spectral types.
It dropped some letters, and this famous sequence could be remembered by the initials for the words “Oh Se A Fine Girl, Kiss Me.” It runs from the hottest blue O stars to the coolest red M stars.
Astronomers now take the entire electromagnetic spectrum into account, not just visible light.
In general, cool objects give off radiation of long wavelengths while hotter objects give off short wavelengths.
Infrared telescopes sent into space far beyond the obscuring atmosphere of the earth measure the short wavelengths below those of gamma ray telescopes are trained on longer and longer wavelengths and hotter and hotter astronomical objects and events.