The Museum of HP Calculators

# Astronomical Refraction for the HP-41

This program is Copyright © 2006 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

1°) Standard Atmosphere

a) Apparent Altitude >>> True Altitude
b) Other Simple Formulae
c) True Altitude >>> Apparent Altitude

2°) More general Programs

a) A short routine
b) A middle program
c) A long program

-The light coming from a star is curved by the atmosphere, so that its apparent altitude differs from its true altitude.
-The refraction R allows to convert the apparent altitude h0 and the true altitude h of a given star:   h = h0 - R
-The following programs use data from the Pulkovo Refraction Tables.

1°)  Standard Atmosphere(s)

a) Apparent Altitude >>> True Altitude

-The short routine hereafter gives relatively accurate results in the following atmospheric conditions:

Temperature:                                +15°Celsius
Pressure:                                    1013.25 mbar
Light wave-length:                         0.590 µm
Partial pressure of water vapor:          0   ( dry air )
Latitude:                                           45°
Observer's altitude:                            0   ( i-e at sea-level )

Formula:    R ~ (1°/62.83)/Tan( h0 + 4.208/( h0 + 14.978/( h0 + 5.906 ) ) )       where h0 is expressed in degrees

-Errors are smaller than  0"34  over the whole range [ 0° , 90° ]

01  LBL "H0-H"
02  DEG
03  HR
04  14.978
05  RCL Y
06  5.906
07  +
08  /
09  +
10  4.208
11  X<>Y
12  /
13  +
14  TAN
15  1/X
16  62.83
17  /
18  X<0?
19  CLX
20  ST- Y
21  HMS
22  X<>Y
23  HMS
24  END

( 52 bytes / SIZE 000 )

 STACK INPUTS OUTPUTS Z / h0 Y / R X h0 h

-All angles expressed in ° ' " ( but Z-output in degrees and decimals )

Examples:     With  h0 = 1°30'00"  ;   h0 = 27°  ;   h0 = 0

1.30  XEQ "H0-H"  >>>>   h =   1°09'42"6    RDN    R = 0°20'17"4
27        R/S            >>>>   h = 26°58'08"3    RDN    R = 0°01'51"7
0         R/S            >>>>   h = -0°32'58"0     RDN   R =  0°32'58"0

-For the horizontal refraction, "H0-H" yields 1977"977
-According to Pulkovo refraction tables, it should be  1977"971

-A more accurate formula is:

R ~ (1°/62.97411)/Tan( h0 + 3.86653/( h0 + 6.24727/( h0 + 8.56113/( h0 + 22.89592/( h0 + 7.15359 ) ) ) ) )

-Errors are smaller than 0"06  over the whole range [ 0° , 90° ]

-Laplace formula  R = 57".085/Tan h0 - 0".0666/Tan3 h0  gives even better results if h0 > 20° , more precisely:

errors are smaller than   0"02   for h0 > 20°
----------------------    0"01   for h0 > 23°
----------------------   0"002  for h0 > 30°

b) Other Simple Formulae

-We can build similar formulae for other atmospheric conditions.

R  ~   a/Tan( h0 + b/( h0 + c/( h0 + d ) ) )       where h0 is expressed in degrees

-For a dry air, light wave-length = 0.59 µm , latitude = 45° at sea-level, we find:

 t (°C) P (mbar) a b c d E error(0) -30 1013.25 67"8716 3.3124 13.2157 4.9474 0"20 -80"0 -10 1013.25 62"720 3.713 14.049 5.389 0"28 -33"6 +10 1013.25 58"292 4.093 14.561 5.730 0"30 -4"9 +30 1013.25 54"451 4.469 15.077 6.089 0"32 +14"4 15 500 28"265 4.438 15.125 5.892 0"17 0"17 15 700 39"576 4.350 15.088 5.904 0"23 0"09 15 900 50"885 4.253 14.937 5.881 0"29 0"23 15 1100 62"187 4.145 14.609 5.801 0"32 0"02

-  E is the maximum error ( in absolute value ) over the interval  [ 0°10' ; 90° ]
-  error(0) is the error at the horizon ( compared with the Pulkovo tables )

-As you can see, error(0) is much greater than E when  t < 15°C or t > 15°C , especially for very low temperatures,
and I don't really know the behavior of the function R(h0)  for  0° < h0 < 0°10'  if t # 15°C

c) True Altitude >>> Apparent Altitude

-We now assume t = 15°C & P = 1013.25 mbar again with the other standard parameters above.

Formula:    R ~ (1°/62.6)/Tan( h + 5.459/( h + 19.272/( h + 6.942 ) ) )       where h is expressed in degrees

-Errors are smaller than  0"8  over the whole range [ -0°32'58" , 90° ]

01  LBL "H-H0"
02  DEG
03  HR
04  19.272
05  RCL Y
06  6.942
07  +
08  /
09  +
10  5.459
11  X<>Y
12  /
13  +
14  TAN
15  1/X
16  62.6
17  /
18  X<0?
19  CLX
20  ST+ Y
21  HMS
22  X<>Y
23  HMS
24  END

( 51 bytes / SIZE 000 )

 STACK INPUTS OUTPUTS Z / h Y / R X h h0

-All angles expressed in ° ' " ( but Z-output in degrees and decimals )

Example:        With  h = 1°30'00"

1.30  XEQ "H-H0"  >>>>  h0 = 1°48'38"6    RDN    R = 0°18'38"6

2°)  More General Programs

a) A Short Routine

-We still assume a dry air, light wave-length = 0.59 µm , latitude = 45° , altitude = 0
but now, the temperature t may be different from 15°C and the pressure P may be different from 1013.25 mbar.

Formula:    R ~ (P/1013.25).(288.15/(t+273.15)).(1°/62.83)/Tan( h0 + 4.208/( h0 + 14.978/( h0 + 5.906 ) ) )       where h0 is expressed in degrees

Data Registers:    R00 = unused                                ( Registers R01 & R02 are to be initialized before executing "REF" )
•  R01 = t     ( in °C )
•  R02 = P    ( in mbar )
Flags: /
Subroutines: /

01  LBL "REF"
02  DEG
03  HR
04  14.978
05  RCL Y
06  5.906
07  +
08  /
09  +
10  4.208
11  X<>Y
12  /
13  +
14  TAN
15  1/X
16  220.935
17  /
18  RCL 01
19  273.15
20  +
21  /
22  RCL 02
23  *
24  X<0?
25  CLX
26  ST- Y
27  HMS
28  X<>Y
29  HMS
30  END

( 64 bytes / SIZE 003 )

 STACK INPUTS OUTPUTS Y / R X h0 h

-All angles expressed in ° ' "

Example:       t = -10°C , P = 1100 mbar      -10  STO 01   1100   STO 02

-If   h0 =  12°34'56"    12.3456  XEQ "REF"  >>>>   h = 12°29'59"   X<>Y   R = 0°04'57"
-If   h0 =  10°12'34"    10.1234       R/S          >>>>   h = 10°06'30"   X<>Y   R = 0°06'04"

-The results are acceptable for  h0 > 10°  ( errors are of the order of 1 or 2 arcseconds for h0 = 10° )
-For heights of a few degrees, the outputs are much more doubtful.

b) A Middle Program

-We suppose a light wave-length = 0.59 µm , latitude = 45° , altitude = 0
but the temperature t , the pressure P and the humidity f may have non-standard values.
-To make a little change, P & f  are expressed in mmHg  ( 760 mmHg = 1013.25 mbar )

Formulae:   The standard refraction is computed by  R0 ~ (1°/62.83)/Tan( h0 + 4.208/( h0 + 14.978/( h0 + 5.906 ) ) )

then, coefficents A , B , D  ( defined in the next paragraph ) are calculated by:

A ~ (1/307.5).[(15-t) + (15-t)2/271].[ exp(-0.81 h00.957) + exp(-0.846 h00.566) ]
B ~ (1/6) 10 -7 [ 3480 (p-760) + (p-760)2 ].[ exp(-0.384 h00.763) + exp(-0.541 h01.123) ]
D ~ (1/759) 10 -4 ( f 3 - 190.f 2 -1852.f ) exp(-0.928 h00.652)

Data Registers:    R00 = h0                                                                   ( Registers R01 thru R03 are to be initialized before executing "REF2" )
•  R01 = t     ( in °C )           ( -10 <= t <= +30 )
•  R02 = P    ( in mmHg )     ( 525 <= P <= 825 )
•  R03 = f     ( in mmHg )      ( 0 <= f <= 15 )
Flags: /
Subroutines: /

01  LBL "REF2"
02  DEG
03  HR
04  STO 00
05  14.978
06  RCL 00
07  5.906
08  +
09  /
10  +
11  4.208
12  X<>Y
13  /
14  +
15  TAN
16  RCL 02
17  166.566
18  /
19  X<>Y
20  /
21  271.677
22  RCL 01
23  +
24  /
25  RCL 03
26  4935
27  /
28  RCL 03
29  320
30  /
31  X^2
32  +
33  *
34  -
35  RCL 00
36  .957
37  Y^X
38  .81
39  *
40  CHS
41  E^X
42  RCL 00
43  .566
44  Y^X
45  .846
46  *
47  CHS
48  E^X
49  +
50  15
51  RCL 01
52  -
53  X^2
54  271
55  ST/ Y
56  X<> L
57  +
58  307.5
59  /
60  *
61  *
62  +
63  RCL 00
64  .763
65  Y^X
66  .384
67  *
68  CHS
69  E^X
70  RCL 00
71  1.123
72  Y^X
73  .541
74  *
75  CHS
76  E^X
77  +
78  RCL 02
79  760
80  -
81  X^2
82  3480
83  ST* L
84  X<> L
85  +
86  *
87  6 E7
88  /
89  *
90  +
91  RCL 03
92  190
93  -
94  RCL 03
95  *
96  1852
97  -
98  RCL 03
99  *
100  759 E4
101  /
102  RCL 00
103  .652
104  Y^X
105  .928
106  *
107  E^X
108  /
109  *
110  +
111  RCL 00
112  X<>Y
113  X<0?
114  CLX
115  ST- Y
116  HMS
117  X<>Y
118  HMS
119  END

( 216 bytes / SIZE 004 )

 STACK INPUTS OUTPUTS Y / R X h0 h

( All angles expressed in ° ' " )   Execution time = 11 seconds.

Example:         t = 5°C ;  P = 800 mmHg  ;  f = 6 mmHg

5 STO 01    800 STO 02    6 STO 03

-If   h0 =  0°                     0      XEQ "REF2"  >>>>   h = -0°38'25"     X<>Y   R = 0°38'25"
-If   h0 =  10°23'45"    10.2345       R/S          >>>>   h = 10°18'16"4   X<>Y   R = 0°05'28"6
-If   h0 =  49°12'34"    49.1234       R/S          >>>>   h = 49°11'40"3   X<>Y   R = 0°00'53"7

-If  h0 > 20° more accurate results will be obtained if  R0 is computed by Laplace's formula.
-The accuracy is of the order of 10" near the horizon, but errors rapidly decrease as h0 increases.
-However, disturbances of the atmosphere make accurate results more theoretical than real for very small h0-values:
near the horizon, the refraction may fluctuate by several arcminutes!

-Nevertheless, the following program tries to produce the accurate values of the Pulkovo refraction tables,
and the other parameters are now taken into account:

c) A Long Program

-This program uses the following formula to compute the atmospheric refraction in a standard atmosphere:

R0 ~ (1°/62.97411)/Tan( h0 + 3.86653/( h0 + 6.24727/( h0 + 8.56113/( h0 + 22.89592/( h0 + 7.15359 ) ) ) ) )

-Then, refraction R in more general conditions is calculated by:

R = R0 (1.0552126/(1+0.00368084.t)).(1+A).(P/1013.25).(1+B).(0.98282+0.005981/Lwl2).(1+C).(1-0.152 10 -3 f -0.55 10 -5 f 2 ).(1+D).(1+E).(1+F)

where    t = temperature (°C) ; P = pressure (mbar) ; f = partial pressure of water vapor (mbar)
Lwl = Light wave-length ( µm ) ; lat = latitude
alt = observer's altitude ( over sea-level ) in meters.

- A , B , C , D , E , F are coefficients which depend on the temperature, pressure, Light wave-length, humidity, latitude and observer's altitude respectively.

-They are very small near the zenith, but they can't be neglected near the horizon!
-Reference [1] provides tables for these coefficients, but "REFR" uses approximate formulae instead:

-Lagange's interpolation formula is used to obtain A and B for other t- and P-values.

Coefficient A:         With  x = 1/(1+h0)

-If t = -30°C    105A = Max ( -2 - 1411 x + 100967 x2 + 3583 x3 - 465432 x4 + 928890 x5 - 783471 x6 + 251549 x7 + 2377 e -43.h0 ; 0 )
-If t = -10°C    105A = Max (  -880 x + 57082 x2 - 6928 x3 - 250807 x4 + 515833 x5 - 438687 x6 + 141374 x7 + 976 e -41.h0 ; 0 )
-If t = +10°C    105A = Max ( -175 x + 11332 x2 - 1318 x3 - 54120 x4 + 112625 x5 - 96545 x6 + 31284 x7 + 147 e -30.h0 ; 0 )
-If t = +15°C          A = 0
-If t = +30°C    105A = Min ( -1 + 589 x - 34750 x2 + 9753 x3 + 154745 x4 - 335229 x5 + 291742 x6 - 95395 x7 - 284 e -37.h0 ; 0 )

-The exponential terms on the right are quite arbitrary and the results are uncertain for 0° < h0 < 0°10' ( though correct for h0 = 0° and 0°10' )
-The coefficient A increases more rapidly ( for t < 15°C ) or less rapidly ( for t > 15°C ) near the horizon,
and I don't really know the behavior of the function A(h0) in this interval.
-Though slightly less accurate, the following formulae may also be used:

-If t = -30°C    105A = Max ( -15 - 387 x + 82156 x2 + 142877 x3 - 963927 x4 + 1845007 x5 - 1614635 x6 + 545974 x7 ; 0 )
-If t = -10°C    105A = Max (  -5 - 466 x + 49149 x2 + 49994 x3 - 454890 x4 + 891332 x5 - 779644 x6 + 262223 x7 ; 0 )
-If t = +10°C    105A = Max ( -1 - 113 x + 10184 x2 + 7212 x3 - 84702 x4 + 168894 x5 - 147638 x6 + 49394 x7 ; 0 )
-If t = +15°C          A = 0
-If t = +30°C    105A = Min ( +1 + 469 x - 32520 x2 - 6816 x3 + 214150 x4 - 444530 x5 + 390988 x6 - 130572 x7 ; 0 )

Coefficient B:

-If P = 500 mbar          105B =  -27 + 909 x - 42020 x2 + 102902 x3 - 101640 x4 + 16348 x5 + 39269 x6 - 19816 x7
-If P = 700 mbar          105B =  -16 + 506 x - 24962 x2 + 58265 x3 - 49889 x4 - 6869 x5 + 35957 x6 - 15541 x7
-If P = 900 mbar          105B =   -7 + 229 x - 9556 x2 + 23689 x3 - 25749 x4 + 9819 x5 + 3176 x6 - 2541 x7
-If P = 1013.25 mbar        B = 0
-If P = 1100 mbar        105B =   4 - 153 x + 7206 x2 - 18115 x3 + 21595 x4 - 12458 x5 + 2134 x6 + 572 x7

Coefficient C:

105C = [ 473 ( 0.59-Lwl ) + 1570 ( 0.59-Lwl )2 + 2911 ( 0.59-Lwl )3 ] exp ( -0.472 h00.866 )

Coefficient D:

105D =  ( -14.6 f + 2.556 f 2 - 0.12445 f 3 + f 4/214 - f 5/16540 )/( 1 + 1.057 h0 + 0.29 h02 + h03/80 )

Coefficient E:

E = ( -1/260 ) Cos ( 2.Lat ) exp ( -0.467 h00.8215 )

Coefficient F:

F = [ exp ( - alt/18031 ) - 1 ] exp ( -1.106 h00.805 )

-All these formulae may certainly be improved.
-They are empirical and I 've found many of them with my HP-48 and Sune Bredahl's excellent "SOLVESYS" library ( cf  http://www.hpcalc.org )

Data Registers:    R00 = h0                                                           ( Registers R01 thru R06 are to be initialized before executing "REFR" )
•  R01 = t     ( in °C )         ( -30 <= t <= +30 )
•  R02 = P    ( in mbar )     ( 500 <= P <= 1100 )            These limits are not absolute...
•  R03 = f     ( in mbar )      ( 0 <= f <= 30 )
•  R04 = Lwl  ( in µm )       ( 0.4 <= lwl <= 0.7 )                     R08 thru R24: temp
•  R05 = lat   ( in °. ' " )
•  R06 = alt   ( in meters )   ( 0 <= alt <= 1000 )

When the program stops,  R07 = Refraction ( in degrees and decimals )

with    t = temperature ; P = pressure ; f = partial pressure of water vapor
Lwl = Light wave-length ; lat = latitude
alt = observer's altitude ( over sea-level )

Flags: /
Subroutine:  "LAGR"  ( cf "Lagrange Interpolation formula for the HP-41" )

01  LBL "REFR"
02  DEG
03  HR
04  STO 00                                             If you want to take advantage of Laplace's formula,   replace lines 27-28 by   LBL 02
05  22.89592                                          and add the following instructions after line 04:
06  RCL Y
07  7.15359                                            21                 X<>Y         ENTER^        *                  1/X           GTO 02
08  +                                                       X>Y?           TAN           X^2                CHS            +               LBL 01
09  /                                                        GTO 01        1/X             185 E-7          63.064         *               CLX
10  +
11  8.56113
12  X<>Y
13  /
14  +
15  6.24727
16  X<>Y
17  /
18  +
19  3.86653
20  X<>Y
21  /
22  +
23  TAN
24  1/X
25  62.97411
26  /
27  X<0?
28  CLST
29  RCL 02
30  *
31  960.233
32  /
33  RCL 01
34  271.677
35  /
36  1
37  +
38  /
39  1
40  RCL 03
41  18 E4
42  /
43  6579
44  1/X
45  +
46  RCL 03
47  *
48  -
49  *
50  5
51  RCL 04
52  X^2
53  836
54  *
55  /
56  .98282
57  +
58  *
59  STO 07
60  10
61  STO 19
62  CHS
63  STO 17
64  15
65  STO 21
66  ST+ X
67  STO 23
68  CHS
69  STO 15
70  CLX
71  STO 22
72  SIGN
73  RCL 00
74  +
75  1/X
76  STO 14
77  2                                                             If you want to use the second formulae to calculate A, replace lines 77 to 102 by
78  STO 08
79  1411                                                       15                   82156             CHS                CHS
80  CHS                                                        STO 08          STO 10          STO 12            545974
81  STO 09                                                   387                 142877          1845007           XEQ 01
82  100967                                                   CHS                STO 11         STO 13
83  STO 10                                                   STO 09           963927         1614635
84  3583
85  STO 11
86  465432
87  CHS
88  STO 12
89  928890
90  STO 13
91  783471
92  CHS
93  251549
94  XEQ 01
95  2377
96  RCL 00
97  43
98  *
99  CHS
100  E^X
101  *
102  +
103  X<0?
104  CLX
105  STO 16
106  CLX                                                             If you want to use the second formulae to calculate A, replace lines 106 to 132 by
107  STO 08
108  880                                                               5                     49419           454890             779644
109  CHS                                                             STO 08           STO 10         CHS                 CHS
110  STO 09                                                        466                  575               STO 12             262223
111  57082                                                           CHS                +                   891332             XEQ 01
112  STO 10                                                         STO 09           STO 11         STO 13
113  6928
114  CHS
115  STO 11
116  250807
117  CHS
118  STO 12
119  515833
120  STO 13
121  438687
122  CHS
123  141374
124  XEQ 01
125  976
126  RCL 00
127  41
128  *
129  CHS
130  E^X
131  *
132  +
133  X<0?
134  CLX
135  STO 18
136  175                                                             If you want to use the second formulae to calculate A, replace lines 136 to 160 by
137  CHS
138  STO 09                                                        1                    10184             CHS                CHS
139  11332                                                          STO 08          STO 10          STO 12            49394
140  STO 10                                                        113                7212               168894            XEQ 01
141  1318                                                             CHS              STO 11          STO 13
142  CHS                                                             STO 09          84702            147638
143  STO 11
144  54120
145  CHS
146  STO 12
147  112625
148  STO 13
149  96545
150  CHS
151  31284
152  XEQ 01
153  147
154  RCL 00
155  30
156  *
157  CHS
158  E^X
159  *
160  +
161  X<0?
162  CLX
163  STO 20
164  1                                                             If you want to use the second formulae to calculate A, replace lines 164 to 189 by
165  STO 08
166  589                                                          1                       32520                STO 11          STO 13
167  STO 09                                                   CHS                  CHS                  214150           390988
168  34750                                                      STO 08             STO 10             STO 12          130572
169  CHS                                                        469                    6816                 444530           CHS
170  STO 10                                                   STO 09              CHS                 CHS                XEQ 01
171  9753
172  STO 11
173  154745
174  STO 12
175  335229
176  CHS
177  STO 13
178  291742
179  95395
180  CHS
181  XEQ 01
182  284
183  RCL 00
184  37
185  *
186  CHS
187  E^X
188  *
189  -
190  X>0?
191  CLX
192  STO 24
193  RCL 01
194  XEQ 02
195  500
196  STO 15
197  700
198  STO 17
199  90
200  ST* 19
201  67.55
202  ST* 21
203  1100
204  STO 23
205  27
206  STO 08
207  909
208  STO 09
209  42020
210  CHS
211  STO 10
212  102902
213  STO 11
214  101640
215  CHS
216  STO 12
217  16348
218  STO 13
219  39269
220  19816
221  CHS
222  XEQ 01
223  STO 16
224  16
225  STO 08
226  506
227  STO 09
228  24962
229  CHS
230  STO 10
231  58265
232  STO 11
233  49889
234  CHS
235  STO 12
236  6869
237  CHS
238  STO 13
239  35957
240  15541
241  CHS
242  XEQ 01
243  STO 18
244  7
245  STO 08
246  229
247  STO 09
248  9556
249  CHS
250  STO 10
251  23689
252  STO 11
253  25749
254  CHS
255  STO 12
256  9819
257  STO 13
258  3176
259  2541
260  CHS
261  XEQ 01
262  STO 20
263  4
264  CHS
265  STO 08
266  153
267  CHS
268  STO 09
269  7206
270  STO 10
271  18115
272  CHS
273  STO 11
274  21595
275  STO 12
276  12458
277  CHS
278  STO 13
279  2134
280  572
281  XEQ 01
282  STO 24
283  RCL 02
284  XEQ 02
285  RCL 03
286  RCL 03
287  RCL 03
288  16540
289  /
290  214
291  1/X
292  -
293  *
294  .12445
295  +
296  *
297  2.556
298  -
299  *
300  14.6
301  -
302  *
303  RCL 00
304  80
305  /
306  .29
307  +
308  RCL 00
309  *
310  1.057
311  +
312  RCL 00
313  *
314  1
315  +
316  /
317  XEQ 03
318  .59
319  RCL 04
320  -
321  1570
322  RCL Y
323  2911
324  *
325  +
326  *
327  473
328  +
329  *
330  RCL 00
331  .866
332  Y^X
333  .472
334  *
335  E^X
336  /
337  XEQ 03
338  GTO 04
339  LBL 01
340  RCL 14
341  STO T
342  *
343  +
344  *
345  RCL 13
346  +
347  *
348  RCL 12
349  +
350  *
351  RCL 11
352  +
353  *
354  RCL 10
355  +
356  *
357  RCL 09
358  +
359  *
360  RCL 08
361  -
362  RTN
363  LBL 02
364  15.024
365  X<>Y
366  XEQ "LAGR"
367  LBL 03
368   E5
369  ST+ Y
370  /
371  ST* 07
372  RTN
373  LBL 04
374  1
375  RCL 05
376  HR
377  ST+ X
378  COS
379  260
380  /
381  RCL 00
382  .8215
383  Y^X
384  .467
385  *
386  E^X
387  /
388  -
389  ST* 07
390  RCL 06
391  18031
392  /
393  CHS
394  E^X-1
395  RCL 00
396  .805
397  Y^X
398  1.106
399  *
400  E^X
401  /
402  1
403  +
404  ST* 07
405  RCL 00
406  RCL 07
407  ST- Y
408  HMS
409  X<>Y
410  HMS
411  END

( 852 bytes / SIZE 025 )

 STACK INPUTS OUTPUTS Y / R X h0 h

( All angles expressed in ° ' " )   Execution time = 64 seconds.

Example:   With  t = 20°C , P = 1000 mbar , f = 12 mbar , Lwl = 0.5 µm , lat = 30° , alt = 500 m           ( store these 6 numbers into R01 thru R06 )

h0 = 0               XEQ "REFR"  >>>>   h =   -0°30'04"100    X<>Y    R =  0°30'04"100   =  1804"100
h0 = 1°                    R/S           >>>>   h =    0°37'43"380    X<>Y    R =  0°22'16"620   =  1336"620
h0 = 12°34'56"        R/S           >>>>   h =  12°30'52"615    X<>Y    R =  0°04'03"385   =   243"385
h0 = 41°16'24"        R/S           >>>>   h =  41°15'20"772    X<>Y    R =  0°01'03"228   =    63"228

-The accuracy is of the order of 1 or 2 arcseconds near the horizon ( with a greater uncertainty for 0° < h0 < 0°10' ). Interpolation may also decrease the precision.
- errors ~  0"5 for h0 = 5°
- errors ~  0"2 for h0 = 10°
-For h0 > 20° the accuracy is determined by the formula which computes R0 , therefore use Laplace's formula
as explained on the right of the beginning of this listing if you need more accurate results for these h0-values.

-As mentioned above, the accurate results near the horizon are often unrealistic without knowing the detailed structure of low atmosphere.
( cf references [3] & [9] for a detailed analysis on low-altitude refraction )

References:

[1]  Jean Kovalevsky et al. - "Introduction aux Ephemerides Astronomiques" - EDP Sciences - ISBN 2-86883-298-9  ( in French )
[2]  Abalakin 1985 - "Refraction Tables of Pulkovo Observatory" 5th edition - Nauka, Leningrad
[3]  Andrew T. Young - "Sunset Science IV. Low-Altitude Refraction" - 2004, the Astronomical Journal, 127 , 3622
[4]  Lawrence H. Auer & E. Myles Standish - "Astronomical Refraction, Computational method for all zenith angles" 2000 AJ, 119 , 2472
[5]  Krystyna Kurzynska - "Precision in determination of astronomical refraction from aerological data" - 1987, Astron. Nachr. 308, 323
[6]  Krystyna Kurzunska - "Local effects in pure astronomical refraction" - 1988, Astron. Nachr. 309, 57
[7]  Krystyna Kurzynska - "On the accuracy of the Refraction Tables of Pulkovo Observatory, 5th edition" 1988, Astron. Nachr. 309, 213
[8]  Minodora Lipcanu - "A direct method for the calculation of astronomical refraction"
[9]  Andrew T. Young - "Understanding Astronomical Refraction" - 2006, The Observatory, Vol. 126, N° 1191, pp. 82-115