Skip to content

Commit d4f0b08

Browse files
committed
ephemeris changes for smartLoc compatibility
1 parent ae9a6a4 commit d4f0b08

3 files changed

Lines changed: 31 additions & 72 deletions

File tree

gnss_lib_py/parsers/ephemeris.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class EphemerisManager():
5353
Ephemeris parameters
5454
leapseconds : int
5555
Leap seconds to add to UTC time to get GPS time
56+
verbose : bool
57+
If true, prints debugging statements.
5658
5759
Notes
5860
-----

gnss_lib_py/parsers/precise_ephemerides.py

Lines changed: 28 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
NUMSATS = {'gps': (32, 'G'),
2525
'galileo': (36, 'E'),
2626
'beidou': (46, 'C'),
27-
'glonass': (24, 'R'),
27+
'glonass': (26, 'R'), # 26 total GLONASS satellites in orbit
2828
'qzss': (3, 'J')}
2929

3030
class Sp3:
@@ -501,6 +501,14 @@ def single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
501501
# Compute satellite information for desired time steps
502502
unique_timesteps = np.unique(navdata["gps_millis"])
503503

504+
# add satellite indexes if not present already.
505+
sv_idx_keys = ['x_sv_m', 'y_sv_m', 'z_sv_m', \
506+
'vx_sv_mps','vy_sv_mps','vz_sv_mps', \
507+
'b_sv_m', 'b_dot_sv_mps']
508+
for sv_idx_key in sv_idx_keys:
509+
if sv_idx_key not in navdata.rows:
510+
navdata[sv_idx_key] = np.nan
511+
504512
for t_idx, timestep in enumerate(unique_timesteps):
505513

506514
# Compute indices where gps_millis match, sort them
@@ -514,19 +522,19 @@ def single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
514522
print('misc: ', navdata['gps_millis', sorted_idxs], \
515523
navdata['gnss_id', sorted_idxs], \
516524
navdata['sv_id', sorted_idxs], \
517-
navdata['signal_type', sorted_idxs])
525+
)
518526

519-
# this if else condition can be removed later after navdata has been
520-
# fixed to represent one data point as an array as well
521-
if len(sorted_idxs)==1:
522-
visible_sats = np.array([navdata["sv_id", sorted_idxs]])
523-
else:
524-
visible_sats = navdata["sv_id", sorted_idxs]
527+
visible_sats = np.atleast_1d(navdata["sv_id", sorted_idxs])
525528

526529
for sv_idx, prn in enumerate(visible_sats):
527530

528531
prn = int(prn)
529532

533+
# continue if no sp3 or clk data availble
534+
if len(sp3_parsed_file[prn].tym) == 0 \
535+
or len(clk_parsed_file[prn].tym) == 0:
536+
continue
537+
530538
# Perform nearest time step search to compute iref values for sp3 and clk
531539
sp3_iref = np.argmin(abs(np.array(sp3_parsed_file[prn].tym) - \
532540
(timestep - navdata_offset) ))
@@ -613,46 +621,19 @@ def single_gnss_from_precise_eph(navdata, sp3_parsed_file, \
613621
navdata["b_dot_sv_mps", sorted_idxs[sv_idx]] - consts.C * satdrift_clk)
614622
print(' ')
615623

616-
# update x_sv_m of navdata with the estimated values from .sp3 files
624+
# update *_sv_m of navdata with the estimated values from .sp3 files
617625
navdata['x_sv_m', sorted_idxs[sv_idx]] = np.array([satpos_sp3[0]])
618-
if not (navdata["x_sv_m", sorted_idxs[sv_idx]] - satpos_sp3[0] == 0.0):
619-
raise RuntimeError("x_sv_m of navdata not correctly updated")
620-
621-
# update y_sv_m of navdata with the estimated values from .sp3 files
622626
navdata['y_sv_m', sorted_idxs[sv_idx]] = np.array([satpos_sp3[1]])
623-
if not (navdata["y_sv_m", sorted_idxs[sv_idx]] - satpos_sp3[1] == 0.0):
624-
raise RuntimeError("y_sv_m of navdata not correctly updated")
625-
626-
# update z_sv_m of navdata with the estimated values from .sp3 files
627627
navdata['z_sv_m', sorted_idxs[sv_idx]] = np.array([satpos_sp3[2]])
628-
if not (navdata["z_sv_m", sorted_idxs[sv_idx]] - satpos_sp3[2] == 0.0):
629-
raise RuntimeError("z_sv_m of navdata not correctly updated")
630628

631-
# update vx_sv_mps of navdata with the estimated values from .sp3 files
629+
# update v*_sv_mps of navdata with the estimated values from .sp3 files
632630
navdata["vx_sv_mps", sorted_idxs[sv_idx]] = np.array([satvel_sp3[0]])
633-
if not (navdata["vx_sv_mps", sorted_idxs[sv_idx]] - satvel_sp3[0] == 0.0):
634-
raise RuntimeError("vx_sv_mps of navdata not correctly updated")
635-
636-
# update vy_sv_mps of navdata with the estimated values from .sp3 files
637631
navdata["vy_sv_mps", sorted_idxs[sv_idx]] = np.array([satvel_sp3[1]])
638-
if not (navdata["vy_sv_mps", sorted_idxs[sv_idx]] - satvel_sp3[1] == 0.0):
639-
raise RuntimeError("vy_sv_mps of navdata not correctly updated")
640-
641-
# update vz_sv_mps of navdata with the estimated values from .sp3 files
642632
navdata["vz_sv_mps", sorted_idxs[sv_idx]] = np.array([satvel_sp3[2]])
643-
if not (navdata["vz_sv_mps", sorted_idxs[sv_idx]] - satvel_sp3[2] == 0.0):
644-
raise RuntimeError("vz_sv_mps of navdata not correctly updated")
645633

646-
# update b_sv_m of navdata with the estimated values from .clk files
634+
# update clock data of navdata with the estimated values from .clk files
647635
navdata["b_sv_m", sorted_idxs[sv_idx]] = np.array([consts.C * satbias_clk])
648-
if not (navdata["b_sv_m", sorted_idxs[sv_idx]] - consts.C * satbias_clk == 0.0):
649-
raise RuntimeError("b_sv_m of navdata not correctly updated")
650-
651-
# update b_dot_sv_mps of navdata with the estimated values from .clk files
652636
navdata["b_dot_sv_mps", sorted_idxs[sv_idx]] = np.array([consts.C * satdrift_clk])
653-
if not (navdata["b_dot_sv_mps", sorted_idxs[sv_idx]] - \
654-
consts.C * satdrift_clk == 0.0):
655-
raise RuntimeError("b_dot_sv_mps of navdata not correctly updated")
656637

657638
return navdata
658639

@@ -664,10 +645,13 @@ def multi_gnss_from_precise_eph(navdata, sp3_path, clk_path, \
664645
----------
665646
navdata : gnss_lib_py.parsers.navdata.NavData
666647
Instance of the NavData class that depicts android derived dataset
667-
sp3_parsed_file : list
668-
Instance with list of gnss_lib_py.parsers.precise_ephemerides.Sp3
669-
clk_parsed_file : list
670-
Instance with array of gnss_lib_py.parsers.precise_ephemerides.Clk
648+
sp3_path : path
649+
File path for .sp3 file to extract precise ephemerides
650+
clk_path : path
651+
File path for .clk file to extract precise ephemerides
652+
gnss_consts : array-like
653+
The GNSS constellations for which you want to extract precise
654+
ephemeris, (e.g. ['gps','glonass'])
671655
verbose : bool
672656
Flag (True/False) for whether to print intermediate steps useful
673657
for debugging/reviewing (the default is False)
@@ -743,7 +727,6 @@ def sv_gps_from_brdcst_eph(navdata, verbose = False):
743727
print('misc: ', navdata['gps_millis', sorted_idxs], \
744728
navdata['gnss_id', sorted_idxs], \
745729
navdata['sv_id', sorted_idxs], \
746-
navdata['signal_type', sorted_idxs], \
747730
desired_sats, rxdatetime)
748731

749732
satpos_android = np.transpose([ navdata["x_sv_m", sorted_idxs], \
@@ -777,34 +760,14 @@ def sv_gps_from_brdcst_eph(navdata, verbose = False):
777760
np.linalg.norm(satvel_ephemeris - satvel_android, axis=1) )
778761
print(' ')
779762

780-
# update x_sv_m of navdata with the estimated values from .n files
763+
# update *_sv_m of navdata with the estimated values from .n files
781764
navdata["x_sv_m", sorted_idxs] = satpos_ephemeris[:,0]
782-
if not max(abs(navdata["x_sv_m", sorted_idxs] - satpos_ephemeris[:,0])) == 0.0:
783-
raise RuntimeError("x_sv_m of navdata not correctly updated")
784-
785-
# update y_sv_m of navdata with the estimated values from .n files
786765
navdata["y_sv_m", sorted_idxs] = satpos_ephemeris[:,1]
787-
if not max(abs(navdata["y_sv_m", sorted_idxs] - satpos_ephemeris[:,1])) == 0.0:
788-
raise RuntimeError("y_sv_m of navdata not correctly updated")
789-
790-
# update z_sv_m of navdata with the estimated values from .n files
791766
navdata["z_sv_m", sorted_idxs] = satpos_ephemeris[:,2]
792-
if not max(abs(navdata["z_sv_m", sorted_idxs] - satpos_ephemeris[:,2])) == 0.0:
793-
raise RuntimeError("z_sv_m of navdata not correctly updated")
794767

795-
# update vx_sv_mps of navdata with the estimated values from .n files
768+
# update v*_sv_mps of navdata with the estimated values from .n files
796769
navdata["vx_sv_mps", sorted_idxs] = satvel_ephemeris[:,0]
797-
if not max(abs(navdata["vx_sv_mps", sorted_idxs] - satvel_ephemeris[:,0])) == 0.0:
798-
raise RuntimeError("vx_sv_mps of navdata not correctly updated")
799-
800-
# update vy_sv_mps of navdata with the estimated values from .n files
801770
navdata["vy_sv_mps", sorted_idxs] = satvel_ephemeris[:,1]
802-
if not max(abs(navdata["vy_sv_mps", sorted_idxs] - satvel_ephemeris[:,1])) == 0.0:
803-
raise RuntimeError("vy_sv_mps of navdata not correctly updated")
804-
805-
# update vz_sv_mps of navdata with the estimated values from .n files
806771
navdata["vz_sv_mps", sorted_idxs] = satvel_ephemeris[:,2]
807-
if not max(abs(navdata["vz_sv_mps", sorted_idxs] - satvel_ephemeris[:,2])) == 0.0:
808-
raise RuntimeError("vz_sv_mps of navdata not correctly updated")
809772

810773
return navdata

tests/parsers/test_precise_ephemerides.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
from gnss_lib_py.parsers.precise_ephemerides import sv_gps_from_brdcst_eph
2323
from gnss_lib_py.parsers.precise_ephemerides import sp3_snapshot, clk_snapshot
2424
from gnss_lib_py.parsers.precise_ephemerides import extract_sp3, extract_clk
25+
from gnss_lib_py.parsers.precise_ephemerides import NUMSATS
2526
import gnss_lib_py.utils.constants as consts
2627

27-
# Define the number of sats to create arrays for
28-
NUMSATS = {'gps': (32, 'G'),
29-
'galileo': (36, 'E'),
30-
'beidou': (46, 'C'),
31-
'glonass': (24, 'R'),
32-
'qzss': (3, 'J')}
33-
3428
# Define the no. of samples to test functions:test_gps_sp3_funcs,
3529
# test_gps_clk_funcs, test_glonass_sp3_funcs, test_glonass_clk_funcs
3630
NUMSAMPLES = 4

0 commit comments

Comments
 (0)