line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "erfa.h" |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
|
|
|
void eraRefco(double phpa, double tc, double rh, double wl, |
4
|
|
|
|
|
|
|
double *refa, double *refb) |
5
|
|
|
|
|
|
|
/* |
6
|
|
|
|
|
|
|
** - - - - - - - - - |
7
|
|
|
|
|
|
|
** e r a R e f c o |
8
|
|
|
|
|
|
|
** - - - - - - - - - |
9
|
|
|
|
|
|
|
** |
10
|
|
|
|
|
|
|
** Determine the constants A and B in the atmospheric refraction model |
11
|
|
|
|
|
|
|
** dZ = A tan Z + B tan^3 Z. |
12
|
|
|
|
|
|
|
** |
13
|
|
|
|
|
|
|
** Z is the "observed" zenith distance (i.e. affected by refraction) |
14
|
|
|
|
|
|
|
** and dZ is what to add to Z to give the "topocentric" (i.e. in vacuo) |
15
|
|
|
|
|
|
|
** zenith distance. |
16
|
|
|
|
|
|
|
** |
17
|
|
|
|
|
|
|
** Given: |
18
|
|
|
|
|
|
|
** phpa double pressure at the observer (hPa = millibar) |
19
|
|
|
|
|
|
|
** tc double ambient temperature at the observer (deg C) |
20
|
|
|
|
|
|
|
** rh double relative humidity at the observer (range 0-1) |
21
|
|
|
|
|
|
|
** wl double wavelength (micrometers) |
22
|
|
|
|
|
|
|
** |
23
|
|
|
|
|
|
|
** Returned: |
24
|
|
|
|
|
|
|
** refa double* tan Z coefficient (radians) |
25
|
|
|
|
|
|
|
** refb double* tan^3 Z coefficient (radians) |
26
|
|
|
|
|
|
|
** |
27
|
|
|
|
|
|
|
** Notes: |
28
|
|
|
|
|
|
|
** |
29
|
|
|
|
|
|
|
** 1) The model balances speed and accuracy to give good results in |
30
|
|
|
|
|
|
|
** applications where performance at low altitudes is not paramount. |
31
|
|
|
|
|
|
|
** Performance is maintained across a range of conditions, and |
32
|
|
|
|
|
|
|
** applies to both optical/IR and radio. |
33
|
|
|
|
|
|
|
** |
34
|
|
|
|
|
|
|
** 2) The model omits the effects of (i) height above sea level (apart |
35
|
|
|
|
|
|
|
** from the reduced pressure itself), (ii) latitude (i.e. the |
36
|
|
|
|
|
|
|
** flattening of the Earth), (iii) variations in tropospheric lapse |
37
|
|
|
|
|
|
|
** rate and (iv) dispersive effects in the radio. |
38
|
|
|
|
|
|
|
** |
39
|
|
|
|
|
|
|
** The model was tested using the following range of conditions: |
40
|
|
|
|
|
|
|
** |
41
|
|
|
|
|
|
|
** lapse rates 0.0055, 0.0065, 0.0075 deg/meter |
42
|
|
|
|
|
|
|
** latitudes 0, 25, 50, 75 degrees |
43
|
|
|
|
|
|
|
** heights 0, 2500, 5000 meters ASL |
44
|
|
|
|
|
|
|
** pressures mean for height -10% to +5% in steps of 5% |
45
|
|
|
|
|
|
|
** temperatures -10 deg to +20 deg with respect to 280 deg at SL |
46
|
|
|
|
|
|
|
** relative humidity 0, 0.5, 1 |
47
|
|
|
|
|
|
|
** wavelengths 0.4, 0.6, ... 2 micron, + radio |
48
|
|
|
|
|
|
|
** zenith distances 15, 45, 75 degrees |
49
|
|
|
|
|
|
|
** |
50
|
|
|
|
|
|
|
** The accuracy with respect to raytracing through a model |
51
|
|
|
|
|
|
|
** atmosphere was as follows: |
52
|
|
|
|
|
|
|
** |
53
|
|
|
|
|
|
|
** worst RMS |
54
|
|
|
|
|
|
|
** |
55
|
|
|
|
|
|
|
** optical/IR 62 mas 8 mas |
56
|
|
|
|
|
|
|
** radio 319 mas 49 mas |
57
|
|
|
|
|
|
|
** |
58
|
|
|
|
|
|
|
** For this particular set of conditions: |
59
|
|
|
|
|
|
|
** |
60
|
|
|
|
|
|
|
** lapse rate 0.0065 K/meter |
61
|
|
|
|
|
|
|
** latitude 50 degrees |
62
|
|
|
|
|
|
|
** sea level |
63
|
|
|
|
|
|
|
** pressure 1005 mb |
64
|
|
|
|
|
|
|
** temperature 280.15 K |
65
|
|
|
|
|
|
|
** humidity 80% |
66
|
|
|
|
|
|
|
** wavelength 5740 Angstroms |
67
|
|
|
|
|
|
|
** |
68
|
|
|
|
|
|
|
** the results were as follows: |
69
|
|
|
|
|
|
|
** |
70
|
|
|
|
|
|
|
** ZD raytrace eraRefco Saastamoinen |
71
|
|
|
|
|
|
|
** |
72
|
|
|
|
|
|
|
** 10 10.27 10.27 10.27 |
73
|
|
|
|
|
|
|
** 20 21.19 21.20 21.19 |
74
|
|
|
|
|
|
|
** 30 33.61 33.61 33.60 |
75
|
|
|
|
|
|
|
** 40 48.82 48.83 48.81 |
76
|
|
|
|
|
|
|
** 45 58.16 58.18 58.16 |
77
|
|
|
|
|
|
|
** 50 69.28 69.30 69.27 |
78
|
|
|
|
|
|
|
** 55 82.97 82.99 82.95 |
79
|
|
|
|
|
|
|
** 60 100.51 100.54 100.50 |
80
|
|
|
|
|
|
|
** 65 124.23 124.26 124.20 |
81
|
|
|
|
|
|
|
** 70 158.63 158.68 158.61 |
82
|
|
|
|
|
|
|
** 72 177.32 177.37 177.31 |
83
|
|
|
|
|
|
|
** 74 200.35 200.38 200.32 |
84
|
|
|
|
|
|
|
** 76 229.45 229.43 229.42 |
85
|
|
|
|
|
|
|
** 78 267.44 267.29 267.41 |
86
|
|
|
|
|
|
|
** 80 319.13 318.55 319.10 |
87
|
|
|
|
|
|
|
** |
88
|
|
|
|
|
|
|
** deg arcsec arcsec arcsec |
89
|
|
|
|
|
|
|
** |
90
|
|
|
|
|
|
|
** The values for Saastamoinen's formula (which includes terms |
91
|
|
|
|
|
|
|
** up to tan^5) are taken from Hohenkerk and Sinclair (1985). |
92
|
|
|
|
|
|
|
** |
93
|
|
|
|
|
|
|
** 3) A wl value in the range 0-100 selects the optical/IR case and is |
94
|
|
|
|
|
|
|
** wavelength in micrometers. Any value outside this range selects |
95
|
|
|
|
|
|
|
** the radio case. |
96
|
|
|
|
|
|
|
** |
97
|
|
|
|
|
|
|
** 4) Outlandish input parameters are silently limited to |
98
|
|
|
|
|
|
|
** mathematically safe values. Zero pressure is permissible, and |
99
|
|
|
|
|
|
|
** causes zeroes to be returned. |
100
|
|
|
|
|
|
|
** |
101
|
|
|
|
|
|
|
** 5) The algorithm draws on several sources, as follows: |
102
|
|
|
|
|
|
|
** |
103
|
|
|
|
|
|
|
** a) The formula for the saturation vapour pressure of water as |
104
|
|
|
|
|
|
|
** a function of temperature and temperature is taken from |
105
|
|
|
|
|
|
|
** Equations (A4.5-A4.7) of Gill (1982). |
106
|
|
|
|
|
|
|
** |
107
|
|
|
|
|
|
|
** b) The formula for the water vapour pressure, given the |
108
|
|
|
|
|
|
|
** saturation pressure and the relative humidity, is from |
109
|
|
|
|
|
|
|
** Crane (1976), Equation (2.5.5). |
110
|
|
|
|
|
|
|
** |
111
|
|
|
|
|
|
|
** c) The refractivity of air is a function of temperature, |
112
|
|
|
|
|
|
|
** total pressure, water-vapour pressure and, in the case |
113
|
|
|
|
|
|
|
** of optical/IR, wavelength. The formulae for the two cases are |
114
|
|
|
|
|
|
|
** developed from Hohenkerk & Sinclair (1985) and Rueger (2002). |
115
|
|
|
|
|
|
|
** |
116
|
|
|
|
|
|
|
** d) The formula for beta, the ratio of the scale height of the |
117
|
|
|
|
|
|
|
** atmosphere to the geocentric distance of the observer, is |
118
|
|
|
|
|
|
|
** an adaption of Equation (9) from Stone (1996). The |
119
|
|
|
|
|
|
|
** adaptations, arrived at empirically, consist of (i) a small |
120
|
|
|
|
|
|
|
** adjustment to the coefficient and (ii) a humidity term for the |
121
|
|
|
|
|
|
|
** radio case only. |
122
|
|
|
|
|
|
|
** |
123
|
|
|
|
|
|
|
** e) The formulae for the refraction constants as a function of |
124
|
|
|
|
|
|
|
** n-1 and beta are from Green (1987), Equation (4.31). |
125
|
|
|
|
|
|
|
** |
126
|
|
|
|
|
|
|
** References: |
127
|
|
|
|
|
|
|
** |
128
|
|
|
|
|
|
|
** Crane, R.K., Meeks, M.L. (ed), "Refraction Effects in the Neutral |
129
|
|
|
|
|
|
|
** Atmosphere", Methods of Experimental Physics: Astrophysics 12B, |
130
|
|
|
|
|
|
|
** Academic Press, 1976. |
131
|
|
|
|
|
|
|
** |
132
|
|
|
|
|
|
|
** Gill, Adrian E., "Atmosphere-Ocean Dynamics", Academic Press, |
133
|
|
|
|
|
|
|
** 1982. |
134
|
|
|
|
|
|
|
** |
135
|
|
|
|
|
|
|
** Green, R.M., "Spherical Astronomy", Cambridge University Press, |
136
|
|
|
|
|
|
|
** 1987. |
137
|
|
|
|
|
|
|
** |
138
|
|
|
|
|
|
|
** Hohenkerk, C.Y., & Sinclair, A.T., NAO Technical Note No. 63, |
139
|
|
|
|
|
|
|
** 1985. |
140
|
|
|
|
|
|
|
** |
141
|
|
|
|
|
|
|
** Rueger, J.M., "Refractive Index Formulae for Electronic Distance |
142
|
|
|
|
|
|
|
** Measurement with Radio and Millimetre Waves", in Unisurv Report |
143
|
|
|
|
|
|
|
** S-68, School of Surveying and Spatial Information Systems, |
144
|
|
|
|
|
|
|
** University of New South Wales, Sydney, Australia, 2002. |
145
|
|
|
|
|
|
|
** |
146
|
|
|
|
|
|
|
** Stone, Ronald C., P.A.S.P. 108, 1051-1058, 1996. |
147
|
|
|
|
|
|
|
** |
148
|
|
|
|
|
|
|
** Copyright (C) 2013-2019, NumFOCUS Foundation. |
149
|
|
|
|
|
|
|
** Derived, with permission, from the SOFA library. See notes at end of file. |
150
|
|
|
|
|
|
|
*/ |
151
|
|
|
|
|
|
|
{ |
152
|
|
|
|
|
|
|
int optic; |
153
|
|
|
|
|
|
|
double p, t, r, w, ps, pw, tk, wlsq, gamma, beta; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
/* Decide whether optical/IR or radio case: switch at 100 microns. */ |
157
|
|
|
|
|
|
|
optic = ( wl <= 100.0 ); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
/* Restrict parameters to safe values. */ |
160
|
3
|
50
|
|
|
|
|
t = ERFA_GMAX ( tc, -150.0 ); |
161
|
3
|
50
|
|
|
|
|
t = ERFA_GMIN ( t, 200.0 ); |
162
|
3
|
50
|
|
|
|
|
p = ERFA_GMAX ( phpa, 0.0 ); |
163
|
3
|
50
|
|
|
|
|
p = ERFA_GMIN ( p, 10000.0 ); |
164
|
3
|
50
|
|
|
|
|
r = ERFA_GMAX ( rh, 0.0 ); |
165
|
3
|
50
|
|
|
|
|
r = ERFA_GMIN ( r, 1.0 ); |
166
|
3
|
50
|
|
|
|
|
w = ERFA_GMAX ( wl, 0.1 ); |
167
|
3
|
50
|
|
|
|
|
w = ERFA_GMIN ( w, 1e6 ); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
/* Water vapour pressure at the observer. */ |
170
|
3
|
50
|
|
|
|
|
if ( p > 0.0 ) { |
171
|
9
|
|
|
|
|
|
ps = pow ( 10.0, ( 0.7859 + 0.03477*t ) / |
172
|
3
|
|
|
|
|
|
( 1.0 + 0.00412*t ) ) * |
173
|
3
|
|
|
|
|
|
( 1.0 + p * ( 4.5e-6 + 6e-10*t*t ) ); |
174
|
3
|
|
|
|
|
|
pw = r * ps / ( 1.0 - (1.0-r)*ps/p ); |
175
|
|
|
|
|
|
|
} else { |
176
|
|
|
|
|
|
|
pw = 0.0; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
/* Refractive index minus 1 at the observer. */ |
180
|
3
|
|
|
|
|
|
tk = t + 273.15; |
181
|
3
|
100
|
|
|
|
|
if ( optic ) { |
182
|
2
|
|
|
|
|
|
wlsq = w * w; |
183
|
2
|
|
|
|
|
|
gamma = ( ( 77.53484e-6 + |
184
|
4
|
|
|
|
|
|
( 4.39108e-7 + 3.666e-9/wlsq ) / wlsq ) * p |
185
|
2
|
|
|
|
|
|
- 11.2684e-6*pw ) / tk; |
186
|
|
|
|
|
|
|
} else { |
187
|
1
|
|
|
|
|
|
gamma = ( 77.6890e-6*p - ( 6.3938e-6 - 0.375463/tk ) * pw ) / tk; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
/* Formula for beta from Stone, with empirical adjustments. */ |
191
|
3
|
|
|
|
|
|
beta = 4.4474e-6 * tk; |
192
|
3
|
100
|
|
|
|
|
if ( ! optic ) beta -= 0.0074 * pw * beta; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
/* Refraction constants from Green. */ |
195
|
3
|
|
|
|
|
|
*refa = gamma * ( 1.0 - beta ); |
196
|
3
|
|
|
|
|
|
*refb = - gamma * ( beta - gamma / 2.0 ); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
/* Finished. */ |
199
|
|
|
|
|
|
|
|
200
|
3
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
202
|
|
|
|
|
|
|
** |
203
|
|
|
|
|
|
|
** |
204
|
|
|
|
|
|
|
** Copyright (C) 2013-2019, NumFOCUS Foundation. |
205
|
|
|
|
|
|
|
** All rights reserved. |
206
|
|
|
|
|
|
|
** |
207
|
|
|
|
|
|
|
** This library is derived, with permission, from the International |
208
|
|
|
|
|
|
|
** Astronomical Union's "Standards of Fundamental Astronomy" library, |
209
|
|
|
|
|
|
|
** available from http://www.iausofa.org. |
210
|
|
|
|
|
|
|
** |
211
|
|
|
|
|
|
|
** The ERFA version is intended to retain identical functionality to |
212
|
|
|
|
|
|
|
** the SOFA library, but made distinct through different function and |
213
|
|
|
|
|
|
|
** file names, as set out in the SOFA license conditions. The SOFA |
214
|
|
|
|
|
|
|
** original has a role as a reference standard for the IAU and IERS, |
215
|
|
|
|
|
|
|
** and consequently redistribution is permitted only in its unaltered |
216
|
|
|
|
|
|
|
** state. The ERFA version is not subject to this restriction and |
217
|
|
|
|
|
|
|
** therefore can be included in distributions which do not support the |
218
|
|
|
|
|
|
|
** concept of "read only" software. |
219
|
|
|
|
|
|
|
** |
220
|
|
|
|
|
|
|
** Although the intent is to replicate the SOFA API (other than |
221
|
|
|
|
|
|
|
** replacement of prefix names) and results (with the exception of |
222
|
|
|
|
|
|
|
** bugs; any that are discovered will be fixed), SOFA is not |
223
|
|
|
|
|
|
|
** responsible for any errors found in this version of the library. |
224
|
|
|
|
|
|
|
** |
225
|
|
|
|
|
|
|
** If you wish to acknowledge the SOFA heritage, please acknowledge |
226
|
|
|
|
|
|
|
** that you are using a library derived from SOFA, rather than SOFA |
227
|
|
|
|
|
|
|
** itself. |
228
|
|
|
|
|
|
|
** |
229
|
|
|
|
|
|
|
** |
230
|
|
|
|
|
|
|
** TERMS AND CONDITIONS |
231
|
|
|
|
|
|
|
** |
232
|
|
|
|
|
|
|
** Redistribution and use in source and binary forms, with or without |
233
|
|
|
|
|
|
|
** modification, are permitted provided that the following conditions |
234
|
|
|
|
|
|
|
** are met: |
235
|
|
|
|
|
|
|
** |
236
|
|
|
|
|
|
|
** 1 Redistributions of source code must retain the above copyright |
237
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer. |
238
|
|
|
|
|
|
|
** |
239
|
|
|
|
|
|
|
** 2 Redistributions in binary form must reproduce the above copyright |
240
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer in |
241
|
|
|
|
|
|
|
** the documentation and/or other materials provided with the |
242
|
|
|
|
|
|
|
** distribution. |
243
|
|
|
|
|
|
|
** |
244
|
|
|
|
|
|
|
** 3 Neither the name of the Standards Of Fundamental Astronomy Board, |
245
|
|
|
|
|
|
|
** the International Astronomical Union nor the names of its |
246
|
|
|
|
|
|
|
** contributors may be used to endorse or promote products derived |
247
|
|
|
|
|
|
|
** from this software without specific prior written permission. |
248
|
|
|
|
|
|
|
** |
249
|
|
|
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
250
|
|
|
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
251
|
|
|
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
252
|
|
|
|
|
|
|
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
253
|
|
|
|
|
|
|
** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
254
|
|
|
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
255
|
|
|
|
|
|
|
** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
256
|
|
|
|
|
|
|
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
257
|
|
|
|
|
|
|
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
258
|
|
|
|
|
|
|
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
259
|
|
|
|
|
|
|
** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
260
|
|
|
|
|
|
|
** POSSIBILITY OF SUCH DAMAGE. |
261
|
|
|
|
|
|
|
** |
262
|
|
|
|
|
|
|
*/ |