Library Objects¶
User¶
The tripkit.models.User
object provides the representation of a user in a survey with their
associated coordinates, prompt, cancelled prompts and trips (if available in cache).
-
class
tripkit.models.
User
(db_user)¶ Parameters: db_user – The
peewee
survey response for a given user.Variables: - activity_locations (list) – A user’s saved or detected activity locations. This is loaded automatically
when a
User
is initialized bytripkit.database.Database.load_user()
. - trips (list) – A user’s detected trips. This is loaded automatically when a
User
is initialized bytripkit.database.Database.load_user()
.
- activity_locations (list) – A user’s saved or detected activity locations. This is loaded automatically
when a
Trip¶
The tripkit.models.Trip
object provides the representation of a user’s trip with some inferred
properties about it.
-
class
tripkit.models.
Trip
(num, trip_code)¶ Parameters: - num (int) – The integer index (starting at 1) of all the detected trip events (completer or incomplete) as user has made over the duration of their survey participation.
- trip_code (int) – The integer code representing the detected trip type.
Variables: points (list of
tripkit.models.TripPoint
) – The timestamp-ordered points that comprise thisTrip
.
Trip Point¶
The tripkit.models.TripPoint
object provides the respresentation of a user’s GPS coordinates
after having been processed by a trip detection algorithm.
-
class
tripkit.models.
TripPoint
(database_id, latitude, longitude, h_accuracy, distance_before, trip_distance, period_before, timestamp_UTC)¶ Parameters: - database_id (integer) – The GPS point’s original database coordinates record id.
- latitude (float) – The GPS point’s latitude.
- longitude (float) – The GPS point’s longitude.
- h_accuracy (float) – The reported horizontal accuracy of a GPS point.
- distance_before (float) – The distance between this point and point immediately prior in meters.
- trip_distance (float) – The cumulative distance of the current trip so far in meters.
- period_before (integer) – The number of seconds passed since the last recorded point.
- timestamp_UTC (datetime) – The point’s naive datetime localized to UTC.
Variables: timestamp_epoch (int) – The point’s datetime within the UNIX epoch format.
Day Summary¶
The tripkit.models.DaySummary
object provides the representation of complete trip days after
processing a user’s trips by a complete days detection algorithm.
-
class
tripkit.models.
DaySummary
(timezone, date, has_trips, is_complete, start_point, end_point, consecutive_inactive_days, inactivity_streak)¶ Parameters: - timezone (str) – String representation of the timezone as listed in the IANA tz database (e.g., America/Montreal). See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- date (datetime.Date) – The naive date used for determining a complete trip day.
- has_trips (bool) – Boolean value to indicate whether a date contains any trips.
- is_complete (bool) – Boolean value to indicate whether a date with trips is considered complete or not.
- start_point (object) – The database point for the first available GPS coordinate on a localized date.
- end_point (object) – The database point for the last available GPS coordinate on a localized date.
- consecutive_inactive_days (int) – The total number of days in the latest inactivity streak (reset on any complete day).
- inactivity_streak (int) – The longest streak of consecutively inactive days for a user.