|
22 | 22 | from gnss_lib_py.utils.ephemeris_downloader import DEFAULT_EPHEM_PATH, load_ephemeris |
23 | 23 |
|
24 | 24 |
|
25 | | -def add_sv_states(measurements, source = 'precise', file_paths = None, |
| 25 | +def add_sv_states(navdata, source = 'precise', file_paths = None, |
26 | 26 | download_directory = DEFAULT_EPHEM_PATH, |
27 | | - constellations = None, delta_t_dec = -2, |
28 | 27 | verbose = True): |
29 | 28 | """Add SV states to measurements using SP3 and CLK or Rinex files. |
| 29 | +
|
| 30 | + If source is 'precise' then will use SP3 and CLK files. |
| 31 | +
|
| 32 | + Parameters |
| 33 | + ---------- |
| 34 | + navdata : gnss_lib_py.parsers.navdata.NavData |
| 35 | + Instance of the NavData class that must include rows for |
| 36 | + ``gps_millis``, ``gnss_id``, ``sv_id``, and ``raw_pr_m``. |
| 37 | + source : string |
| 38 | + The method used to compute SV states. If 'precise', then will |
| 39 | + use SP3 and CLK precise files. |
| 40 | + file_paths : list, string or path-like |
| 41 | + Paths to existing ephemeris files if they exist. |
| 42 | + download_directory : string or path-like |
| 43 | + Directory where ephemeris files are downloaded if necessary. |
| 44 | + verbose : bool |
| 45 | + Prints extra debugging statements if true. |
| 46 | +
|
| 47 | + Returns |
| 48 | + ------- |
| 49 | + navdata_w_sv_states : gnss_lib_py.parsers.navdata.NavData |
| 50 | + Updated NavData class with satellite information computed. |
| 51 | +
|
30 | 52 | """ |
31 | 53 | if source == 'precise': |
32 | | - measurements_w_sv_states = add_sv_states_precise(measurements, |
33 | | - sp3_clk_paths = file_paths, |
34 | | - download_directory = download_directory, |
35 | | - constellations = constellations, |
36 | | - delta_t_dec = delta_t_dec, |
37 | | - verbose = verbose) |
| 54 | + navdata_w_sv_states = add_sv_states_precise(navdata, |
| 55 | + file_paths = file_paths, |
| 56 | + download_directory = download_directory, |
| 57 | + verbose = verbose) |
38 | 58 | else: |
39 | 59 | raise RuntimeError('Only Precise SV state estimation supported') |
40 | | - return measurements_w_sv_states |
41 | | - |
| 60 | + return navdata_w_sv_states |
42 | 61 |
|
43 | 62 |
|
44 | | -def add_sv_states_precise(measurements, sp3_clk_paths = None, |
| 63 | +def add_sv_states_precise(navdata, file_paths = None, |
45 | 64 | download_directory = DEFAULT_EPHEM_PATH, |
46 | | - constellations=None, delta_t_dec=-2, |
47 | 65 | verbose=True): |
48 | 66 | """Add SV states to measurements using SP3 and CLK files. |
49 | 67 |
|
50 | | - Given received measurements, add SV states for measurements corresponding |
51 | | - to received time and SV ID using SP3 and CLK files. If receiver |
52 | | - position is given, that position is used to calculate the difference |
53 | | - between signal transmission and reception to find the SV states |
54 | | - corresponding to the time at which the signal was transmitted. |
55 | | -
|
56 | 68 | Parameters |
57 | 69 | ---------- |
58 | | - """ |
59 | | - return measurements |
| 70 | + navdata : gnss_lib_py.parsers.navdata.NavData |
| 71 | + Instance of the NavData class that must include rows for |
| 72 | + ``gps_millis``, ``gnss_id``, ``sv_id``, and ``raw_pr_m``. |
| 73 | + source : string |
| 74 | + The method used to compute SV states. If 'precise', then will |
| 75 | + use SP3 and CLK precise files. |
| 76 | + file_paths : list, string or path-like |
| 77 | + Paths to existing SP3 or CLK files if they exist. |
| 78 | + download_directory : string or path-like |
| 79 | + Directory where ephemeris files are downloaded if necessary. |
| 80 | + verbose : bool |
| 81 | + Prints extra debugging statements if true. |
60 | 82 |
|
| 83 | + Returns |
| 84 | + ------- |
| 85 | + navdata_w_sv_states : gnss_lib_py.parsers.navdata.NavData |
| 86 | + Updated NavData class with satellite information computed. |
61 | 87 |
|
| 88 | + """ |
| 89 | + |
| 90 | + # get unique gps_millis and constellations for ephemeris loader |
| 91 | + unique_gps_millis = np.unique(navdata["gps_millis"]) |
| 92 | + constellations = np.unique(navdata["gnss_id"]) |
| 93 | + |
| 94 | + # load sp3 files |
| 95 | + sp3_paths = load_ephemeris("sp3", gps_millis = unique_gps_millis, |
| 96 | + constellations=constellations, |
| 97 | + file_paths = file_paths, |
| 98 | + download_directory=download_directory, |
| 99 | + verbose=verbose |
| 100 | + ) |
| 101 | + sp3 = Sp3(sp3_paths) |
| 102 | + |
| 103 | + # load clk files |
| 104 | + clk_paths = load_ephemeris("clk", gps_millis = unique_gps_millis, |
| 105 | + constellations=constellations, |
| 106 | + file_paths = file_paths, |
| 107 | + download_directory=download_directory, |
| 108 | + verbose=verbose |
| 109 | + ) |
| 110 | + clk = Clk(clk_paths) |
| 111 | + |
| 112 | + # add SV states using sp3 and clk |
| 113 | + navdata_w_sv_states = single_gnss_from_precise_eph(navdata, |
| 114 | + sp3, |
| 115 | + clk, |
| 116 | + verbose=verbose) |
| 117 | + |
| 118 | + return navdata_w_sv_states |
62 | 119 |
|
63 | 120 | def add_sv_states_rinex(measurements, ephemeris_path= DEFAULT_EPHEM_PATH, |
64 | 121 | constellations=['gps'], delta_t_dec = -2): |
@@ -709,9 +766,6 @@ def _find_delxyz_range(sv_posvel, rx_ecef): |
709 | 766 | true_range = np.linalg.norm(del_pos, axis=0) |
710 | 767 | return del_pos, true_range |
711 | 768 |
|
712 | | - |
713 | | - |
714 | | - |
715 | 769 | def single_gnss_from_precise_eph(navdata, sp3_parsed_file, |
716 | 770 | clk_parsed_file, inplace=False, |
717 | 771 | verbose = False): |
@@ -862,39 +916,3 @@ def single_gnss_from_precise_eph(navdata, sp3_parsed_file, |
862 | 916 | if inplace: |
863 | 917 | return None |
864 | 918 | return new_navdata |
865 | | - |
866 | | -def add_sv_states_sp3_and_clk(navdata, sp3_path, clk_path, |
867 | | - inplace=False, verbose = False): |
868 | | - """Compute satellite information using .sp3 and .clk for multiple GNSS |
869 | | -
|
870 | | - Parameters |
871 | | - ---------- |
872 | | - navdata : gnss_lib_py.parsers.navdata.NavData |
873 | | - Instance of the NavData class that depicts android derived dataset |
874 | | - sp3_path : path |
875 | | - File path for .sp3 file to extract precise ephemerides |
876 | | - clk_path : path |
877 | | - File path for .clk file to extract precise ephemerides |
878 | | - inplace : bool |
879 | | - If true, adds satellite positions and clock bias to the input |
880 | | - navdata object, otherwise returns a new NavData object with the |
881 | | - satellite rows added. |
882 | | - verbose : bool |
883 | | - Flag for whether to print intermediate steps useful |
884 | | - for debugging/reviewing (the default is False) |
885 | | -
|
886 | | - Returns |
887 | | - ------- |
888 | | - navdata : gnss_lib_py.parsers.navdata.NavData |
889 | | - Updated NavData class with satellite information computed using |
890 | | - precise ephemerides from .sp3 and .clk files |
891 | | - """ |
892 | | - sp3_parsed_gnss = Sp3(sp3_path) |
893 | | - clk_parsed_gnss = Clk(clk_path) |
894 | | - precise_navdata = single_gnss_from_precise_eph(navdata, |
895 | | - sp3_parsed_gnss, |
896 | | - clk_parsed_gnss, |
897 | | - inplace = inplace, |
898 | | - verbose = verbose) |
899 | | - |
900 | | - return precise_navdata |
|
0 commit comments