Skip to content

Commit 21f63c0

Browse files
committed
Cleaned up some files
1 parent 0db8136 commit 21f63c0

4 files changed

Lines changed: 99 additions & 382 deletions

File tree

gnss_lib_py/parsers/rinex_nav.py

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def preprocess(self, rinex_paths, satellites):
135135

136136
data = pd.DataFrame()
137137
self.iono_params = {}
138-
#TODO: Convert this to a dictionary
139138
for rinex_path in rinex_paths:
140139
new_data, rinex_header = self._get_ephemeris_dataframe(rinex_path,
141140
constellations)
@@ -242,7 +241,6 @@ def _get_ephemeris_dataframe(self, rinex_path, constellations=None):
242241
data['t_oc'] = 1e-9 * data['t_oc'] - consts.WEEKSEC * np.floor(1e-9 * data['t_oc'] / consts.WEEKSEC)
243242
data['time'] = data['time'].dt.tz_localize('UTC')
244243
# Rename Keplerian orbital parameters to match a GLP standard
245-
# TODO: Change these to a standard nomenclature
246244
data.rename(columns={'M0': 'M_0', 'Eccentricity': 'e', 'Toe': 't_oe', 'DeltaN': 'deltaN', 'Cuc': 'C_uc', 'Cus': 'C_us',
247245
'Cic': 'C_ic', 'Crc': 'C_rc', 'Cis': 'C_is', 'Crs': 'C_rs', 'Io': 'i_0', 'Omega0': 'Omega_0'}, inplace=True)
248246
data.rename(columns={'X': 'sv_x_m', 'dX': 'sv_dx_mps', 'dX2': 'sv_dx2_mps2',
@@ -362,211 +360,6 @@ def load_leapseconds(self, rinex_header):
362360
leap_seconds = np.nan
363361
return leap_seconds
364362

365-
# def rinex_to_sv_states(gps_millis, rinex_nav):
366-
# # keplerian_rinex =
367-
# # num_int_rinex =
368-
# # keplerian_sv_states =
369-
# # num_int_sv_states =
370-
# # sv_states = keplerian_sv_states.concat(num_int_sv_states)
371-
# # sv_states.sort('gps_millis', inplace=True)
372-
# # rotate the states
373-
# # return sv_states
374-
# pass
375-
#
376-
# def orbit_params_to_sv_states(gps_millis, ephem_orbit_params):
377-
# """Compute position and velocities for all satellites in ephemeris file
378-
# given time of clock.
379-
#
380-
# `ephem` contains broadcast ephemeris parameters (similar in form to GPS
381-
# broadcast parameters).
382-
#
383-
# Must contain the following rows (description in [1]_):
384-
# * :code:`gnss_id`
385-
# * :code:`sv_id`
386-
# * :code:`gps_week`
387-
# * :code:`t_oe`
388-
# * :code:`e`
389-
# * :code:`omega`
390-
# * :code:`Omega_0`
391-
# * :code:`OmegaDot`
392-
# * :code:`sqrtA`
393-
# * :code:`deltaN`
394-
# * :code:`IDOT`
395-
# * :code:`i_0`
396-
# * :code:`C_is`
397-
# * :code:`C_ic`
398-
# * :code:`C_rs`
399-
# * :code:`C_rc`
400-
# * :code:`C_uc`
401-
# * :code:`C_us`
402-
#
403-
# Parameters
404-
# ----------
405-
# gps_millis : int
406-
# Time at which measurements are needed, measured in milliseconds
407-
# since start of GPS epoch [ms].
408-
# ephem : gnss_lib_py.parsers.navdata.NavData
409-
# NavData instance containing ephemeris parameters of satellites
410-
# for which states are required.
411-
#
412-
# Returns
413-
# -------
414-
# sv_posvel : gnss_lib_py.parsers.navdata.NavData
415-
# NavData containing satellite positions, velocities, corresponding
416-
# time with GNSS ID and SV number.
417-
#
418-
# Notes
419-
# -----
420-
# Based on code written by J. Makela.
421-
# AE 456, Global Navigation Sat Systems, University of Illinois
422-
# Urbana-Champaign. Fall 2017
423-
#
424-
# More details on the algorithm used to compute satellite positions
425-
# from broadcast navigation message can be found in [1]_.
426-
#
427-
# Satellite velocity calculations based on algorithms introduced in [2]_.
428-
#
429-
# References
430-
# ----------
431-
# .. [1] Misra, P. and Enge, P,
432-
# "Global Positioning System: Signals, Measurements, and Performance."
433-
# 2nd Edition, Ganga-Jamuna Press, 2006.
434-
# .. [2] B. F. Thompson, S. W. Lewis, S. A. Brown, and T. M. Scott,
435-
# “Computing GPS satellite velocity and acceleration from the broadcast
436-
# navigation message,” NAVIGATION, vol. 66, no. 4, pp. 769–779, Dec. 2019,
437-
# doi: 10.1002/navi.342.
438-
#
439-
# """
440-
#
441-
# # Convert time from GPS millis to TOW
442-
# gps_week, gps_tow = gps_millis_to_tow(gps_millis)
443-
# # Extract parameters
444-
#
445-
# c_is = ephem_orbit_params['C_is']
446-
# c_ic = ephem_orbit_params['C_ic']
447-
# c_rs = ephem_orbit_params['C_rs']
448-
# c_rc = ephem_orbit_params['C_rc']
449-
# c_uc = ephem_orbit_params['C_uc']
450-
# c_us = ephem_orbit_params['C_us']
451-
# delta_n = ephem_orbit_params['deltaN']
452-
#
453-
# ecc = ephem_orbit_params['e'] # eccentricity
454-
# omega = ephem_orbit_params['omega'] # argument of perigee
455-
# omega_0 = ephem_orbit_params['Omega_0']
456-
# sqrt_sma = ephem_orbit_params['sqrtA'] # sqrt of semi-major axis
457-
# sma = sqrt_sma**2 # semi-major axis
458-
#
459-
# sqrt_mu_a = np.sqrt(consts.MU_EARTH) * sqrt_sma**-3 # mean angular motion
460-
# gpsweek_diff = (np.mod(gps_week,1024) - np.mod(ephem_orbit_params['gps_week'],1024))*604800.
461-
# sv_posvel = NavData()
462-
# sv_posvel['gnss_id'] = ephem_orbit_params['gnss_id']
463-
# sv_posvel['sv_id'] = ephem_orbit_params['sv_id']
464-
# sv_posvel['gps_millis'] = gps_millis
465-
#
466-
# delta_t = gps_tow - ephem_orbit_params['t_oe'] + gpsweek_diff
467-
#
468-
# # Calculate the mean anomaly with corrections
469-
# ecc_anom = _compute_eccentric_anomaly(gps_week, gps_tow,
470-
# ephem_orbit_params)
471-
#
472-
# cos_e = np.cos(ecc_anom)
473-
# sin_e = np.sin(ecc_anom)
474-
# e_cos_e = (1 - ecc*cos_e)
475-
#
476-
# # Calculate the true anomaly from the eccentric anomaly
477-
# sin_nu = np.sqrt(1 - ecc**2) * (sin_e/e_cos_e)
478-
# cos_nu = (cos_e-ecc) / e_cos_e
479-
# nu_rad = np.arctan2(sin_nu, cos_nu)
480-
#
481-
# # Calcualte the argument of latitude iteratively
482-
# phi_0 = nu_rad + omega
483-
# phi = phi_0
484-
# for incl in range(5):
485-
# cos_to_phi = np.cos(2.*phi)
486-
# sin_to_phi = np.sin(2.*phi)
487-
# phi_corr = c_uc * cos_to_phi + c_us * sin_to_phi
488-
# phi = phi_0 + phi_corr
489-
#
490-
# # Calculate the longitude of ascending node with correction
491-
# omega_corr = ephem_orbit_params['OmegaDot'] * delta_t
492-
#
493-
# # Also correct for the rotation since the beginning of the GPS week for which the Omega0 is
494-
# # defined. Correct for GPS week rollovers.
495-
#
496-
# # Also correct for the rotation since the beginning of the GPS week for
497-
# # which the Omega0 is defined. Correct for GPS week rollovers.
498-
# omega = omega_0 - (consts.OMEGA_E_DOT*(gps_tow + gpsweek_diff)) + omega_corr
499-
#
500-
# # Calculate orbital radius with correction
501-
# r_corr = c_rc * cos_to_phi + c_rs * sin_to_phi
502-
# orb_radius = sma*e_cos_e + r_corr
503-
#
504-
# ############################################
505-
# ###### Lines added for velocity (1) ######
506-
# ############################################
507-
# delta_e = (sqrt_mu_a + delta_n) / e_cos_e
508-
# dphi = np.sqrt(1 - ecc**2)*delta_e / e_cos_e
509-
# # Changed from the paper
510-
# delta_r = (sma * ecc * delta_e * sin_e) + 2*(c_rs*cos_to_phi - c_rc*sin_to_phi)*dphi
511-
#
512-
# # Calculate the inclination with correction
513-
# i_corr = c_ic*cos_to_phi + c_is*sin_to_phi + ephem_orbit_params['IDOT']*delta_t
514-
# incl = ephem_orbit_params['i_0'] + i_corr
515-
#
516-
# ############################################
517-
# ###### Lines added for velocity (2) ######
518-
# ############################################
519-
# delta_i = 2*(c_is*cos_to_phi - c_ic*sin_to_phi)*dphi + ephem_orbit_params['IDOT']
520-
#
521-
# # Find the position in the orbital plane
522-
# x_plane = orb_radius*np.cos(phi)
523-
# y_plane = orb_radius*np.sin(phi)
524-
#
525-
# ############################################
526-
# ###### Lines added for velocity (3) ######
527-
# ############################################
528-
# delta_u = (1 + 2*(c_us * cos_to_phi - c_uc*sin_to_phi))*dphi
529-
# dxp = delta_r*np.cos(phi) - orb_radius*np.sin(phi)*delta_u
530-
# dyp = delta_r*np.sin(phi) + orb_radius*np.cos(phi)*delta_u
531-
# # Find satellite position in ECEF coordinates
532-
# cos_omega = np.cos(omega)
533-
# sin_omega = np.sin(omega)
534-
# cos_i = np.cos(incl)
535-
# sin_i = np.sin(incl)
536-
#
537-
# sv_posvel['x_sv_m'] = x_plane*cos_omega - y_plane*cos_i*sin_omega
538-
# sv_posvel['y_sv_m'] = x_plane*sin_omega + y_plane*cos_i*cos_omega
539-
# sv_posvel['z_sv_m'] = y_plane*sin_i
540-
#
541-
# ############################################
542-
# ###### Lines added for velocity (4) ######
543-
# ############################################
544-
# omega_dot = ephem_orbit_params['OmegaDot'] - consts.OMEGA_E_DOT
545-
# sv_posvel['vx_sv_mps'] = (dxp * cos_omega
546-
# - dyp * cos_i*sin_omega
547-
# + y_plane * sin_omega*sin_i*delta_i
548-
# - (x_plane * sin_omega + y_plane*cos_i*cos_omega)*omega_dot)
549-
#
550-
# sv_posvel['vy_sv_mps'] = (dxp * sin_omega
551-
# + dyp * cos_i * cos_omega
552-
# - y_plane * sin_i * cos_omega * delta_i
553-
# + (x_plane * cos_omega - (y_plane*cos_i*sin_omega)) * omega_dot)
554-
#
555-
# sv_posvel['vz_sv_mps'] = dyp*sin_i + y_plane*cos_i*delta_i
556-
#
557-
# # Estimate SV clock corrections, including polynomial and relativistic
558-
# # clock corrections
559-
# clock_corr, _, _ = _estimate_sv_clock_corr(gps_millis,
560-
# ephem_orbit_params)
561-
#
562-
# sv_posvel['b_sv_m'] = clock_corr
563-
#
564-
# return sv_posvel
565-
#
566-
#
567-
# def numerical_integration_for_sv_states(self, gps_millis):
568-
# pass
569-
570363

571364
def _compute_eccentric_anomaly(gps_week, gps_tow, ephem, tol=1e-5, max_iter=10):
572365
"""Compute the eccentric anomaly from ephemeris parameters.

gnss_lib_py/utils/gnss_models.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
find_sv_location, find_sv_states, \
2222
find_visible_sv_posvel, _sort_ephem_measures, \
2323
_filter_ephemeris_measurements
24-
from gnss_lib_py.parsers.rinex_nav import _compute_eccentric_anomaly
2524
from gnss_lib_py.utils.ephemeris_downloader import DEFAULT_EPHEM_PATH
2625

2726

@@ -339,16 +338,6 @@ def expected_measures(gps_millis, state, ephem=None, sv_posvel=None):
339338
return measurements, sv_posvel
340339

341340

342-
# def _matching_state_for_measure(measurements, state_estimate,
343-
# delta_t_decimals=2):
344-
# measurement_times = np.sort(np.unique(np.around(times,
345-
# decimals=delta_t_decimals)))
346-
# for
347-
348-
349-
# return measure_time_state_row
350-
351-
352341
def _extract_state_variables(state):
353342
"""Extract position, velocity and clock bias terms from state.
354343
@@ -450,14 +439,6 @@ def calculate_pseudorange_corr(gps_millis, state=None, ephem=None, sv_posvel=Non
450439
"SV states must be given when ephemeris isn't"
451440
satellites = len(sv_posvel)
452441

453-
# # calculate clock pseudorange correction
454-
# if ephem is not None:
455-
# clock_corr, _, _ = _calculate_clock_delay(gps_millis, ephem)
456-
# else:
457-
# warnings.warn("Broadcast ephemeris not given, returning 0 "\
458-
# + "clock corrections", RuntimeWarning)
459-
# clock_corr = np.zeros(satellites)
460-
461442
if rx_ecef is not None:
462443
# Calculate the tropospheric delays
463444
tropo_delay = _calculate_tropo_delay(gps_millis, rx_ecef, ephem, sv_posvel)
@@ -475,69 +456,9 @@ def calculate_pseudorange_corr(gps_millis, state=None, ephem=None, sv_posvel=Non
475456
RuntimeWarning)
476457
iono_delay = np.zeros(satellites)
477458

478-
# return clock_corr, tropo_delay, iono_delay
479459
return tropo_delay, iono_delay
480460

481461

482-
# def _calculate_clock_delay(gps_millis, ephem):
483-
# """Calculate the modelled satellite clock delay
484-
485-
# Parameters
486-
# ---------
487-
# gps_millis : int
488-
# Time at which measurements are needed, measured in milliseconds
489-
# since start of GPS epoch [ms].
490-
# ephem : gnss_lib_py.parsers.navdata.NavData
491-
# Satellite ephemeris parameters for measurement SVs.
492-
493-
# Returns
494-
# -------
495-
# clock_corr : np.ndarray
496-
# Satellite clock corrections containing all terms [m].
497-
# corr_polynomial : np.ndarray
498-
# Polynomial clock perturbation terms [m].
499-
# clock_relativistic : np.ndarray
500-
# Relativistic clock correction terms [m].
501-
502-
# """
503-
# # Extract required GPS constants
504-
# ecc = ephem['e'] # eccentricity
505-
# sqrt_sma = ephem['sqrtA'] # sqrt of semi-major axis
506-
507-
# # if np.abs(delta_t).any() > 302400:
508-
# # delta_t = delta_t - np.sign(delta_t)*604800
509-
510-
# gps_week, gps_tow = gps_millis_to_tow(gps_millis)
511-
512-
# # Compute Eccentric Anomaly
513-
# ecc_anom = _compute_eccentric_anomaly(gps_week, gps_tow, ephem)
514-
515-
# # Determine pseudorange corrections due to satellite clock corrections.
516-
# # Calculate time offset from satellite reference time
517-
# t_offset = gps_tow - ephem['t_oc']
518-
# if np.abs(t_offset).any() > 302400: # pragma: no cover
519-
# t_offset = t_offset-np.sign(t_offset)*604800
520-
521-
# # Calculate clock corrections from the polynomial corrections in
522-
# # broadcast message
523-
# corr_polynomial = (ephem['SVclockBias']
524-
# + ephem['SVclockDrift']*t_offset
525-
# + ephem['SVclockDriftRate']*t_offset**2)
526-
527-
# # Calcualte the relativistic clock correction
528-
# corr_relativistic = consts.F * ecc * sqrt_sma * np.sin(ecc_anom)
529-
530-
# # Calculate the total clock correction including the Tgd term
531-
# clk_corr = (corr_polynomial - ephem['TGD'] + corr_relativistic)
532-
533-
# #Convert values to equivalent meters from seconds
534-
# clk_corr = np.array(consts.C*clk_corr, ndmin=1)
535-
# corr_polynomial = np.array(consts.C*corr_polynomial, ndmin=1)
536-
# corr_relativistic = np.array(consts.C*corr_relativistic, ndmin=1)
537-
538-
# return clk_corr, corr_polynomial, corr_relativistic
539-
540-
541462
def _calculate_tropo_delay(gps_millis, rx_ecef, ephem=None, sv_posvel=None):
542463
"""Calculate tropospheric delay
543464

0 commit comments

Comments
 (0)