Package: itinerum-tripkit
itinerum-tripkitDocumentation 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.Looking to get started without coding? Try theitinerum-tripkit-cli!SetupQuickstartInstall this library from PyPI (a Pythonvirtual environmentis recommended)Create a configuration file with input filepaths, output filepaths, and trip processing parameters. See the includedtripkit_config.pyfile for a full example.Importtripkitas a dependency in a notebook or scriptFor more complete installation information, see the officialitinerum-tripkit documentation.Loading Subway StationsSubway station data for trip detection can be loaded similarly for all processing modules. Place a.csvfile of station entrances with the columns ofx(orlongitude) andy(orlatitude). Locations are expected as geographic coordinates only. Edit theSUBWAY_STATIONS_FPconfig parameter to reflect the subway stations.csvfilepath.ExampleView attributes on a Userimporttripkit_configitinerum=Itinerum(tripkit_config)# create a new database and read in .csv dataitinerum.setup()# load all users from databaseusers=itinerum.load_all_users()test_user=users[0]print(test_user.coordinates)print(test_user.prompt_responses)Run trip detection on a Userimporttripkit_configitinerum=Itinerum(tripkit_config)# load user from database by uuiduser=itinerum.database.load_user('00000000-0000-0000-0000-000000000000')# run a provided trip detection algorithmparameters={'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)ProcessingTrip DetectionArgumentsparametersA dictionary to supply arbitrary kwargs to an algorithmsubway_stationsA list of subway station entrance database objects containinglatitudeandlongitudeattributescoordinatesA 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 OutputsTrips will be output with the following trip codes to indicate the type of trip:Trip CodeDescription1Complete trip2Complete trip - subway101Missing trip102Missing trip - subway103Missing trip - less than 250m201Single point202Distance too short - less than 250mOutputsThe 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 ageomcolumn generated for directly connection QGIS to the output data. The library should also easily provide methods for easily plotting GPS within Jupyter notebooks.