Earth's atmosphere happens to be essential to life, but in all other regards, it's an astronomer's worst enemy. Air is responsible for poor seeing when it bends light chaotically, causing telescopic images to waver and smear. And it's responsible for poor transparency when it absorbs and scatters light, causing faint objects to appear even fainter than they really are. Seeing is a subject for another discussion; this article focus on transparency and its close cousin, atmospheric extinction.
Considering how thick the atmosphere is, it's a miracle that we can see stars at all. If all the air were to condense into a liquid as dense as water, it would cover our planet to a depth of 10 meters (33 feet). If you think how murky even a few feet of water can be, you'll realize that air isn't so bad after all. In fact, over short distances, clean air is almost perfectly transparent. Unfortunately, the distances in question aren't short.
The atmosphere has no sharp upper boundary. NASA calls anybody who's flown higher than 50 miles (80 km) an astronaut, but air drag is still much too strong at that elevation for a satellite to orbit. If the atmosphere could somehow be made uniformly as dense as it is at sea level, it would extend up to 8,400 meters, just below the highest Himalayan peaks. But because air thins out as you get higher, only two-thirds of the atmosphere lies below that elevation. Do a Web search on "standard atmosphere" for more information.
Extinction, Scattering, and Absorption
Astronomers who specialize in photometry need to compensate for atmospheric extinction: the reduction in a celestial object's apparent brightness when its light passes through the atmosphere. This depends on three factors:
The transparency (clarity) of the air.
Your elevation above sea level.
The altitude above the horizon of your celestial target.
In this article, to avoid confusion, we will carefully restrict the meanings of "elevation" and "altitude" as described above, though they're interchangeable in normal usage.
Extinction has two components: absorption, where light is stopped cold in its tracks, and scattering, where light is diffused away from its original source. Thin fog scatters light, and smoke absorbs it. Scattering is more pernicious for astronomy, because it not only dims the object that you're observing, but also reduces contrast by brightening the background sky.
Rayleigh Scattering and Ozone Absorption
Our atmosphere absorbs most of the infrared and ultraviolet radiation that hits it. That's fortunate for us, because ultraviolet from the Sun would fry us all to a crisp in a matter of minutes if we weren't protected by the ozone layer. However, ozone absorbs only one or two percent of all light that's visible to the human eye. And as long as the air is clear, the rest of the atmosphere absorbs hardly any visible light at all. This is no accident: our eyes have evolved to make maximum use of the fairly narrow range of wavelengths that happen to penetrate the atmosphere.
But even perfectly clean air scatters quite a lot of light through the process called Rayleigh scattering. This effect is much stronger for blue light than for red, which is why the daytime sky is blue. Without scattering, the sky would appear black even at midday.
Extinction at 510 nanometers, the bluish green wavelength to which human night vision is most sensitive, is what matters most to deep-sky observers. According to Daniel W. E. Green's article Magnitude Corrections for Atmospheric Extinction, for at observer at sea level viewing a star directly overhead, Rayleigh scattering reduces the star's brightness by 0.145 magnitude at this wavelength. (Other sources yield values closer to 0.140 magnitude.) Ozone absorption removes another 0.016 magnitude, so the total extinction at sea level is roughly 0.16 magnitude for a star directly overhead if the air contains no impurities whatsoever.
At higher elevations, there's less air above you, so Rayleigh scattering is smaller. Subtract 0.03 magnitude from the zenithal extinction for every 2,000 meters of elevation. For instance, the observatories atop Mauna Kea, at 4,200 meters, experience a zenithal extinction around 0.010 magnitude when the air is perfectly clear.
Celestial Altitude and Airmasses
The closer your target is to the horizon, the more air you have to look through, and the more degraded your view gets. The amount of air directly overhead is called one airmass. (The actual amount of air in one airmass varies depending on your elevation above sea level.)
For a star 30° above the horizon, you're looking through two airmasses. At 10°, 5.6 airmasses, and for an object on the horizon, 40 airmasses. The number of airmasses is approximately 1/sin(alt), though this needs modification near the horizon because of Earth's curvature. See Green's article for a more accurate formula.
Extinction is usually measured in magnitudes per airmass. For instance, let's say that extinction is 0.16 magnitudes per airmass, the best it can ever get at sea level. Then a star overhead appears 0.16 magnitude fainter (86% as bright) as it really is, a star 30° above the horizon, with 2 airmasses to look through, appears 0.32 magnitude fainter, or 74% as bright, and an star 10° above the horizon appears 0.90 magnitude fainter, or just 44% as bright.
You can see from this example why it's so important to view objects when they're as high as possible above the horizon.
Aerosol Optical Depth
In practice, air is never perfectly clean, so stargazers usually have worse things than Rayleigh scattering to obstruct their views. That's especially true in the summer, when natural pollutants such as dust and forest-fire smoke are at their worst, and humidity combines with emissions from power plants and motor vehicles to form smog. Generically, these pollutants are called aerosols: microscopic solid or liquid particles suspended in the atmosphere.
Reduction in visibility due to aerosols is called aerosol optical depth (AOD). Optical depth is the term used by atmospheric scientists for what astronomers call extinction. Both are usually measured on logarithmic scales, but optical depth uses "natural" logs with a base of e (roughly 2.718), while astronomical magnitudes are based on the fifth root of 100 (roughly 2.512). Multiply by 1.086 to convert optical depth to magnitudes.
Crisp nights, typical in the western US, have a 550-nm AOD of 0.1 or less. An AOD of 0.2, still good enough for most deep-sky observing, is more common in the eastern US. But on hazy summer nights, the AOD can rise to 0.5 or greater, making all but the brightest deep-sky objects dull or invisible.
Extinction is about 10% stronger at 510 nm than 550 nm. So if you multiply 550-nm AOD by 1.2 (10% for the different wavelength and 10% for the difference between AOD and magnitudes), and add 0.16 for Rayleigh scattering and ozone absorption, you should get a fairly accurate estimate of atmospheric extinction at 510 nm in magnitudes per airmass.
Putting it All Together
Let's put this all together with two examples. First, we're at sea level on a mediocre but not terrible night in the eastern US, with AOD=0.2, and viewing a star 30° above the horizon. Baseline extinction is 0.16 magnitude per airmass, and aerosols add another 0.2 × 1.2 = 0.24, for a total extinction of 0.40 magnitude per airmass. The line of sight to the star passes through two airmasses, so total extinction is 0.80 magnitude. That means that only 48% of the star's light makes it through the atmosphere.
Second, we're atop Mauna Kea, at 4,200 meters, and AOD=0.04, which is rather poor for this site except when it's downwind of a volcanic eruption. We've previously calculated the baseline extinction as 0.10 magnitude per airmass, and aerosols add another 0.05, for a total of 0.15 magnitude per airmass. For a star 30° above the horizon, that means 0.3 magnitude extinction, so 76% of the star's light is still visible.
If you have Excel on your computer, you can compute extinction for yourself using this handy spreadsheet.