|
21 | 21 | from gnss_lib_py.parsers.sp3 import Sp3 |
22 | 22 | from gnss_lib_py.parsers.clk import Clk |
23 | 23 |
|
24 | | -def svs_from_el_az(elaz_deg): |
25 | | - """Generate NED satellite positions for given elevation and azimuth. |
26 | 24 |
|
27 | | - Given elevation and azimuth angles, with respect to the receiver, |
28 | | - generate satellites in the NED frame of reference with the receiver |
29 | | - position as the origin. Satellites are assumed to have a nominal |
30 | | - distance of 20,200 km from the receiver (height of GNSS satellite orbit) |
| 25 | +def add_sv_states(measurements, source = 'precise', file_paths = None, |
| 26 | + download_directory = DEFAULT_EPHEM_PATH, |
| 27 | + constellations = None, delta_t_dec = -2, |
| 28 | + verbose = True): |
| 29 | + """Add SV states to measurements using SP3 and CLK or Rinex files. |
| 30 | + """ |
| 31 | + 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) |
| 38 | + else: |
| 39 | + raise RuntimeError('Only Precise SV state estimation supported') |
| 40 | + return measurements_w_sv_states |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +def add_sv_states_precise(measurements, sp3_clk_paths = None, |
| 45 | + download_directory = DEFAULT_EPHEM_PATH, |
| 46 | + constellations=None, delta_t_dec=-2, |
| 47 | + verbose=True): |
| 48 | + """Add SV states to measurements using SP3 and CLK files. |
| 49 | +
|
| 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. |
31 | 55 |
|
32 | 56 | Parameters |
33 | 57 | ---------- |
34 | | - elaz_deg : np.ndarray |
35 | | - Nx2 array of elevation and azimuth angles [degrees] |
36 | | -
|
37 | | - Returns |
38 | | - ------- |
39 | | - svs_ned : np.ndarray |
40 | | - Nx3 satellite NED positions, simulated at a distance of 20,200 km |
41 | 58 | """ |
42 | | - assert np.shape(elaz_deg)[0] == 2, "elaz_deg should be a 2xN array" |
43 | | - el_deg = np.deg2rad(elaz_deg[0, :]) |
44 | | - az_deg = np.deg2rad(elaz_deg[1, :]) |
45 | | - unit_vect = np.zeros([3, np.shape(elaz_deg)[1]]) |
46 | | - unit_vect[0, :] = np.sin(az_deg)*np.cos(el_deg) |
47 | | - unit_vect[1, :] = np.cos(az_deg)*np.cos(el_deg) |
48 | | - unit_vect[2, :] = np.sin(el_deg) |
49 | | - svs_ned = 20200000*unit_vect |
50 | | - return svs_ned |
| 59 | + return measurements |
| 60 | + |
51 | 61 |
|
52 | 62 |
|
53 | | -def add_sv_states(measurements, ephemeris_path= DEFAULT_EPHEM_PATH, |
| 63 | +def add_sv_states_rinex(measurements, ephemeris_path= DEFAULT_EPHEM_PATH, |
54 | 64 | constellations=['gps'], delta_t_dec = -2): |
55 | 65 | """ |
56 | 66 | Add SV states (ECEF position and velocities) to measurements. |
@@ -121,6 +131,7 @@ def add_sv_states(measurements, ephemeris_path= DEFAULT_EPHEM_PATH, |
121 | 131 | sv_states_all_time.concat(measure_frame, inplace=True) |
122 | 132 | return sv_states_all_time |
123 | 133 |
|
| 134 | + |
124 | 135 | def add_visible_svs_for_trajectory(rx_states, |
125 | 136 | ephemeris_path=DEFAULT_EPHEM_PATH, |
126 | 137 | constellations=['gps'], el_mask = 5.): |
@@ -198,6 +209,34 @@ def add_visible_svs_for_trajectory(rx_states, |
198 | 209 |
|
199 | 210 | return sv_posvel_trajectory |
200 | 211 |
|
| 212 | +def svs_from_el_az(elaz_deg): |
| 213 | + """Generate NED satellite positions for given elevation and azimuth. |
| 214 | +
|
| 215 | + Given elevation and azimuth angles, with respect to the receiver, |
| 216 | + generate satellites in the NED frame of reference with the receiver |
| 217 | + position as the origin. Satellites are assumed to have a nominal |
| 218 | + distance of 20,200 km from the receiver (height of GNSS satellite orbit) |
| 219 | +
|
| 220 | + Parameters |
| 221 | + ---------- |
| 222 | + elaz_deg : np.ndarray |
| 223 | + Nx2 array of elevation and azimuth angles [degrees] |
| 224 | +
|
| 225 | + Returns |
| 226 | + ------- |
| 227 | + svs_ned : np.ndarray |
| 228 | + Nx3 satellite NED positions, simulated at a distance of 20,200 km |
| 229 | + """ |
| 230 | + assert np.shape(elaz_deg)[0] == 2, "elaz_deg should be a 2xN array" |
| 231 | + el_deg = np.deg2rad(elaz_deg[0, :]) |
| 232 | + az_deg = np.deg2rad(elaz_deg[1, :]) |
| 233 | + unit_vect = np.zeros([3, np.shape(elaz_deg)[1]]) |
| 234 | + unit_vect[0, :] = np.sin(az_deg)*np.cos(el_deg) |
| 235 | + unit_vect[1, :] = np.cos(az_deg)*np.cos(el_deg) |
| 236 | + unit_vect[2, :] = np.sin(el_deg) |
| 237 | + svs_ned = 20200000*unit_vect |
| 238 | + return svs_ned |
| 239 | + |
201 | 240 |
|
202 | 241 | def find_sv_states(gps_millis, ephem): |
203 | 242 | """Compute position and velocities for all satellites in ephemeris file |
|
0 commit comments