I have constructed a model for the purposes of determining an algorithm for calculating refraction from JCMT, and have derived such algorithms for wavelengths of 1mm and 0.55microns. The 1mm results are applicable throughout the sub-mm region.
The model
Refraction under any given atmospheric conditions and at any elevation is then determined by an integration along the light path, through the atmosphere. While the temperature and pressure profiles are fairly well defined, and in the tropics especially seem to vary little from season to season, the humidity can take many profiles. However, experimentation early on in this work showed that the refraction was essentially independent of the humidity profile, and depended only upon the humidity at the altitude of the observer. This is similar to the general plane parallel medium case where the refraction depends only on the indices at the ends of the light path.
The ambient temperature and pressure are compared with the nominal values from the mean profiles ( 3degC and 624mb for the altitude of JCMT) to specify the way the mean profiles are adjusted for the integration.
The integration results agree very well with the values quoted by Allen(AQ3,p125) for optical refraction under standard conditions from sea- level, and with Ulich's(1980, Intl. J. of I-R & Mm Waves Vol 2 No 2 p293) values for (sub)-millimeter refraction from an altitude of 2km, so we have confidence in the model.
Assuming, as is generally held, that refraction takes the general form
where Z is the zenith distance ( and E is the elevation), the essence of producing the algorithm is in determining A and B. By allowing the atmospheric parameters (T,p,and h) to vary separately and in pairs and by performing integrations through the atmosphere at 45degs elevation it is possible to determine the form of A, and by integrations at low elevations to determine the form of B. Because the refraction behaves almost exponentially at low elevations the applicabilty of any derived form of B, which transpires to be primarily elevation dependent, depends very sensitively upon the range of elevation covered by the experiments. An elevation limit of 5degrees was chosen and above this elevation B, it will be seen, is well described by a second order polynomial in elevation. Below this elevation the errors quickly grow and are available as a set of look-up Tables.
     We find
           
         A = C0 + C1*(h-20) + C2*p + C3*T + C4*T**2 + cross-terms
     where  
                      1mm                0.55microns
         C0 =        37.823                 37.080
         C1 =         0.0681                -0.0006
         C2 =         0.371                  0.371
         C3 =        -0.133                 -0.137
         C4 =         0.00047                0.00047
    and the cross-terms are
          h(0.004433*T + 0.000133*T**2 + 0.000002*T**3)  for   1mm
    and     -0.001333*p*T                                for  0.55 microns
    and  
          B = D0  +  D1*E  +  D2*E**2
  where
         D0 =        -0.0242                  -0.0238
         D1 =        -0.00212                 -0.00227
         D2 =         0.0000676                0.0000819
          E is the elevation in degrees
          T (degC) is the ambient temperature
          h (%)    is the ambient relative humidity
     and  p (%)    is the ambient pressure difference from nominal
                            (624mb for the altitude of JCMT).
     The formula reproduces the integrations through the atmosphere to within
     about half an arcsecond for elevations above 10degrees and under most
     expected conditions of the atmosphere. The errors increase towards lower
     elevations and with increasingly abnormal atmospheric conditions.
     Tables are available showing these errors or may be constructed upon 
     request.
I would like to think that these formulae would be incorporated into the JCMT telescope software as soon as possible so that real-time accounting for the effects of refraction upon the pointing may be made. This will require both hardware and software effort, but I believe that this issue is crucial to the performance of JCMT and should be well rewarded.
As an intermediate step, tables are also available giving the values of A for the range of expected atmospheric conditions. These could be entered into the system 'manually'. The independence of B from the atmospheric parameters means that only this one number is needed.
Implementation is described in mtun133 by Coulson & Mayer.
A single algorithm giving the refraction at any optical or infra-red wavelength from UKIRT has also been produced.
Iain Coulson  -  20 Feb 1988 
Updated       -  05 Sep 2001
Latest Update -  31 May 2017
Subsequent empirical amendments to this refraction code at JCMT :
The effects of refraction upon are described in a 1992 paper by Bill Duncan : " Expectation Values of Signal levels in the presence of Refraction"
The September 1987 document describes the basis of the above model. It is also mentioned in some June 1995 correspondence with Pat Wallace (then Starlink Project Manager), which showed good agreement between this model and that now installed as the Starlink document SLA_REFRO . See also related code SLA_REFCO , and SLA_REFCOQ .
2008 Aug 13
Pat Wallace has " . . . added to the SLALIB refraction
function slaRefro a correction for the spectral features that come in 
above
above 100 GHz.  The plot shows the 
pointing changes at different
frequencies up to 1 THz, for an ALMA test case.  The ZD is 80 deg.  The
admittedly rather extreme weather readings . . . used are 560 mb, 10 degC
and 50% RH."