2424NUMSATS = {'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
3030class 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
0 commit comments