Electromagnetic radiation follows gravity in its importance in astrophysics. We study stars and galaxies principally through the light they emit. Star and planets cool by emitting light. In large stars, gravity is balanced by the pressure exerted by light; this pressure can drive a wind from such stars.
Light can be thought of as a gas, and like all gases, light obeys the laws of thermodynamics. This means that when light interacts with matter, it tries to come into thermal equilibrium the matter: the light tries to acquire the same temperature as the matter. Light in equilibrium with the surrounding matter has a Planck spectrum—also called a black body spectrum.
Light at the core of a star has a Planck spectrum, but fortunately for astronomers, light almost always deviates from a Planck spectrum at the photosphere of a star or the surface of a planet. A planck spectrum is featureless, and the shape of the spectrum contains only one piece of information—the temperature of the matter that created the light. But when light deviates from thermal equilibrium, it contains additional information, such as the composition and density of the gas creating the light. Usually the deviation appears as sets of lines in the spectrum, appearing either as dips in a black body spectrum or as spikes rising above a black body spectrum. These lines are unique signatures of elements such as hydrogen and helium. Helium, in fact, was discovered through its spectral lines in the Sun's spectrum; this is why the name is derived from helios, the Greek word for Sun.
Electromagnetic radiation appears not only as visible light, but also as radio wave, x-rays, and gamma-rays. These types of radiation are often nowhere near thermal equilibrium, and the spectrum we see at these frequencies is a direct reflection of the mechanisms responsible for the radiation. Radio waves are commonly created by high-velocity electrons traveling through a magnetic field. This process, called synchrotron emission, occurs in the magnetospheres of stars and in the remnants of supernovae. X-rays are created in the collisions between high-velocity electrons and atomic nuclei, a process called bremsstrahlung emission, as well as in the transitions of inner-orbit electrons bound to elements such as iron. These processes are seen in the corona of the Sun and other stars, and in the regions around neutron stars and black holes. Gamma-rays are associated with bremsstrahlung emission around neutron stars and black holes and with synchrotron emission in the extremely strong magnetic fields of neutron stars. Gamma-rays are also created in nuclear reactions. Radio waves, x-rays, and gamma-rays are therefore associated with the most extreme conditions found within our universe.
Whether we see the raw emission processes or something close to a Planck spectrum is set by the density of matter. Each emission process has an associated absorption process that destroys photons. These processes are precisely related through a physical principal called detailed balance. It is this principle that causes light to obey the laws of thermodynamics; as photons approach thermal equilibrium with a gas, detailed balance ensures that the gas emits photons of a given frequency at the same rate as it absorbs them. Because of detailed balance, materials that are strong radiators are also strong absorbers of light. High density always makes an object a strong radiator. Temperature's effect on an object's ability to radiate is more complex; usually raising the temperature causes a gas to be a stronger radiator, but under some conditions, particularly when the temperature is high enough to dissociate a gas, raising the temperature actually causes a gas to become a weaker radiator.
The Plank spectrum defines the maximum rate at which a thermal gas can radiate energy. If we took a gas that is radiating a Plank spectrum and dropped its density until we began seeing the raw emission processes, we would not only find a spectrum that deviated from the Planck spectrum, but we would also find that the intensity of this spectrum was less than the intensity of the Plank spectrum at the frequencies where the deviations from a Planck spectrum occur. The amount of power emitted as a Planck spectrum is proportional to T4, where T is the temperature. This is one of the reasons that we generally see cool bodies emitting Planck spectra, but we see very hot bodies, bodies that are hotter than the largest stars, emitting spectra that deviate dramatically from a Planck spectrum.