Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 137 additions and 43 deletions.
  1. +92 −2 swiftnav/almanac.pyx
  2. +17 −13 swiftnav/track.pyx
  3. +28 −28 swiftnav/track_c.pxd
View
94 swiftnav/almanac.pyx
@@ -14,6 +14,40 @@ cimport numpy as np
cimport almanac_c
cdef class Almanac:
+ """
+ Wraps the :libswiftnav:`almanac_t` structure and associated functions for
+ performing calculations with almanacs.
+
+ Parameters
+ ----------
+ ecc : float
+ Eccentricity in radians.
+ toa : float
+ Time of Applicability in seconds since Sunday.
+ inc : float
+ Inclination in radians.
+ rora : float
+ Rate of Right Ascension in radians/sec.
+ a : float
+ Semi-major axis in meters.
+ raaw : float
+ Right Ascension at Week in radians.
+ argp : float
+ Argument of Perigee in radians.
+ ma : float
+ Mean Anomaly at Time of Applicability in radians.
+ af0 : float
+ 0-order clock correction in seconds.
+ af1 : float
+ 1-order clock correction in seconds/second.
+ week : int
+ GPS week number, modulo 1024.
+ prn : int
+ PRN number of the satellite.
+ healthy : bool
+ Satellite health status.
+
+ """
cdef almanac_c.almanac_t almanac
def __init__(self, ecc, toa, inc, rora, a, raaw,
@@ -33,6 +67,24 @@ cdef class Almanac:
self.healthy = healthy
def calc_state(self, t, week=None):
+ """
+ Wraps the function :libswiftnav:`calc_sat_state_almanac`.
+
+ Parameters
+ ----------
+ t : float
+ The GPS time at which to calculate the azimuth and elevation.
+ week : int, optional
+ The GPS week number modulo 1024. If `None` then it is assumed that `t` is
+ within one half week of the almanac time of applicability.
+
+ Returns
+ -------
+ out : (:class:`numpy.ndarray`, :class:`numpy.ndarray`)
+ The tuple (position, velocity) in meters and meters/sec in the ECEF
+ coordinate system.
+
+ """
cdef np.ndarray[np.double_t, ndim=1, mode="c"] pos = \
np.empty(3, dtype=np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vel = \
@@ -46,6 +98,25 @@ cdef class Almanac:
return (pos, vel)
def calc_az_el(self, t, ref, week=None):
+ """
+ Wraps the function :libswiftnav:`calc_sat_az_el_almanac`.
+
+ Parameters
+ ----------
+ t : float
+ The GPS time at which to calculate the azimuth and elevation.
+ ref : (float, float, float)
+ The tuple of coordinates of the reference position, `(x, y, z)`
+ week : int, optional
+ The GPS week number modulo 1024. If `None` then it is assumed that `t` is
+ within one half week of the almanac time of applicability.
+
+ Returns
+ -------
+ out : (float, float)
+ The tuple (azimuth, elevation) in radians.
+
+ """
if len(ref) != 3:
raise ValueError("ECEF coordinates must have dimension 3.")
@@ -63,6 +134,25 @@ cdef class Almanac:
return (az, el)
def calc_doppler(self, t, ref, week=None):
+ """
+ Wraps the function :libswiftnav:`calc_sat_doppler_almanac`.
+
+ Parameters
+ ----------
+ t : float
+ The GPS time at which to calculate the Doppler shift.
+ ref : (float, float, float)
+ The tuple of coordinates of the reference position, `(x, y, z)`
+ week : int, optional
+ The GPS week number modulo 1024. If `None` then it is assumed that `t` is
+ within one half week of the almanac time of applicability.
+
+ Returns
+ -------
+ out : float
+ The Doppler shift in Hz.
+
+ """
if len(ref) != 3:
raise ValueError("ECEF coordinates must have dimension 3.")
@@ -78,8 +168,8 @@ cdef class Almanac:
&ref_[0])
def __repr__(self):
- return "<Almanac PRN %02d, Week %d, ToA %.1f>" % (self.prn, self.week,
- self.toa)
+ return "<Almanac PRN %02d, Week %d, ToA %.1f>" % \
+ (self.prn, self.week, self.toa)
property ecc:
def __get__(self):
View
30 swiftnav/track.pyx
@@ -82,7 +82,7 @@ def calc_navigation_measurement(double t, chan_meas, es):
return nav_meas
-def calc_loop_gains(double bw, double zeta, double k, double loop_freq):
+def calc_loop_gains(float bw, float zeta, float k, float loop_freq):
"""
Wraps function :libswiftnav:`calc_loop_gains`.
@@ -103,8 +103,8 @@ def calc_loop_gains(double bw, double zeta, double k, double loop_freq):
The tuple `(pgain, igain)`.
"""
- cdef double pgain
- cdef double igain
+ cdef float pgain
+ cdef float igain
track_c.calc_loop_gains(bw, zeta, k, loop_freq, &pgain, &igain)
return (pgain, igain)
@@ -226,9 +226,9 @@ cdef class SimpleTrackingLoop:
"""
cdef track_c.simple_tl_state_t s
- cdef double loop_freq
- cdef double code_bw, code_zeta, code_k
- cdef double carr_bw, carr_zeta, carr_k
+ cdef float loop_freq
+ cdef float code_bw, code_zeta, code_k
+ cdef float carr_bw, carr_zeta, carr_k
def __cinit__(self, code_params, carr_params, loop_freq):
self.loop_freq = loop_freq
@@ -316,20 +316,24 @@ cdef class CompTrackingLoop:
The frequency with which loop updates are performed.
tau : float
The complimentary filter cross-over frequency.
+ cpc : float
+ The number of carrier cycles per complete code, or equivalently the ratio
+ of the carrier frequency to the nominal code frequency.
sched : int, optional
The gain scheduling count.
"""
cdef track_c.comp_tl_state_t s
- cdef double loop_freq, tau
- cdef double code_bw, code_zeta, code_k
- cdef double carr_bw, carr_zeta, carr_k
+ cdef float loop_freq, cpc, tau
+ cdef float code_bw, code_zeta, code_k
+ cdef float carr_bw, carr_zeta, carr_k
cdef u32 sched
- def __cinit__(self, code_params, carr_params, loop_freq, tau, sched=0):
+ def __cinit__(self, code_params, carr_params, loop_freq, tau, cpc, sched=0):
self.loop_freq = loop_freq
self.tau = tau
+ self.cpc = cpc
self.sched = sched
self.code_bw, self.code_zeta, self.code_k = code_params
self.carr_bw, self.carr_zeta, self.carr_k = carr_params
@@ -341,9 +345,9 @@ cdef class CompTrackingLoop:
Parameters
----------
code_freq : float
- The code phase rate (i.e. frequency).
+ The code phase rate (i.e. frequency) difference from nominal.
carr_freq : float
- The carrier frequency.
+ The carrier frequency difference from nominal, i.e. Doppler shift.
"""
track_c.comp_tl_init(&self.s, self.loop_freq,
@@ -351,7 +355,7 @@ cdef class CompTrackingLoop:
self.code_zeta, self.code_k,
carr_freq, self.carr_bw,
self.carr_zeta, self.carr_k,
- self.tau, self.sched)
+ self.tau, self.cpc, self.sched)
def update(self, complex e, complex p, complex l):
"""
View
56 swiftnav/track_c.pxd
@@ -29,52 +29,52 @@ cdef extern from "libswiftnav/track.h":
double sat_vel[3]
ctypedef struct simple_lf_state_t:
- double y
+ float y
ctypedef struct simple_tl_state_t:
- double code_freq
- double carr_freq
+ float code_freq
+ float carr_freq
ctypedef struct comp_tl_state_t:
- double code_freq
- double carr_freq
+ float code_freq
+ float carr_freq
ctypedef struct cn0_est_state_t:
pass
ctypedef struct correlation_t:
- double I
- double Q
+ float I
+ float Q
void calc_navigation_measurement_(u8 n_channels, channel_measurement_t* meas[], navigation_measurement_t* nav_meas[], double nav_time, ephemeris_t* ephemerides[])
- void calc_loop_gains(double bw, double zeta, double k, double loop_freq,
- double *pgain, double *igain)
- double costas_discriminator(double I, double Q)
- double dll_discriminator(correlation_t cs[3])
+ void calc_loop_gains(float bw, float zeta, float k, float loop_freq,
+ float *pgain, float *igain)
+ float costas_discriminator(float I, float Q)
+ float dll_discriminator(correlation_t cs[3])
- void simple_lf_init(simple_lf_state_t *s, double y0,
- double pgain, double igain)
- double simple_lf_update(simple_lf_state_t *s, double error)
+ void simple_lf_init(simple_lf_state_t *s, float y0,
+ float pgain, float igain)
+ float simple_lf_update(simple_lf_state_t *s, float error)
- void simple_tl_init(simple_tl_state_t *s, double loop_freq,
- double code_freq, double code_bw,
- double code_zeta, double code_k,
- double carr_freq, double carr_bw,
- double carr_zeta, double carr_k)
+ void simple_tl_init(simple_tl_state_t *s, float loop_freq,
+ float code_freq, float code_bw,
+ float code_zeta, float code_k,
+ float carr_freq, float carr_bw,
+ float carr_zeta, float carr_k)
void simple_tl_update(simple_tl_state_t *s, correlation_t cs[3])
- void comp_tl_init(comp_tl_state_t *s, double loop_freq,
- double code_freq, double code_bw,
- double code_zeta, double code_k,
- double carr_freq, double carr_bw,
- double carr_zeta, double carr_k,
- double tau, u32 sched)
+ void comp_tl_init(comp_tl_state_t *s, float loop_freq,
+ float code_freq, float code_bw,
+ float code_zeta, float code_k,
+ float carr_freq, float carr_bw,
+ float carr_zeta, float carr_k,
+ float tau, float cpc, u32 sched)
void comp_tl_update(comp_tl_state_t *s, correlation_t cs[3])
- void cn0_est_init(cn0_est_state_t* s, double bw, double cn0_0,
- double cutoff_freq, double loop_freq)
- double cn0_est(cn0_est_state_t* s, double I)
+ void cn0_est_init(cn0_est_state_t* s, float bw, float cn0_0,
+ float cutoff_freq, float loop_freq)
+ float cn0_est(cn0_est_state_t* s, float I)

No commit comments for this range

Something went wrong with that request. Please try again.