suboptimumg.loganalysis.gps#

GPS visualization, trimming, coordinate transforms, and distance computation.

suboptimumg.loganalysis.gps.compute_elapsed_distance(dfs, pos_n_col='posN', pos_e_col='posE', out_col='distance')[source]#

Cumulative arc-length distance from local cartesian position columns.

Parameters:
  • dfs (DataFrame or list[DataFrame])

  • pos_n_col (str) – Local cartesian position column names (must already exist).

  • pos_e_col (str) – Local cartesian position column names (must already exist).

  • out_col (str) – Name of the new distance column.

Return type:

Same type as input, with out_col added.

suboptimumg.loganalysis.gps.gps_to_local_cartesian(dfs, lat_col='pcm.vnav.posLla.latitude', lon_col='pcm.vnav.posLla.longitude', origin=None)[source]#

Equirectangular projection from lat/lon to local North/East (meters).

Adds posN and posE columns. If origin is None, uses the first data point of the first DataFrame as the reference.

Parameters:
  • dfs (DataFrame or list[DataFrame])

  • lat_col (str)

  • lon_col (str)

  • origin ((lat_deg, lon_deg) or None)

Return type:

Same type as input, with posN and posE added.

suboptimumg.loganalysis.gps.plot_gps_trajectory(df, lat_col='pcm.vnav.posLla.latitude', lon_col='pcm.vnav.posLla.longitude', time_col='time_s', color_by='time', max_display_hz=100.0, width=700, height=700)[source]#

Interactive 2D GPS trajectory plot with time-based trim sliders.

Parameters:
  • df (pd.DataFrame)

  • lat_col (str)

  • lon_col (str)

  • time_col (str) – Column used for slider values and colour mapping.

  • color_by (str) – "time" colours by time_col.

  • max_display_hz (float) – Target sample rate for display. Data is naively thinned (every Nth point) to approximately this rate. The source DataFrame is not modified.

  • width (int)

  • height (int)

Returns:

fig is the FigureWidget, widget_box is the VBox with sliders that can be display()-ed.

Return type:

(fig, widget_box)

suboptimumg.loganalysis.gps.prepare_gps_data(df, lat_col='latitude', lon_col='longitude', max_radius_m=5000.0, max_jump_m=30.0)[source]#

Full GPS cleaning pipeline: filter invalid positions, project to local cartesian, and remove spatial outliers.

Steps applied in order:

  1. Drop rows where lat/lon are zero or outside physical range (|lat| > 90 or |lon| > 180).

  2. Equirectangular projection to local East/North meters, with the median lat/lon as origin.

  3. Drop points farther than max_radius_m from the origin (warns if any are removed).

  4. Drop points that jump more than max_jump_m from their predecessor (warns if any are removed).

ZOH deduplication of stale GPS samples should be handled upstream via perda_to_dataframe(deduplicate_vars=...).

Adds posE (East, meters) and posN (North, meters) columns to the returned DataFrame.

Parameters:
  • df (pd.DataFrame) – Must contain lat_col and lon_col columns.

  • lat_col (str) – Column names for latitude and longitude in degrees.

  • lon_col (str) – Column names for latitude and longitude in degrees.

  • max_radius_m (float) – Maximum distance from the median position to keep.

  • max_jump_m (float) – Maximum point-to-point distance to keep.

Returns:

Cleaned copy with posE and posN columns added and invalid rows removed.

Return type:

pd.DataFrame

suboptimumg.loganalysis.gps.resolve_gps_columns(dfs, ins_lat_col='pcm.vnav.posLla.latitude', ins_lon_col='pcm.vnav.posLla.longitude', fix_col='pcm.vnav.gpsFix', out_lat_col='latitude', out_lon_col='longitude')[source]#

Build unified latitude/longitude columns with INS-lock fallback.

The VN-300 INS solution (posLla) reads zero when the INS hasn’t converged. This function creates clean latitude/longitude columns that mask out invalid (zero) samples and, when the INS lock is eventually acquired, use the INS-filtered position.

When fix_col is provided and present in the DataFrame, rows where gpsFix == 0 are also treated as invalid.

Invalid rows are set to NaN so downstream functions can handle them (e.g. drop, interpolate, or skip).

Parameters:
  • dfs (DataFrame or list[DataFrame])

  • ins_lat_col (str) – INS solution position columns (the only position variables in these CAN logs).

  • ins_lon_col (str) – INS solution position columns (the only position variables in these CAN logs).

  • fix_col (str or None) – GPS fix status column. None skips the fix check.

  • out_lat_col (str) – Names for the output columns.

  • out_lon_col (str) – Names for the output columns.

Return type:

Same type as input, with out_lat_col and out_lon_col added.

suboptimumg.loganalysis.gps.trim_dataframe(df, time_col, start_time, end_time)[source]#

Return rows where time_col is between start_time and end_time (inclusive).

Parameters:
  • df (DataFrame)

  • time_col (str)

  • start_time (float)

  • end_time (float)

Return type:

DataFrame