Welcome to igclib’s documentation

Introduction

igclib is a Python module and a command line tool designed for the analysis of paragliding competitions. Its original purpose is to serve as backend to Task Creator.

Installation

This package will be hosted on PyPI when it reaches its beta version. For the moment, you can install it by downloading the source from GitHub.

git clone https://github.com/teobouvard/igclib.git
cd igclib
make install

Examples

Python Examples

Build a race and save it to disk

from igclib.core.race import Race

r =  Race(tracks='tracks/', task='task.xctsk')
r.save('race.pkl')

Load a race and save it as json

from igclib.core.race import Race

r =  Race(path='race.pkl')
r.save('race.json')

Get a task optimization info and save it as json

from igclib.core.task import Task

t = Task('task.xctsk')
t.save('optimized.json')

Get all available tasks from a provider on standard output

from igclib.crawlers.task_crawler import TaskCrawler

crawler = TaskCrawler(provider='PWCA', year=2015)
crawler.save('-')

Command line Examples

Build a race and save it to disk

igclib race --task task.xctsk --flights tracks_dir/ --output race.pkl

Get a task optimization info in json

igclib optimize --task task.xctsk --progress ratio

Get all available tasks from a provider

igclib crawl --provider PWCA --year 2015

Architecture

Soon

Python API

Race

class igclib.core.race.Race(tracks=None, task=None, validate=True, path=None, progress='gui')[source]

You can create a Race instance in two different ways :

  • Passing a tracks and a task, which creates a new Race object and validates all pilot flights.

    >>> r =  Race(tracks='tracks/', task='task.xctsk')
    
  • Passing a path to a previously saved Race, loading the saved instance (much faster than re-validating flights).

    >>> r =  Race(path='race.pkl')
    
Keyword Arguments:
 
  • tracks (str) – A path to a directory or a zip file containing IGC tracks.
  • task (str) – A path to the task file or a base64 representation of the task.
  • path (str) – The path of a previously saved Race instance.
n_pilots

The number of pilots in the Race.

Type:int
flights

A collection of Flights indexed by pilot ID.

Type:dict [str, Flight]
task

The Task instance of the Race.

Type:Task
get_pilot_features(pilot_id, start=None, stop=None)[source]

Extracts pilot features

Parameters:

pilot_id (str) – The pilot identifier used as key in self.flights

Keyword Arguments:
 
  • start (time, optional) – Lower bound of the retrieved features (default)
  • stop (time, optional) – Upper bound of the retrieved features
Raises:

KeyError – if pilot_id is not a key of self.flights dictionnary

Returns:

The pilot features from start to stop

Return type:

PilotFeatures

parse_flights(tracks)[source]

Populates flights attribute by parsing each igc file in tracks.

Parameters:tracks (str) – Path to a directory or a zip file containing the igc files
pilot_schema(pilot_id, output)[source]

In dev !

Parameters:pilot_id (str) – ID of the pilot being watched
serialize()[source]

Serializes the race object to be written to a JSON file

validate_flights()[source]

Computes the validation of each flight on the race

Flight

class igclib.core.flight.Flight(igc_file)[source]

Class representing a Flight

Task

class igclib.core.task.Task(task)[source]

Creates a Task object. The way this is done is really bad, and any help would be appreciated. As of now, this class checks if the input task (file or b64) “fits” in each parser implemented. When a parser does not raise a KeyError, the task is assumed to be of this format and its attributes are copied back to the Task object. I feel that there is a smarter way to do this, probably with inheritance. However, task format is not known in advance so trying each format seems like the easiest thing to do.

Parameters:task (str) – Path to or base64 representation of a task file.
Raises:NotImplementedError – If the task could not be parsed.

Pilot Features

class igclib.core.pilot_features.GroupRelation(pilot_id, snapshot)[source]

Convention : If a GroupRelation feature is > 0, it means that the original pilot is in a better position than the other pilot in the group. This means that :

  • delta_altitude > 0 : original pilot is higher
  • delta_distance > 0 : original pilot closer to goal
other_pilot_id

A list of IDs pilots being compared

Type:list [str]
delta_altitude

The altitude differences.

Type:list [float]
delta_distance

The goal distances differences.

Type:list [float]
class igclib.core.pilot_features.PilotFeatures(pilot_id, timestamp, snapshot)[source]
pilot_id

The pilot’s ID

Type:str
timestamp

The timestamp associated with the features.

Type:time
position

The current position of the pilot.

Type:GeoPoint
group_relation

The current position of the pilot.

Type:GroupRelation

Geography

This module contains the base classes representing a GeoPoint, a Turnpoint and an Opti. It also provides convenience wrappers around C extension function calls. These wrappers allow for more concise function calls to improve readability.

class igclib.geography.geo.Arc(lat, lon, p1=None, p2=None, radius=None)[source]
class igclib.geography.geo.GeoPoint(lat=None, lon=None, altitude=None, record=None, status=None)[source]
class igclib.geography.geo.Opti(dist, legs, points, angles)[source]
class igclib.geography.geo.Point(*args)[source]
class igclib.geography.geo.Turnpoint(lat, lon, radius=None, altitude=None, name=None, desc=None, role=None, first_tag=None)[source]

Crawlers

Command line manual

Usage

igclib COMMAND [OPTIONS] ARGS

Commands

optimize

    Get the optimized version of a task.
    Required arguments :
        --task
        --output
replay

    Creates a race without validating flights.
    Required arguments :
        --task
        --flights
        --output
race

    Creates a race with validated flights.
    Required arguments :
        --task and --flights or --path
        --output
crawl

    Crawls a provider for all events hosted in the specified year.
    Optional arguments :
        --provider [ PWCA | FFVL ] (defaults to PWCA)
        --year (defaults to current year)
watch

    Get the features of a pilot on a flight.
    Required arguments :
        --path
        --pilot
        --output

Options

--progress [ gui | ratio | silent ] (defaults to gui)

    Defines the way progress is displayed to the user.
    * gui displays a progress bar
    * ratio displays a percentage on each line
    * silent runs quietly

Files specifications

Soon