Skip to content

Commit 349a567

Browse files
committed
Merge pull request #5 from nsirola/i245_tropo_rebase
UNB3M tropospheric model and iono/tropo Python bindings
2 parents 2549cac + 44ae011 commit 349a567

File tree

18 files changed

+590
-62
lines changed

18 files changed

+590
-62
lines changed

include/libswiftnav/time.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,6 @@ static inline bool is_leap_year(s32 year)
102102

103103
gps_time_t glo_time2gps_time(u16 nt, u8 n4, u8 h, u8 m, u8 s);
104104

105+
u16 gps2doy(const gps_time_t *t);
106+
105107
#endif /* LIBSWIFTNAV_TIME_H */

include/libswiftnav/tropo.h renamed to include/libswiftnav/troposphere.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1111
*/
1212

13-
#ifndef LIBSWIFTNAV_TROPO_H
14-
#define LIBSWIFTNAV_TROPO_H
13+
#ifndef LIBSWIFTNAV_TROPOSPHERE_H
14+
#define LIBSWIFTNAV_TROPOSPHERE_H
1515

16-
double tropo_correction(double elevation);
16+
#include <libswiftnav/time.h>
1717

18-
#endif /* LIBSWIFTNAV_TROPO_H */
18+
double calc_troposphere(const gps_time_t *t_gps, double lat, double h,
19+
double el);
1920

21+
#endif /* LIBSWIFTNAV_TROPOSPHERE_H */

python/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def make_extension(ext_name):
6363
'swiftnav.memory_pool',
6464
'swiftnav.prns',
6565
'swiftnav.sats_management',
66+
'swiftnav.iono',
6667
'swiftnav.tropo',
6768
'swiftnav.set',
6869
'swiftnav.bit_sync',

python/swiftnav/iono.pxd

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2016 Swift Navigation Inc.
2+
#
3+
# This source is subject to the license found in the file 'LICENSE' which must
4+
# be be distributed together with this source. All other rights reserved.
5+
#
6+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
7+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
8+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
9+
10+
from common cimport *
11+
from time cimport gps_time_t
12+
13+
cdef extern from "libswiftnav/ionosphere.h":
14+
double calc_ionosphere(const gps_time_t *t_gps,
15+
double lat_u, double lon_u,
16+
double a, double e,
17+
const ionosphere_t *i);
18+
19+
ctypedef struct ionosphere_t:
20+
double a0, a1, a2, a3;
21+
double b0, b1, b2, b3;
22+

python/swiftnav/iono.pyx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (C) 2016 Swift Navigation Inc.
2+
#
3+
# This source is subject to the license found in the file 'LICENSE' which must
4+
# be be distributed together with this source. All other rights reserved.
5+
#
6+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
7+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
8+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
9+
10+
from time cimport *
11+
from time import GpsTime
12+
13+
def calc_iono_correction(GpsTime t, lat, lon, azimuth, elevation, alpha, beta):
14+
"""
15+
Wraps function :libswiftnav:`calc_ionosphere`.
16+
17+
Parameters
18+
----------
19+
t : GpsTime
20+
GPS time for iono computation (only time of day used)
21+
lat, lon : float
22+
User latitude and longitude (rad)
23+
elevation, azimuth : float
24+
Satellite az-el (rad)
25+
alpha, beta : (float, float, float, float)
26+
ionospheric parameters
27+
28+
Returns
29+
-------
30+
out : float
31+
Ionospheric delay in meters
32+
33+
"""
34+
assert len(alpha) == 4 and len(beta) == 4, "Ionospheric parameter vectors alpha and beta must have 4 elements each."
35+
36+
cdef ionosphere_t i
37+
38+
i.a0, i.a1, i.a2, i.a3 = alpha[0], alpha[1], alpha[2], alpha[3]
39+
i.b0, i.b1, i.b2, i.b3 = beta[0], beta[1], beta[2], beta[3]
40+
return calc_ionosphere(&t._thisptr,
41+
lat, lon,
42+
azimuth, elevation,
43+
&i);

python/swiftnav/tropo.pxd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
99

1010
from common cimport *
11+
from time cimport gps_time_t
1112

12-
cdef extern from "libswiftnav/tropo.h":
13-
double tropo_correction(double elevation)
13+
cdef extern from "libswiftnav/troposphere.h":
14+
double calc_troposphere(const gps_time_t *t, double lat, double h, double el)

python/swiftnav/tropo.pyx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,30 @@
66
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
77
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
88
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
9+
10+
from time cimport *
11+
from time import GpsTime
12+
13+
def calc_tropo_correction(GpsTime t, lat, h, el):
14+
"""
15+
Wraps function :libswiftnav:`calc_troposphere`.
16+
17+
Parameters
18+
----------
19+
t : GpsTime
20+
Time at which to calculate tropospheric delay (only doy matters)
21+
lat : float
22+
Latitude of the receiver [rad]
23+
h : float
24+
Orthometric height of the receiver [m]
25+
el : float
26+
Elevation of the satellite [rad]
27+
28+
Returns
29+
-------
30+
out : float
31+
Tropospheric delay in meters
32+
33+
"""
34+
35+
return calc_troposphere(&t._thisptr, lat, h, el)

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(libswiftnav_SRCS
2020
ephemeris.c
2121
nav_msg.c
2222
pvt.c
23-
tropo.c
23+
troposphere.c
2424
track.c
2525
correlate.c
2626
coord_system.c

src/ionosphere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <libswiftnav/ionosphere.h>
1919

2020
/** \defgroup ionosphere Ionospheric models
21-
* Implemenations of ionoshperic delay correction models.
21+
* Implemenations of ionospheric delay correction models.
2222
* \{ */
2323

2424
/** Calculate ionospheric delay using Klobuchar model.
@@ -33,7 +33,7 @@
3333
* \param e Elevation of the satellite [rad]
3434
* \param i Ionosphere parameters struct from GPS NAV data
3535
*
36-
* \return Ionospheric delay distance for GPS L1 frequency [m]
36+
* \return Ionospheric delay distance for GPS L1 frequency [m]
3737
*/
3838
double calc_ionosphere(const gps_time_t *t_gps,
3939
double lat_u, double lon_u,

src/time.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <assert.h>
1414
#include <math.h>
1515
#include <stdio.h>
16+
#include <time.h>
1617

1718
#include <libswiftnav/time.h>
1819
#include <libswiftnav/constants.h>
@@ -188,4 +189,16 @@ gps_time_t glo_time2gps_time(u16 nt, u8 n4, u8 h, u8 m, u8 s)
188189
return gps_t;
189190
}
190191

192+
/** GPS time to day of year.
193+
*
194+
* \param t GPS time
195+
* \return The day of year (days since Jan 1st)
196+
*/
197+
u16 gps2doy(const gps_time_t *t)
198+
{
199+
time_t unixtime = gps2time(t);
200+
struct tm* ptm = ptm = gmtime(&unixtime);
201+
return ptm->tm_yday;
202+
}
203+
191204
/** \} */

0 commit comments

Comments
 (0)