fasttrips.Trip
- class fasttrips.Trip(input_archive, output_dir, gtfs_feed, today, stops, routes, prepend_route_id_to_trip_id)[source]
Trip class.
One instance represents all of the transit vehicle trips.
Stores Trip information in
Trip.trips_df, an instance ofpandas.DataFrameand stop time information inTrip.stop_times_df, another instance ofpandas.DataFrame.Also stores Vehicle information in
Trip.vehicles_dfand Service Calendar information inTrip.service_df- __init__(input_archive, output_dir, gtfs_feed, today, stops, routes, prepend_route_id_to_trip_id)[source]
Constructor. Read the gtfs data from the transitfeed schedule, and the additional fast-trips stops data from the input files in input_archive.
Methods
__init__(input_archive, output_dir, ...)Constructor.
add_numeric_trip_id(input_df, id_colname, ...)Passing a
pandas.DataFramewith a trip ID column called id_colname, adds the numeric trip id as a column named numeric_newcolname and returns it.add_original_travel_time_and_dwell()Add original travel time to the
Trip.stop_times_dfas the column namedTrip.STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIMEadd_shape_dist_traveled(stops)For any trips in
Trip.stop_times_dfwith rows that are missing column shape_dist_traveled, this method will fill in the column from the stop longitude & latitude.add_trip_attrs_from_stoptimes()Adds the columns
Trip.TRIPS_COLUMN_MAX_STOP_SEQUENCEandTrip.TRIPS_COLUMN_TRIP_DEPARTURE_TIMEto theTrip.trips_dfdatatable to facilitate stop time updates inTrip.update_trip_times()calculate_headways(trips_df)Calculates headways and sets them into the given trips_df
pandas.DataFrame.get_full_trips()Returns the fullest dataframe of trip + stop information.
get_scheduled_departure(trip_id, stop_id)Return the scheduled departure time for the given stop as a datetime.datetime
get_stop_times(trip_id)Returns
pandas.DataFramewith stop times for the given trip id.has_capacity_configured()Returns true if seated capacity and standing capacity are columns included in the vehicles input.
linkify_vehicle_trips(veh_trips_df, stops)Given a vehicle trips table with columns:
number_of_stops(trip_id)Return the number of stops in this trip.
reset_onboard(df)Resets the onboard fields for the given vehicle trip table.
update_trip_times(trips_df, MSA_RESULTS)Updates trip times for stops with boards and/or alights.
write_trips_for_extension()This writes to an intermediate file a formatted file for the C++ extension.
Attributes
DEFAULT_HEADWAYDefault headway if no previous matching route/trip
INPUT_STOPTIMES_FILEINPUT_TRIPS_FILEINPUT_VEHICLES_FILEFile with fasttrips vehicles information.
OUTPUT_TRIPINFO_FILEFile with trip information
OUTPUT_TRIP_ID_NUM_FILEFile with trip ID, trip ID number correspondence
SERVICE_COLUMN_END_DATEfasttrips Service column name: End Date as datetime.date
SERVICE_COLUMN_END_DATE_STRfasttrips Service column name: End Date string in 'YYYYMMDD' format
SERVICE_COLUMN_START_DATEfasttrips Service column name: Start Date as datetime.date
SERVICE_COLUMN_START_DATE_STRfasttrips Service column name: Start Date string in 'YYYYMMDD' format
SIM_COL_VEH_ALIGHTSResult column name: Alights.
SIM_COL_VEH_BOARDSResult column name: Boards.
SIM_COL_VEH_FRICTIONResult column name: Friction.
SIM_COL_VEH_MSA_ALIGHTSResult column name: MSA of column
SIM_COL_VEH_ALIGHTS.SIM_COL_VEH_MSA_BOARDSResult column name: MSA of column
SIM_COL_VEH_BOARDS.SIM_COL_VEH_MSA_FRICTIONResult column name: MSA Friction.
SIM_COL_VEH_MSA_ONBOARDResult column name: MSA Onboard.
SIM_COL_VEH_MSA_OVERCAPResult column name: Number of MSA onboard passengers minus capacity.
SIM_COL_VEH_MSA_STANDEESResult column name: MSA Standeeds.
SIM_COL_VEH_ONBOARDResult column name: Onboard.
SIM_COL_VEH_OVERCAPResult column name: Number of onboard passengers minus capacity.
SIM_COL_VEH_OVERCAP_FRACResult column name: Percentage of boards that are problematic.
SIM_COL_VEH_STANDEESResult column name: Standees.
STOPTIMES_COLUMN_ARRIVAL_TIMEgtfs Stop times column name: Arrival time.
STOPTIMES_COLUMN_ARRIVAL_TIME_MINStop times column name: Arrival time.
STOPTIMES_COLUMN_DEPARTURE_TIMEgtfs Stop times column name: Departure time.
STOPTIMES_COLUMN_DEPARTURE_TIME_MINStop times column name: Departure time.
STOPTIMES_COLUMN_DROP_OFF_TYPEgtfs Stop times stop times column name: Drop Off Type
STOPTIMES_COLUMN_DWELL_TIMEfasttrips Trips column name: Dwell Time.
STOPTIMES_COLUMN_DWELL_TIME_SECfasttrips Trips column name: Dwell Time in seconds.
STOPTIMES_COLUMN_HEADSIGNgtfs Stop times stop times column name: Stop Headsign
STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIMEfasttrips Trips column name: Original Travel Time.
STOPTIMES_COLUMN_PICKUP_TYPEgtfs Stop times stop times column name: Pickup Type
STOPTIMES_COLUMN_SHAPE_DIST_TRAVELEDgtfs Stop times stop times column name: Shape Distance Traveled
STOPTIMES_COLUMN_STOP_IDgtfs Stop times column name: Stop unique identifier
STOPTIMES_COLUMN_STOP_ID_NUMfasttrips Trips column name: Stop Numerical Identifier.
STOPTIMES_COLUMN_STOP_SEQUENCEgtfs Stop times column name: Sequence number of stop within a trip.
STOPTIMES_COLUMN_TIMEPOINTgtfs Stop times stop times column name: Time Point
STOPTIMES_COLUMN_TRAVEL_TIMEfasttrips Trips column name: Travel Time.
STOPTIMES_COLUMN_TRAVEL_TIME_SECfasttrips Trips column name: Travel Time in seconds.
STOPTIMES_COLUMN_TRIP_IDgtfs Stop times column name: Trip unique identifier.
STOPTIMES_COLUMN_TRIP_ID_NUMfasttrips Trips column name: Trip Numerical Identifier.
TRIPS_COLUMN_DIRECTION_IDgtfs Trip column name: Direction binary identifier.
TRIPS_COLUMN_MAX_STOP_SEQUENCEfasttrips Trips column name: Max Stop Sequence number.
TRIPS_COLUMN_MODE_NUMfasttrips Trips column name: Mode Numerical Identifier.
TRIPS_COLUMN_ROUTE_IDgtfs Trips column name: Route unique identifier.
TRIPS_COLUMN_ROUTE_ID_NUMfasttrips Trips column name: Route Numerical Identifier.
TRIPS_COLUMN_SERVICE_IDgtfs Trips column name: Service unique identifier.
TRIPS_COLUMN_SHAPE_IDgtfs Trip column name: Shape ID
TRIPS_COLUMN_TRIP_DEPARTURE_TIMEfasttrips Trip column name: Trip departure time (from the first stop).
TRIPS_COLUMN_TRIP_IDgtfs Trips column name: Unique identifier.
TRIPS_COLUMN_TRIP_ID_NUMfasttrips Trips column name: Trip Numerical Identifier.
TRIPS_COLUMN_VEHICLE_NAMEfasttrips Trips column name: Vehicle Name
VEHICLES_COLUMN_ACCELERATIONfasttrips Vehicles column name: Acceleration (feet per (second^2)) float.
VEHICLES_COLUMN_BICYCLE_CAPACITYfasttrips Vehicles column name: Bicycle Capacity
VEHICLES_COLUMN_DECELERATIONfasttrips Vehicles column name: Decelration (feet per (second^2)) float.
VEHICLES_COLUMN_DWELL_FORMULAfasttrips Vehilces column name: Dwell formula (string)
VEHICLES_COLUMN_MAXIMUM_SPEEDfasttrips Vehicles column name: Maximum Speed (mph)
VEHICLES_COLUMN_MAXIMUM_SPEED_FPSfasttrips Vehicles column name: Maximum Speed (fps)
VEHICLES_COLUMN_NUMBER_OF_DOORSfasttrips Vehicles column name: Number of Doors
VEHICLES_COLUMN_PLATFORM_HEIGHTfasttrips Vehicles column name: Platform Height (inches)
VEHICLES_COLUMN_PROPULSION_TYPEfasttrips Vehicles column name: Propulsion Type
VEHICLES_COLUMN_SEATED_CAPACITYfasttrips Vehicles column name: Seated Capacity
VEHICLES_COLUMN_STANDING_CAPACITYfasttrips Vehicles column name: Standing Capacity
VEHICLES_COLUMN_TOTAL_CAPACITYfasttrips Trips column name: Vehicle Total (Seated + Standing) Capacity
VEHICLES_COLUMN_VEHICLE_DESCRIPTIONfasttrips Vehicles column name: Vehicle Description
VEHICLES_COLUMN_VEHICLE_LENGTHfasttrips Vehicles column name: Vehicle Length (feet)
VEHICLES_COLUMN_VEHICLE_NAMEfasttrips Vehicles column name: Vehicle name (identifier)
VEHICLES_COLUMN_WHEELCHAIR_CAPACITYfasttrips Vehicles column name: Wheelchair Capacity (overrides trip)