sv_models module

Model GNSS SV states (positions and velocities).

Functions to calculate GNSS SV positions and velocities for a given time.

sv_models._combine_gnss_sv_ids(measurement_frame)[source]

Combine string gnss_id and integer sv_id into single gnss_sv_id.

gnss_id contains strings like ‘gps’ and ‘glonass’ and sv_id contains integers. The newly returned gnss_sv_id is formatted as Axx where A is a single letter denoting the gnss_id and xx denote the two digit sv_id of the satellite.

Parameters:

measurement_frame (gnss_lib_py.navdata.navdata.NavData) – NavData instance containing measurements including gnss_id and sv_id.

Returns:

gnss_sv_id – New row values that combine gnss_id and sv_id into a something similar to ‘R01’ or ‘G12’ for example.

Return type:

np.ndarray

Notes

For reference on strings and the contellation characters corresponding to them, refer to CONSTELLATION_CHARS in gnss_lib_py/utils/constants.py.

sv_models._extract_pos_vel_arr(sv_posvel)[source]

Extract satellite positions and velocities into numpy arrays.

Parameters:

sv_posvel (gnss_lib_py.navdata.navdata.NavData) – NavData containing satellite position and velocity states.

Returns:

  • sv_pos (np.ndarray) – ECEF satellite x, y and z positions 3xN [m].

  • sv_vel (np.ndarray) – ECEF satellite x, y and z velocities 3xN [m].

sv_models._filter_ephemeris_measurements(measurements, constellations, ephemeris_path='/home/docs/checkouts/readthedocs.org/user_builds/gnss-lib-py/checkouts/latest/docs/source/data/ephemeris', get_iono=False)[source]

Return subset of input measurements and ephmeris containing constellations and received SVs.

Measurements are filtered to contain the intersection of received and desired constellations. Ephemeris is extracted from the given path and a subset containing SVs that are in measurements is returned.

Parameters:
  • measurements (gnss_lib_py.navdata.navdata.NavData) – Received measurements, that are filtered based on constellations.

  • constellations (list) – List of strings indicating constellations required in output.

  • ephemeris_path (string or path-like) – Path where the ephermis files are stored or downloaded to.

Returns:

  • measurements_subset (gnss_lib_py.navdata.navdata.NavData) – Measurements containing desired constellations

  • ephem (gnss_lib_py.navdata.navdata.NavData) – Ephemeris parameters for received SVs and constellations

sv_models._find_delxyz_range(sv_posvel, rx_ecef)[source]

Return difference of satellite and rx_pos positions and distance between them.

Parameters:
  • sv_posvel (gnss_lib_py.navdata.navdata.NavData) – Satellite position and velocities.

  • rx_ecef (np.ndarray) – 3x1 Receiver 3D ECEF position [m].

Returns:

  • del_pos (np.ndarray) – Difference between satellite positions and receiver position.

  • true_range (np.ndarray) – Distance between satellite and receiver positions.

sv_models._sort_ephem_measures(measure_frame, ephem)[source]

Sort measures and return indices for sorting and inverting sort.

Parameters:
  • measure_frame (gnss_lib_py.navdata.navdata.NavData) – Measurements received for a single time instance, to be sorted.

  • ephem (gnss_lib_py.navdata.navdata.NavData) – Ephemeris parameters for all satellites for the closest time before the measurements were received.

Returns:

  • rx_ephem (gnss_lib_py.navdata.navdata.NavData) – Ephemeris parameters for satellites from which measurements were received. Sorted by gnss_sv_id.

  • sorted_sats_ind (np.ndarray) – Indices that sorts the original measurements by gnss_sv_id.

  • inv_sort_order (np.ndarray) – Indices that invert the sort by gnss_sv_id to match the order in the input measurements.

sv_models.add_sv_states(navdata, source='precise', file_paths=None, download_directory='/home/docs/checkouts/readthedocs.org/user_builds/gnss-lib-py/checkouts/latest/docs/source/data/ephemeris', verbose=False)[source]

Add SV states to measurements using SP3 and CLK or Rinex files.

If source is ‘precise’ then will use SP3 and CLK files.

Parameters:
  • navdata (gnss_lib_py.navdata.navdata.NavData) – Instance of the NavData class that must include rows for gps_millis, gnss_id, sv_id, and raw_pr_m.

  • source (string) – The method used to compute SV states. If ‘precise’, then will use SP3 and CLK precise files.

  • file_paths (list, string or path-like) – Paths to existing ephemeris files if they exist.

  • download_directory (string or path-like) – Directory where ephemeris files are downloaded if necessary.

  • verbose (bool) – Prints extra debugging statements if true.

Returns:

navdata_w_sv_states – Updated NavData class with satellite information computed.

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.add_sv_states_precise(navdata, file_paths=None, download_directory='/home/docs/checkouts/readthedocs.org/user_builds/gnss-lib-py/checkouts/latest/docs/source/data/ephemeris', verbose=True)[source]

Add SV states to measurements using SP3 and CLK files.

Parameters:
  • navdata (gnss_lib_py.navdata.navdata.NavData) – Instance of the NavData class that must include rows for gps_millis, gnss_id, sv_id, and raw_pr_m.

  • file_paths (list, string or path-like) – Paths to existing SP3 or CLK files if they exist.

  • download_directory (string or path-like) – Directory where ephemeris files are downloaded if necessary.

  • verbose (bool) – Prints extra debugging statements if true.

Returns:

navdata_w_sv_states – Updated NavData class with satellite information computed.

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.add_sv_states_rinex(measurements, ephemeris_path='/home/docs/checkouts/readthedocs.org/user_builds/gnss-lib-py/checkouts/latest/docs/source/data/ephemeris', constellations=['gps'], delta_t_dec=-2)[source]

Add SV states (ECEF position and velocities) to measurements.

Given received measurements, add SV states for measurements corresponding to received time and SV ID. If receiver position is given, that position is used to calculate the delay between signal transmission and reception, which is used to update the time at which the SV states are calculated.

Columns for SV calculation: gps_millis, gnss_id and sv_id. Columns for Rx based correction: x_rx*_m, y_rx*_m and z_rx*_m

Parameters:
  • measurements (gnss_lib_py.navdata.navdata.NavData) – Recorded measurements with time of recpetion, GNSS ID and SV ID, corresponding to which SV states are calculated

  • ephemeris_path (string or path-like) – Location where ephemeris files are stored. Files will be downloaded if they don’t exist for the given date and constellation. If not given, default from

  • constellations (list) – List of GNSS IDs for constellations are to be used. Others will be removed while processing the measurements

  • delta_t_dec (int) – Decimal places after which times are considered as belonging to the same discrete time interval.

Returns:

sv_states_all_time – Input measurements with rows containing SV states appended.

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.add_visible_svs_for_trajectory(rx_states, ephemeris_path='/home/docs/checkouts/readthedocs.org/user_builds/gnss-lib-py/checkouts/latest/docs/source/data/ephemeris', constellations=['gps'], el_mask=5.0)[source]

Wrapper to add visible satellite states for given times and positions.

Given a sequence of times and rx points in ECEF, along with desired constellations, give SV states for satellites that are visible along trajectory at given times (assuming open sky conditions).

rx_states must contain the following rows in order of increasing time: * gps_millis * x_rx*_m * y_rx*_m * z_rx*_m

Parameters:
  • rx_states (gnss_lib_py.navdata.navdata.NavData) – NavData containing position states of receiver at which SV states are needed.

  • ephemeris_path (string) – Path at which ephemeris files are to be stored. Uses directory default if not given.

  • constellations (list) – List of constellations for which states are to be estimated. Default is ['gps']. If None is given, will estimate states for all available constellations.

  • el_mask (float) – Elevation value above which satellites are considered visible.

Returns:

sv_posvel_trajectory – NavData instance containing

Return type:

gnss_lib_py.navdata.navdata.Navdata

sv_models.find_sv_location(gps_millis, rx_ecef, ephem=None, sv_posvel=None, get_iono=False)[source]

Given time, return SV positions, difference from Rx, and ranges.

Parameters:
  • gps_millis (int) – Time at which measurements are needed, measured in milliseconds since start of GPS epoch [ms].

  • rx_ecef (np.ndarray) – 3x1 Receiver 3D ECEF position [m].

  • ephem (gnss_lib_py.navdata.navdata.NavData) – DataFrame containing all satellite ephemeris parameters ephemeris, as indicated in find_sv_states. Use None if using precomputed satellite positions and velocities instead.

  • sv_posvel (gnss_lib_py.navdata.navdata.NavData) – Precomputed positions of satellites, use None if using broadcast ephemeris parameters instead.

Returns:

  • sv_posvel (gnss_lib_py.navdata.navdata.NavData) – Satellite position and velocities (same if input).

  • del_pos (np.ndarray) – Difference between satellite positions and receiver position.

  • true_range (np.ndarray) – Distance between satellite and receiver positions.

sv_models.find_sv_states(gps_millis, ephem)[source]

Compute position and velocities for all satellites in ephemeris file given time of clock.

ephem contains broadcast ephemeris parameters (similar in form to GPS broadcast parameters).

Must contain the following rows (description in [1]): * gnss_id * sv_id * gps_week * t_oe * e * omega * Omega_0 * OmegaDot * sqrtA * deltaN * IDOT * i_0 * C_is * C_ic * C_rs * C_rc * C_uc * C_us

Parameters:
  • gps_millis (int) – Time at which measurements are needed, measured in milliseconds since start of GPS epoch [ms].

  • ephem (gnss_lib_py.navdata.navdata.NavData) – NavData instance containing ephemeris parameters of satellites for which states are required.

Returns:

sv_posvel – NavData containing satellite positions, velocities, corresponding time with GNSS ID and SV number.

Return type:

gnss_lib_py.navdata.navdata.NavData

Notes

Based on code written by J. Makela. AE 456, Global Navigation Sat Systems, University of Illinois Urbana-Champaign. Fall 2017

More details on the algorithm used to compute satellite positions from broadcast navigation message can be found in [1].

Satellite velocity calculations based on algorithms introduced in [2].

References

sv_models.find_visible_ephem(gps_millis, rx_ecef, ephem, el_mask=5.0)[source]

Trim input ephemeris to keep only visible SVs.

Parameters:
  • gps_millis (int) – Time at which measurements are needed, measured in milliseconds since start of GPS epoch [ms].

  • rx_ecef (np.ndarray) – 3x1 row rx_pos ECEF position vector [m].

  • ephem (gnss_lib_py.navdata.navdata.NavData) – NavData instance containing satellite ephemeris parameters including gps_week and gps_tow for the ephemeris

  • el_mask (float) – Minimum elevation of satellites considered visible.

Returns:

eph – Ephemeris parameters of visible satellites

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.find_visible_sv_posvel(rx_ecef, sv_posvel, el_mask=5.0)[source]

Trim input SV state NavData to keep only visible SVs.

Parameters:
  • rx_ecef (np.ndarray) – 3x1 row rx_pos ECEF position vector [m].

  • sv_posvel (gnss_lib_py.navdata.navdata.NavData) – NavData instance containing satellite positions and velocities at the time at which visible satellites are needed.

  • el_mask (float) – Minimum elevation of satellites considered visible.

Returns:

vis_posvel – SV states of satellites that are visible

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.single_gnss_from_precise_eph(navdata, sp3_parsed_file, clk_parsed_file, inplace=False, verbose=False)[source]

Compute satellite states using .sp3 and .clk

Either adds or replaces satellite ECEF position data and clock bias for any satellite that exists in the provided sp3 file and clk file.

Parameters:
  • navdata (gnss_lib_py.navdata.navdata.NavData) – Instance of the NavData class that must include rows for gps_millis and gnss_sv_id.

  • sp3_parsed_file (gnss_lib_py.parsers.sp3.Sp3) – SP3 data

  • clk_parsed_file (gnss_lib_py.parsers.clk.Clk) – Clk data

  • inplace (bool) – If true, adds satellite positions and clock bias to the input navdata object, otherwise returns a new NavData object with the satellite rows added.

  • verbose (bool) – Flag (True/False) for whether to print intermediate steps useful for debugging/reviewing (the default is False)

Returns:

navdata – Updated NavData class with satellite information computed using precise ephemerides from .sp3 and .clk files

Return type:

gnss_lib_py.navdata.navdata.NavData

sv_models.svs_from_el_az(elaz_deg)[source]

Generate NED satellite positions for given elevation and azimuth.

Given elevation and azimuth angles, with respect to the receiver, generate satellites in the NED frame of reference with the receiver position as the origin. Satellites are assumed to have a nominal distance of 20,200 km from the receiver (height of GNSS satellite orbit)

Parameters:

elaz_deg (np.ndarray) – Nx2 array of elevation and azimuth angles [degrees]

Returns:

svs_ned – Nx3 satellite NED positions, simulated at a distance of 20,200 km

Return type:

np.ndarray