Atmospheric refraction
Atmospheric refraction is the deviation of light or other electromagnetic wave from a straight line as it passes through the atmosphere due to the variation in air density as a function of height. This refraction is due to the velocity of light through air decreasing (the refractive index increases) with increased density. Atmospheric refraction near the ground produces mirages. Such refraction can also raise or lower, or stretch or shorten, the images of distant objects without involving mirages. Turbulent air can make distant objects appear to twinkle or shimmer. The term also applies to the refraction of sound . Atmospheric refraction is considered in measuring the position of both celestial and terrestrial objects. Astronomical or celestial refraction causes astronomical objects to appear higher above the horizon than they actually are. Terrestrial refraction usually causes terrestrial objects to appear higher than they actually are, although in the afternoon when the air near the ground is heated, the rays can curve upward making objects appear lower than they actually are. Refraction not only affects visible light rays, but all electromagnetic radiation, although in varying degrees. For example, in the visible spectrum, blue is more affected than red. This may cause astronomical  objects to appear dispersed into a spectrum in high-resolution images. Whenever possible, astronomers will schedule their observations around the times of culmination, when celestial objects are highest in the sky. Likewise, sailors will not shoot a star below 20° above the horizon. If observations of objects near the horizon cannot be avoided, it is possible to equip an optical telescope with control systems to compensate for the shift caused by the refraction. If the dispersion is also a problem (in case of broadband high-resolution observations), atmospheric refraction correctors (made from pairs of rotating glass prisms) can  be employed as well. Since the amount of atmospheric refraction is a function of the temperature gradient, temperature, pressure, and humidity (the amount of water vapor, which is especially important at mid-infrared wavelengths), the amount of effort needed for a successful compensation can be prohibitive. Surveyors, on the other hand, will often schedule their observations in the afternoon, when the magnitude of refraction is minimum. Atmospheric refraction becomes more severe when temperature gradients are strong, and refraction is not uniform when the atmosphere is heterogeneous, as when turbulence occurs in the air. This causes suboptimal seeing conditions, such as  the twinkling of stars and various deformations of the Sun's apparent shape soon before sunset or after sunrise. Astronomical refraction. Astronomical refraction deals with the angular position of celestial bodies, their appearance as a point source, and through differential refraction, the shape of extended bodies such as the Sun and Moon. Atmospheric refraction of the light from a star is zero in the zenith, less than 1′ (one arc-minute) at 45° apparent altitude, and still only 5.3′ at 10° altitude; it quickly increases as altitude decreases, reaching 9.9′ at 5° altitude, 18.4′ at 2°  altitude, and 35.4′ at the horizon; all values are for 10 °C and 1013.25 hPa in the visible part of the spectrum. On the horizon refraction is slightly greater than the apparent diameter of the Sun, so when the bottom of the sun's disc appears to touch the horizon, the sun's true altitude is negative. If the atmosphere suddenly vanished at this moment, one couldn't see the sun, as it would be entirely below the horizon. By convention, sunrise and sunset refer to times at which the Sun's upper limb appears on or disappears from  the horizon and the standard value for the Sun's true altitude is −50′: −34′ for the refraction and −16′ for the Sun's semi-diameter. The altitude of a celestial body is normally given for the center of the body's disc. In the case of the Moon, additional corrections are needed for the Moon's horizontal parallax and its apparent semi-diameter; both vary with the Earth–Moon distance. Refraction near the horizon is highly variable, principally because of the variability of the temperature gradient near the Earth's surface and the geometric sensitivity of the nearly horizontal  rays to this variability. As early as 1830, Friedrich Bessel had found that even after applying all corrections for temperature and pressure (but not for the temperature gradient) at the observer, highly precise measurements of refraction varied by ±0.19′ at two degrees above the horizon and by ±0.50′ at a half degree above the horizon. At and below the horizon, values of refraction significantly higher than the nominal value of 35.4′ have been observed in a wide range of climates. Georg Constantin Bouris measured refraction of as much of 4° for stars on the horizon at the Athens Observatory  and, during his ill-fated Endurance expedition, Sir Ernest Shackleton recorded refraction of 2°37′: “The sun which had made ‘positively his last appearance’ seven days earlier surprised us by lifting more than half its disk above the horizon on May 8. A glow on the northern horizon resolved itself into the sun at 11 am that day. A quarter of an hour later the unreasonable visitor disappeared again, only to rise again at 11:40 am, set at 1 pm, rise at 1:10 pm and set lingeringly at 1:20 pm. These curious phenomena were due to refraction which amounted  to 2° 37′ at 1:20 pm. The temperature was 15° below 0° Fahr., and we calculated that the refraction was 2° above normal.” Day-to-day variations in the weather will affect the exact times of sunrise and sunset as well as moon-rise and moon-set, and for that reason it generally is not meaningful to give rise and set times to greater precision than the nearest minute. More precise calculations can be useful for determining day-to-day changes in rise and set times that would occur with the standard value for refraction if  it is understood that actual changes may differ because of unpredictable variations in refraction. Because atmospheric refraction is nominally 34′ on the horizon, but only 29′ at 0.5° above it, the setting or rising sun seems to be flattened by about 5′ (about 1/6 of its apparent diameter). Calculating refraction. Young distinguished several regions where different methods for calculating astronomical refraction were applicable. In the upper portion of the sky, with a zenith distance of less than 70° (or an altitude over 20°), various simple refraction formulas based on the index of refraction (and hence on the  temperature, pressure, and humidity) at the observer are adequate. Between 20° and 5° of the horizon the temperature gradient becomes the dominant factor and numerical integration, using a method such as that of Auer and Standish and employing the temperature gradient of the standard atmosphere and the measured conditions at the observer, is required. Closer to the horizon, actual measurements of the changes with height of the local temperature gradient need to be employed in the numerical integration. Below the astronomical horizon, refraction is so variable that only crude estimates of astronomical refraction can be made; for example , the observed time of sunrise or sunset can vary by several minutes from day to day. As "The Nautical Almanac" notes, "the actual values of …the refraction at low altitudes may, in extreme atmospheric conditions, differ considerably from the mean values used in the tables." Many different formulas have been developed for calculating astronomical refraction; they are reasonably consistent, differing among themselves by a few minutes of arc at the horizon and becoming increasingly consistent as they approach the zenith. The simpler formulations involved nothing more than the temperature and pressure at the observer, powers of the cotangent of the  apparent altitude of the astronomical body and in the higher order terms, the height of a fictional homogeneous atmosphere. The simplest version of this formula, which Smart held to be only accurate within 45° of the zenith, is: where "R" is the refraction in radians, "n" is the index of refraction at the observer (which depends on the temperature, pressure, and humidity), and "h" is the "apparent" altitude angle of the astronomical body. An early simple approximation of this form, which directly incorporated the temperature and pressure at the observer, was developed by George Comstock: where "R" is the  refraction in seconds of arc, "b" is the atmospheric pressure in millimeters of mercury, and "t" is the temperature in Celsius. Comstock considered that this formula gave results within one arcsecond of Bessel's values for refraction from 15° above the horizon to the zenith. A further expansion in terms of the third power of the cotangent of the apparent altitude incorporates "H", the height of the homogeneous atmosphere, in addition to the usual conditions at the observer: A version of this formula is used in the International Astronomical Union's "Standards of Fundamental Astronomy"; a comparison of the  IAU's algorithm with more rigorous ray-tracing procedures indicated an agreement within 60 milliarcseconds at altitudes above 15°. Bennett developed another simple empirical formula for calculating refraction from the apparent altitude which gives the refraction "R" in arcminutes: This formula is used in the U. S. Naval Observatory's "Vector Astrometry Software", and is reported to be consistent with Garfinkel's more complex algorithm within 0.07′ over the entire range from the zenith to the horizon. Sæmundsson developed an inverse formula for determining refraction from "true" altitude; if "h" is the true altitude in degrees, refraction "R" in  arcminutes is given by the formula is consistent with Bennett's to within 0.1′. The formulas of Bennet and Sæmundsson assume an atmospheric pressure of 101.0 kPa and a temperature of 10 °C; for different pressure "P" and temperature "T", refraction calculated from these formulas is multiplied by Refraction increases approximately 1% for every 0.9 kPa increase in pressure, and decreases approximately 1% for every 0.9 kPa decrease in pressure. Similarly, refraction increases approximately 1% for every 3 °C decrease in temperature, and decreases approximately 1% for every 3 °C increase in temperature. Random refraction effects. Turbulence  in Earth's atmosphere scatters the light from stars, making them appear brighter and fainter on a time-scale of milliseconds. The slowest components of these fluctuations are visible as twinkling (also called "scintillation"). Turbulence also causes small, sporadic motions of the star image, and produces rapid distortions in its structure. These effects are not visible to the naked eye, but can be easily seen even in small telescopes. They perturb astronomical seeing conditions. Some telescopes employ adaptive optics to reduce this effect. Terrestrial refraction. Terrestrial refraction, sometimes called geodetic refraction, deals with the apparent angular position and measured distance  of terrestrial bodies. It is of special concern for the production of precise maps and surveys. Since the line of sight in terrestrial refraction passes near the earth's surface, the magnitude of refraction depends chiefly on the temperature gradient near the ground, which varies widely at different times of day, seasons of the year, the nature of the terrain, the state of the weather, and other factors. As a common approximation, terrestrial refraction is considered as a constant bending of the ray of light or line of sight, in which the ray can be considered as describing a circular  path. A common measure of refraction is the coefficient of refraction. Unfortunately there are two different definitions of this coefficient. One is the ratio of the radius of the Earth to the radius of the line of sight, the other is the ratio of the angle that the line of sight subtends at the center of the Earth to the angle of refraction measured at the observer. Since the latter definition only measures the bending of the ray at one end of the line of sight, it is one half the value of the former definition. The coefficient of refraction  is directly related to the local vertical temperature gradient and the atmospheric temperature and pressure. The larger version of the coefficient "k", measuring the ratio of the radius of the Earth to the radius of the line of sight, is given by: where temperature "T" is given in kelvins, pressure "P" in millibars, and height "h" in meters. The angle of refraction increases with the coefficient of refraction and with the length of the line of sight. Although the straight line from your eye to a distant mountain might be blocked by a closer hill, the ray may curve enough  to make the distant peak visible. A convenient method to analyze the effect of refraction on visibility is to consider an increased effective radius of the Earth "R", given by where "R" is the radius of the Earth and "k" is the coefficient of refraction. Under this model the ray can be considered a straight line on an Earth of increased radius. The curvature of the refracted ray in arc seconds per meter can be computed using the relationship where 1/σ is the curvature of the ray in arcsec per meter, "P" is the pressure in millibars, "T" is  the temperature in kelvins, and β is the angle of the ray to the horizontal. Multiplying half the curvature by the length of the ray path gives the angle of refraction at the observer. For a line of sight near the horizon cos β differs little from unity and can be ignored. This yields where "L" is the length of the line of sight in meters and Ω is the refraction at the observer measured in arc seconds. A simple approximation is to consider that a mountain's apparent altitude at your eye (in degrees) will exceed its true altitude  by its distance in kilometers divided by 1500. This assumes a fairly horizontal line of sight and ordinary air density; if the mountain is very high (so much of the sightline is in thinner air) divide by 1600 instead.