21
21
22
22
23
23
static double novas_refraction (enum novas_refraction_model model , const on_surface * loc , enum novas_refraction_type type , double el ) {
24
- if (!loc )
25
- return novas_error (-1 , EINVAL , "novas_refraction" , "NULL on surface observer location" );
24
+ if (!loc ) {
25
+ novas_error (-1 , EINVAL , "novas_refraction" , "NULL on surface observer location" );
26
+ return NAN ;
27
+ }
26
28
27
29
if (type == NOVAS_REFRACT_OBSERVED )
28
- return refract (loc , NOVAS_WEATHER_AT_LOCATION , 90.0 - el );
30
+ return refract (loc , model , 90.0 - el );
31
+
32
+ if (type == NOVAS_REFRACT_ASTROMETRIC )
33
+ return refract_astro (loc , model , 90.0 - el );
29
34
30
- return refract_astro ( loc , NOVAS_WEATHER_AT_LOCATION , 90.0 - el ) ;
35
+ return NAN ;
31
36
}
32
37
33
38
/**
@@ -120,6 +125,8 @@ double novas_optical_refraction(double jd_tt, const on_surface *loc, enum novas_
120
125
* data is fully defined, and that the humidity was explicitly set after calling
121
126
* `make_on_surface()`.
122
127
*
128
+ * Adapted from FORTAN code provided by Berman & Rockwell 1976.
129
+ *
123
130
* REFERENCES:
124
131
* <ol>
125
132
* <li>Berman, Allan L., and Rockwell, Stephen T. (1976), NASA JPL Technical Report 32-1601</li>
@@ -140,7 +147,6 @@ double novas_optical_refraction(double jd_tt, const on_surface *loc, enum novas_
140
147
double novas_radio_refraction (double jd_tt , const on_surface * loc , enum novas_refraction_type type , double el ) {
141
148
// Various coefficients...
142
149
static const double E [] = { 0.0 , 46.625 , 45.375 , 4.1572 , 1.4468 , 0.25391 , 2.2716 , -1.3465 , -4.3877 , 3.1484 , 4.520 , -1.8982 , 0.8900 };
143
- //static const double EULER = 2.71828182845905; // Euler's number
144
150
145
151
double E0 , TK ;
146
152
double y = 1.0 , z ;
@@ -149,23 +155,27 @@ double novas_radio_refraction(double jd_tt, const on_surface *loc, enum novas_re
149
155
double refraction ;
150
156
int j ;
151
157
152
- // The Bermann
153
- if ( type == NOVAS_REFRACT_OBSERVED ) {
154
- return novas_inv_refract ( novas_radio_refraction , jd_tt , loc , NOVAS_REFRACT_ASTROMETRIC , el ) ;
158
+ if (! loc ) {
159
+ novas_error ( -1 , EINVAL , "novas_radio_refraction" , "NULL on surface observer location" );
160
+ return NAN ;
155
161
}
156
162
157
- // TODO check which type of argument it takes.
163
+ if (type != NOVAS_REFRACT_OBSERVED && type != NOVAS_REFRACT_ASTROMETRIC ) {
164
+ novas_error (-1 , EINVAL , "novas_radio_refraction" , "invalid refraction type: %d" , type );
165
+ return NAN ;
166
+ }
167
+
168
+ // The Bermann
169
+ if (type == NOVAS_REFRACT_OBSERVED )
170
+ return novas_inv_refract (novas_radio_refraction , jd_tt , loc , NOVAS_REFRACT_ASTROMETRIC , el );
158
171
159
172
// Zenith angle in degrees
160
173
z = (90.0 - el ) / DEGREE ;
161
174
162
175
// Temperature in Kelvin
163
176
TK = loc -> temperature + 273.16 ;
164
-
165
177
fptem = (loc -> pressure / 1000. ) * (273.16 / TK );
166
-
167
178
E0 = (z - E [1 ]) / E [2 ];
168
-
169
179
poly = E [11 ];
170
180
171
181
for (j = 1 ; j <= 8 ; j ++ )
@@ -174,9 +184,7 @@ double novas_radio_refraction(double jd_tt, const on_surface *loc, enum novas_re
174
184
if (poly <= -80. ) poly = 0. ;
175
185
176
186
poly = exp (poly ) - E [12 ];
177
-
178
187
refraction = poly * fptem ;
179
-
180
188
y = exp (((TK * 17.149 ) - 4684.1 ) / (TK - 38.45 ));
181
189
182
190
return refraction * 1.0 + (y * loc -> humidity * 71. ) / (TK * loc -> pressure * 0.760 );
0 commit comments