A Protective Blanket
Retained by the Earth’s gravity, the atmosphere protects life on Earth from the harsh vacuum of outer-space, and filters out the Sun’s high energy rays, whilst allowing through those lower energy rays critical for life. The atmosphere absorbs large amounts of energy from the Sun, and much of the radiation emitted from the Earths' surface; and when the atmosphere reaches its temperature limit, it emits excess heat in all directions - with some of this going back towards Earth (back radiation). The Earth, therefore, is heated by the Sun and the Atmosphere (the Greenhouse Effect), and for this reason it is estimated that Earth is 30°C warmer due to the presence of the Atmosphere. The Atmosphere also reduces temperature extremes between day and night (diurnal temperature variation), and between the equator and the poles.
Earth’s atmosphere is best described through the varying temperature dynamics at different altitudes; these differences form the five principle layers - the four outer layers are discussed further below. The distinct temperature dynamics are a result of how the atmosphere, at different altitudes, reacts (photochemical and photophysical processes) with the electromagnetic energy from the Sun and Earth; which varies due to many factors, including the distance from the Earth, night and day, density, pressure, composition, molecular weight of elements, and the mixing of elements for instance. Some of the more important processes are described below and are illustrated to the right. Note: Many of the chemical and photochemical reactions due to human activities, and those by natural events such as lightening, are not included.
The Micro Journey
Below: A section through the Atmosphere’s top four principle layers. A closer visual detail of some of the different ways that the Sun’s electromagnetic radiation is being scattered, absorbed and emitted.
“The outermost layer of air, so thin as to contain only a few hundred atoms per cubic centimetre, the exosphere, can be thought of as merging into the equally thin outer atmosphere of the sun.” 
The furthest principle layer from Earth is the Exosphere, the transitional zone between Earth’s atmosphere and outer-space (half way between Earth and the Moon). It is mainly made up of the lightest gas hydrogen (H), and some helium (He), with small amounts of carbon-dioxide (CO2) and atomic oxygen (8O) nearer the base (the Exobase). Due to the extremely low density of the exosphere, atomic collisions are very rare, though due to the high velocity of atoms, some can break out of Earth’s gravitational pull, and ‘leak’ out into outer-space.
Within the Exosphere is the Geocorona, the first line of defence against shortwave radiation coming from the Sun. Here, neutral hydrogen atoms (1H) absorb and emit some of the Extreme UV rays back to Space (and in all other directions). Hydrogen also reacts with some of the ionised oxygen atoms (i.e. O5, O6, and O7) in the Solar-wind through a process known as charge exchange, whereby the ionised oxygen atom takes the hydrogen’s electron and emits the access energy as X-rays (as the new electron falls into the vacancy in the inner shell). The Geocorona also plays an important role in Earth’s plasma budget.
Ionised hydrogen (H-1) within the exosphere can react with the Sun’s high energy gamma rays, through a process known as the Compton Effect. Here the gamma ray has enough energy to knock one of the hydrogen’s free electrons out of its' orbit, but this forsakes energy (breaking the Electromagnetic Force bonding the electron to the atom nucleus), and so the remaining radiation that is emitted is of a lower energy. Meaning that each encounter demotes the energy of the radiation. Another primary process in which high energy gamma rays transfer energy is by pair production. Usually in the presence of an atomic nucleus to conserve momentum (shown in the image to the right as the nucleus within a Hydrogen atom), the gamma (or X-ray) disappears and an electron and a positron appear in its place. A positron will annihilate itself on impact with an electron, releasing two gamma photons of slightly lower energy.
At the base of the exosphere there is a transition boundary, known as the Thermopause, who’s altitude varies, due mainly to changes in solar activity (increased solar activity makes the the layer below get hotter and expand/puff upwards). Therefore, below the Thermopause the atmosphere is defined as active with the insolation received (due to the increased presence of heavier gases, such as atomic oxygen - 8O).
The next principle layer is the Thermosphere. Within the upper kilometres, density is still relatively low, but collision frequency (although low), is far higher than in the Exosphere above. In this region, the different elements tend to stratify by molecular weight. Here the gases are mainly the lighter atomic gases: oxygen (8O), nitrogen (8N), helium (2He) and some traces of Hydrogen (H1).
Within the Thermosphere is the ionosphere; a plasma of highly charged ions and free electrons. The ionosphere also has distinguishable layers, due to the varying dynamics at different altitudes (D, E and F). Almost all of the Sun’s harder rays: X-rays - HX (hard) and SX (soft), and the harder UV rays - EUV (Extreme) are absorbed and emitted in the ionosphere. This creates heat through a process known as the photoelectric effect, where these higher energy rays, have the ability to ionise atoms and molecules. Greater quantities of atomic oxygen can be found at higher altitudes in the Thermosphere, and as this is the predominant ionising atom, temperatures increase with altitude.
“[Within the ionosphere we]...encounter the fierce unfiltered rays of the sun [and] the pace of chemical reactions accelerates. In these regions most molecular species other than nitrogen and carbon monoxide tend to split into their constituent atoms. Some atoms and molecules are further dissociated into positive ions and electrons, thus forming the electrically conducting layers which, in the days before orbiting man-made satellites, were important for their capacity to reflect radio-waves and allow global communication.” 
At the base of the Thermosphere is the Mesopause, and below it is the next principle layer of Earth’s atmosphere, the Mesosphere. It is the layer where most meteors burn up upon entering, and near the top there is a 5km deep sodium layer, made of unbound, non-ionised Sodium atoms. There is also mixing with strong zonal East to West winds and Atmospheric Tides, many of which have propagated upwards from the layers below. Here Gravity Waves can become so large that the waves become unstable and dissipate, creating a momentum mostly responsible for driving global circulation.
Within the upper kilometres of the Mesosphere are also Noctilucent Clouds, which are crystals of water ice. This phenomena is possible because of the incredibly cold temperatures, which are due to the radiative cooling of Carbon Dioxide (CO2) and Nitric Oxide. Unlike in the lower atmosphere where Carbon Dioxide adds to the Greenhouse Effect resulting in heating up of the atmosphere, in the Mesosphere CO2 is thought to cool the atmosphere. The reason is proposed to be due to a difference in density: Near the Earth’s Surface, the CO2 absorbs radiation escaping Earth, and in this highly dense zone, it will collide with other molecules giving up it’s energy to the air as heat. However, the CO2 that has escaped up to the lower density Mesosphere or even Thermosphere, acts in reverse, as here, the CO2 absorbs energy from impacts with other molecules (such as O2), but due to the lower density, it has more time to now release this energy as heat radiation into space, therefore cooling the Mesopause.
The Mesosphere also has the lowest ionosphere, the D Layer. Only present during the day as recombination is high, ionisation occurs through some hard X-ray photons (HX) ionising Nitrogen (N2) and Oxygen (O2) molecules, but the majority of ionisation in this layer is of Nitric Oxide by Lyman series-alpha Hydrogen radiation. In this process X-rays photons, on impact with some of the traces of Hydrogen, excite the electron to a second orbit level, and after it falls back to its ground state, it releases a lower energy EUV photon, which ionises Nitric Oxide.
“This region is so named because the air in it does not easy mix in a vertical direction although fierce winds of hundreds of miles per hour blow at a constant level. The temperature is very low at the lower boundary of the stratosphere, the tropopause, but rises as we travel upwards.” 
As the remaining photons reach the lower altitude of the Stratosphere, those with the wavelength between 240 and 310 nm - UV radiation, are blocked by oxygen molecules through a process known as the Ozone-Oxygen Cycle; creating a zone within the stratosphere known as the Ozone Layer (O3).
As a UV-c photons strike the Oxygen molecule (O2), it has enough energy to split the Oxygen into its two individual atoms - 2 x atomic oxygen (8O); The oxygen atom is very reactive and it is not long until it will itself collide with another oxygen atom (reforming the original O2), or colliding with an ‘original’ O2 molecule, creating a new molecule, O3 (Ozone), or colliding with Nitrogen molecule N2 creating Nitrous Oxide N2O. The UV-c energy is completely absorbed in this reaction as kinetic energy of molecular motion. This mostly takes place in the top of the ozone layer.
As UV-b photons strike these O3 molecules, it breaks them apart, back into a oxygen molecule and a free oxygen atom.
By the time the UV reaches the ground it is about 95% UV-a and 5% UV-b (UV-c is completely absorbed). UV-b causes sunburn, but is also required for the synthesis of vitamin D3 (cholecalciferol) in human skin, which is rare in foods, and is important for functions, such as intestinal absorption of calcium, magnesium, phosphate and zinc.
O3 and atomic oxygen are very unstable, and are very reactive. This cycle is effected by natural trace gas - free radical catalysts - such as nitrogen, hydrogen, chlorine, and bromine compounds. Small amounts of these gases can be from natural sources, however, particularly compounds of Chlorine, Nitrogen, and Bromine have increased, due to human activities, and have depleted the ozone layer, by a worldwide average of around four percent.
It is believed that the high level of oxygen in the atmosphere today is due to the evolution of oxygenic photosynthesis by cyanobacteria (sometimes still called "blue-green algae") some 3 million years ago. Their growth across the planet was relatively fast, as they began to incorporate hydrogen (H) from water (H2O) into their bodies, releasing oxygen as O2 (as "waste") in the process. The eventual increase in oxygen in the atmosphere, destroyed much of Earth's early life-forms, which was anaerobic (with low or no oxygen tolerance), however, as explained by Margulis (1995), this eventually helped make further, oxygen forms of, life possible and thrive:
“By growing, [the cyanobacteria] increased atmospheric oxygen concentration from less than one part in 1,000 million to one part in five (20 percent). And Earth's protective, ultraviolet-shielding layer of ozone... was built up largely by [these beings]. ...Today the ozone layer protects animals such as ourselves from ultraviolet skin cancer, cataracts, and compromised immune systems.” 
As a summary, virtually all the hard rays from the Sun, and other astrophysical sources, are blocked by Earth’s upper atmosphere; allowing only wavelengths of visible light (the ‘Optical Window’), some ultraviolet, and a wide range of radio waves (the ‘Radio Window’). The type of electromagnetic energy that can get through, is known as the Atmospheric Opacity. The 'zoomed-in' image at the top of the image shows in greater detail the main areas of opacity, and which gases are responsible for blocking the sunlight at a particular wavelength.
Figure 3: The image above (adapted from work from NASA), is another way of showing what is in the main image at the top of the page.
The image is based on information from many different sources, here are some of the most influential:
Astronomy Cast: www.atronomycast.com
 Lovelock, James. (2016 Second Edition) Gaia: A New Look at Life on Earth.’ Oxford University Press. U.K.
 Margulis, Lynn and Sagan, Dorion. (1995) 'What is Life?' University of California Press, Berkeley and Los Angles, California. U.S.A.
Windows to the universe: www.windows2universe.org
A molecule: Is a group of two or more atoms held together by covalent chemical bonds (the sharing of electrons between atoms). Argon is also classed as a molecule even though it has only one atom.
Photochemical: Chemical reactions that proceed with the absorption of light by atoms or molecules.
Photophysical: Describing photoexcitation - excitation of atoms or molecules with the absorption of light - and any subsequent process that does not involve any chemical change.
Insolation: Is a measure of solar radiation energy received on a given surface area and recorded during a given time.