CO_REFRACT
Name
 
   CO_REFRACT()      
Purpose
 
   Calculate correction to altitude due to atmospheric refraction.
Description
 
   CO_REFRACT can calculate both apparent altitude from observed altitude and 
  
   vice-versa.
Calling Sequence
 
   new_alt  = CO_REFRACT(old_alt, [ ALTITUDE= , PRESSURE= , $
                    
             
                                  TEMPERATURE= , /TO_OBSERVED , EPSILON= ])
Input
 
   old_alt - Observed (apparent) altitude, in DEGREES.  (apparent if keyword 
            
             /TO_OBSERVED set).    May be scalar or vector.
Output
   
     Function returns apparent (observed) altitude, in DEGREES. (observed if 
        
         keyword /TO_OBSERVED set).    Will be of same type as input 
        
         altitude(s).
Optional Keyword Inputs
     
      ALTITUDE :  The height of the observing location, in meters.  This is 
            
             only used to determine an approximate temperature and pressure, 
            
             if these are not specified separately. [default=0, i.e. sea level]
      
      PRESSURE :  The pressure at the observing location, in millibars.
      
      TEMPERATURE:    The temperature at the observing location, in Kelvin.
      
      EPSILON:  When keyword /TO_OBSERVED has been set, this is the accuracy 
              
               to  obtain via the iteration, in arcseconds [default = 0.25 
                
                arcseconds].
      
      /TO_OBSERVED:  Set this keyword to go from Apparent->Observed altitude, 
                
                 using the iterative technique.
      
       Note, if altitude is set, but temperature or pressure are not, the 
      
       program will make an intelligent guess for the temperature and pressure.
Description
  
   Because the index of refraction of air is not precisely 1.0, the atmosphere
  
   bends all incoming light, making a star or other celestial object appear at
  
   a slightly different altitude (or elevation) than it really is.  It is 
  
   important to understand the following definitions:
  
   Observed Altitude:  The altitude that a star is SEEN to BE, with a telescope.
                    
 
                       This is where it appears in the sky.  This is always 
                    
 
                       GREATER than the apparent altitude.
  
   Apparent Altitude:  The altitude that a star would be at, if *there were no
                    
                     atmosphere* (sometimes called "true" altitude). This is 
                    
                     usually calculated from an object's celestial coordinates.
                    
                     Apparent altitude is always LOWER than the observed 
                    
                     altitude.
  
   Thus, for example, the Sun's apparent altitude when you see it right on the
  
   horizon is actually -34 arcminutes.
  
   This program uses couple simple formulae to estimate the effect for most 
  
   optical and radio wavelengths.  Typically, you know your observed altitude 
  
   (from an observation), and want the apparent altitude.  To go the other way,
  
   this program uses an iterative approach.
Example
   
    The lower limb of the Sun is observed to have altitude of 0d 30'.   
    
    Calculate the the true (=apparent) altitude of the Sun's lower limb using 
    
    mean  conditions of air pressure and temperature
    
    IDL> print, co_refract(0.5)     ===>  0.025degrees (1.55')
  
 WAVELENGTH DEPENDENCE:
    
    This correction is 0 at zenith, about 1 arcminute at 45 degrees, and 34 
    
    arcminutes at the horizon FOR OPTICAL WAVELENGTHS.  The correction is 
    
    NON-NEGLIGIBLE at all wavelengths, but is not very easily calculable.  
    
    These formulae assume a wavelength of 550 nm, and will be accurate to 
    
    about 4 arcseconds for all visible wavelengths, for elevations of 10 
    
    degrees and higher.    Amazingly, they are also ACCURATE FOR RADIO 
    
    FREQUENCIES LESS THAN ~ 100 GHz.
    
    It is important to understand that these formulae really can't do better 
    
    than about 30 arcseconds of accuracy very close to the horizon, as 
    
    variable atmospheric effects become very important.
References
   
    1.  Meeus, Astronomical Algorithms, Chapter 15.
    
    2.  Explanatory Supplement to the Astronomical Almanac, 1992.
    
    3.  Methods of Experimental Physics, Vol 12 Part B, Astrophysics, 
        
        Radio Telescopes, Chapter 2.5, "Refraction Effects in the Neutral 
        
        Atmosphere", by R.K. Crane.
Dependencies
   
    CO_REFRACT_FORWARD (contained in this file and automatically compiled).
Author
 
   Chris O'Dell
      
       Univ. of Wisconsin-Madison
  
   Observational Cosmology Laboratory
  
   Email: odell@cmb.physics.wisc.edu
Revision History
   
    version 1 (May 31, 2002)
    
    Update iteration formula,   W. Landsman    June 2002
    
    Corrected slight bug associated with scalar vs. vector temperature and 
              
               pressure inputs. 6/10/2002
    
    Fixed problem with vector input when /TO_OBSERVED set W. Landsman Dec 2005
    
    Allow arrays with more than 32767 elements W.Landsman/C.Dickinson Feb 2010