Log Utilities

Log Directory Helpers

pyflysight.log_utils.classify_log_dir

classify_log_dir(log_dir: Path) -> FlysightType

Identify FlySight hardware revision based on the log directory contents.

It is assumed that the provided log directory contains a single log session; no recursion is performed.

The hueristic used is a simple one: if the directory contains a SENSOR.CSV file then it is assumed to be a FlySight V2 log sesssion, otherwise V1. Trimmed data files, if present, are not considered.

pyflysight.log_utils.locate_log_subdir

locate_log_subdir(top_dir: Path, flysight_type: FlysightType) -> Path

Resolve the child log directory contained under the provided top level directory.

Note

It is assumed that the provided top_dir contains only one valid directory of log files.

Note

Directories containing trimmed V2 log data are currently not considered.

pyflysight.log_utils.LogDir

Bases: NamedTuple

flysight_type instance-attribute

flysight_type: FlysightType

log_dir instance-attribute

log_dir: Path

pyflysight.log_utils.iter_log_dirs

iter_log_dirs(
    top_dir: Path, flysight_type: FlysightType | None = None
) -> abc.Generator[LogDir, None, None]

Iterate through children of the specified top level directory & yield log directories.

A specific FlySight hardware revision can be targeted using the flysight_type argument; if specified as None, both hardware types will be searched for.

Note

Order of yielded directories is not guaranteed.

Note

Directories containing trimmed log data are currently not considered.

Note

FlySight V2 devices may have a root TEMP directory that contains a flight log output, this directory is excluded from being yielded.

Parsed Data Helpers

pyflysight.log_utils.get_idx

get_idx(log_data: polars.DataFrame, query: NUMERIC_T, ref_col: str = 'elapsed_time') -> int

Return the first index of the data in ref_col closest to the provided query value.

pyflysight.log_utils.normalize_gps_location

normalize_gps_location(
    track_data: polars.DataFrame, start_coord: tuple[float, float] = (0, 0)
) -> polars.DataFrame

Shift parsed GPS coordinates so they begin at the provided starting location.

pyflysight.log_utils.normalize_gps_location_plaintext

normalize_gps_location_plaintext(
    track_file: Path,
    flysight_type: FlysightType,
    start_coord: tuple[float, float] = (0, 0),
    inplace: bool = False,
) -> None

Shift plaintext GPS coordinates so they begin at the provided starting location.

If inplace is True, the existing track file will be overwritten. Otherwise, the unmodified track file will be copied to a new TRACK_old.CSV file in the same directory.

Warning

Inplace modification is a destructive operation, all existing data will be lost and cannot be recovered.