Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 075e37e

Browse files
committed
Fix too large troposphere corrections when pos is deep inside the Earth
1 parent e611931 commit 075e37e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/troposphere.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static double calc_param(double lat, double doy, const double *avg_lut, const do
276276
* -# UNB Neutral Atmosphere Models: Development and Performance. R Leandro,
277277
* M Santos, and R B Langley
278278
*
279-
* \param doy Day of the year at which to calculate tropospheric delay [day]
279+
* \param t_gps GPS time at which to calculate tropospheric delay [gps_time]
280280
* \param lat Latitude of the receiver [rad]
281281
* \param h Orthometric height of the receiver (height above the geoid) [m]
282282
* \param el Elevation of the satellite [rad]
@@ -289,6 +289,11 @@ double calc_troposphere(const gps_time_t *t_gps, double lat, double h,
289289
lat *= R2D;
290290
el *= R2D;
291291

292+
/* truncate negative altitudes */
293+
if (h < 0) {
294+
h = 0.0;
295+
}
296+
292297
/* compute day of year from gps time */
293298
double doy = (double) gps2doy(t_gps);
294299

tests/check_troposphere.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ START_TEST(test_calc_troposphere)
5959
fail_unless(fabs(d_tropo - d_true) < d_tol,
6060
"Distance didn't match hardcoded correct values %0.5f. Saw: %.5f\n",
6161
d_true, d_tropo);
62+
63+
/* elevation sanity tests */
64+
double const max_tropo_correction = 30.0;
65+
h = -5000;
66+
d_tropo = calc_troposphere(&t, lat, h, el);
67+
68+
fail_unless(fabs(d_tropo) < max_tropo_correction,
69+
"Sanity test fail at elevation %0.5f. : Correction was %.5f\n",
70+
h, d_tropo);
71+
72+
h = 12000;
73+
d_tropo = calc_troposphere(&t, lat, h, el);
74+
75+
fail_unless(fabs(d_tropo) < max_tropo_correction,
76+
"Sanity test fail at elevation %0.5f. : Correction was %.5f\n",
77+
h, d_tropo);
6278
}
6379
END_TEST
6480

0 commit comments

Comments
 (0)