Skip to main content

itinerum-tripkit

Python Version

Documentation for library usage: https://itinerum-tripkit.readthedocs.io/

This library serves as a framework to process data from the Itinerum platform and hardware GPS loggers (e.g., QStarz). It can be used both through as a library in Jupyter to explore datasets interactively or imported as a module in standalone scripts and applications.

This repository also serves as the development bed for the Itinerum platform algorithms within the TRIP Lab repositories.

Want to get up and running quickly? Try the itinerum-tripkit-cli!

Setup

Quickstart

  1. Install this library from PyPI (a Python virtual environment is recommended)
  2. Create a configuration file with input filepaths, output filepaths, and trip processing parameters. See the included tripkit_config.py file for a full example.
  3. Import tripkit as a dependency in a notebook or script

For more complete installation information, see the official itinerum-tripkit documentation.

Loading Subway Stations

Subway station data for trip detection can be loaded similarly for all processing modules. Place a .csv file of station entrances with the columns of x (or longitude) and y (or latitude). Locations are expected as geographic coordinates only. Edit the SUBWAY_STATIONS_FP config parameter to reflect the subway stations .csv filepath.

Example

View attributes on a User

import tripkit_config
itinerum = Itinerum(tripkit_config)

# create a new database and read in .csv data
itinerum.setup()

# load all users from database
users = itinerum.load_all_users()

test_user = users[0]
print(test_user.coordinates)
print(test_user.prompt_responses)

Run trip detection on a User

import tripkit_config
itinerum = Itinerum(tripkit_config)

# load user from database by uuid
user = itinerum.database.load_user('00000000-0000-0000-0000-000000000000')

# run a provided trip detection algorithm
parameters = {
    'subway_entrances': itinerum.database.load_subway_entrances(),
    'break_interval_seconds': tripkit_config.TRIP_DETECTION_BREAK_INTERVAL_SECONDS,
    'subway_buffer_meters': tripkit_config.TRIP_DETECTION_SUBWAY_BUFFER_METERS,
    'cold_start_distance': tripkit_config.TRIP_DETECTION_COLD_START_DISTANCE_METERS,
    'accuracy_cutoff_meters': tripkit_config.TRIP_DETECTION_ACCURACY_CUTOFF_METERS
}
trips = itinerum.process.trip_detection.triplab.v2.algorithm.run(user.coordinates, parameters)

Processing

Trip Detection

Arguments
parameters A dictionary to supply arbitrary kwargs to an algorithm
subway_stations A list of subway station entrance database objects containing latitude and longitude attributes
coordinates A timestamp-ordered list of coordinates as dicts for a specific user. Multiple users should be run in sequence and have their output coordinates concatenated into a single list after if desired.

Trip Outputs

Trips will be output with the following trip codes to indicate the type of trip:

Trip Code Description
1 Complete trip
2 Complete trip - subway
101 Missing trip
102 Missing trip - subway
103 Missing trip - less than 250m
201 Single point
202 Distance too short - less than 250m

Outputs

The aim of this library is to provide easy visualization of Itinerum data to assist in writing trip processing algorthms. Therefore at a minimum, the library provides exporting processed coordinates and traces as .geojson files (TBA: GeoPackage format). With a PostgreSQL backend for caching, PostGIS can be enabled (unimplemented) and a geom column generated for directly connection QGIS to the output data. The library should also easily provide methods for easily plotting GPS within Jupyter notebooks.

Release files for itinerum-tripkit 0.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for itinerum-tripkit 0.0.17
File Size Uploaded
itinerum-tripkit-0.0.17.tar.gz 67.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for itinerum-tripkit 0.0.17
File Interpreter ABI Platform
itinerum_tripkit-0.0.17-py3-none-any.whl Python 3 none any Details

Total release size: 190.5 kB

Release files / itinerum-tripkit-0.0.17.tar.gz

Download URL itinerum-tripkit-0.0.17.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91dc5ee1f258ce619c6961ff9a9039ac63b8db80f02c1e7eef376178ac568e50
BLAKE2b-256 checksum
How to use checksums
85f7ae509cda572972caeca5920d2ad6b005bc458acd23b65e5eefee4ce6e159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / itinerum_tripkit-0.0.17-py3-none-any.whl

Download URL itinerum_tripkit-0.0.17-py3-none-any.whl
Size 123.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6be4670d6c24cf9430b0e8c838d53920221cae33a8fd26df5dd3311cf73afde5
BLAKE2b-256 checksum
How to use checksums
e7812503c12faef3815c9246082ab607cd2991726c6b541c54c46a5cd15acb19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release history Release notifications | RSS feed

0.0.26

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

This release

0.0.17 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page