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 of pandas.DataFrame and stop time information in Trip.stop_times_df, another instance of pandas.DataFrame.

Also stores Vehicle information in Trip.vehicles_df and Service Calendar information in Trip.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.DataFrame with 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_df as the column named Trip.STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIME

add_shape_dist_traveled(stops)

For any trips in Trip.stop_times_df with 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_SEQUENCE and Trip.TRIPS_COLUMN_TRIP_DEPARTURE_TIME to the Trip.trips_df datatable to facilitate stop time updates in Trip.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.DataFrame with 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_HEADWAY

Default headway if no previous matching route/trip

INPUT_STOPTIMES_FILE

INPUT_TRIPS_FILE

INPUT_VEHICLES_FILE

File with fasttrips vehicles information.

OUTPUT_TRIPINFO_FILE

File with trip information

OUTPUT_TRIP_ID_NUM_FILE

File with trip ID, trip ID number correspondence

SERVICE_COLUMN_END_DATE

fasttrips Service column name: End Date as datetime.date

SERVICE_COLUMN_END_DATE_STR

fasttrips Service column name: End Date string in 'YYYYMMDD' format

SERVICE_COLUMN_START_DATE

fasttrips Service column name: Start Date as datetime.date

SERVICE_COLUMN_START_DATE_STR

fasttrips Service column name: Start Date string in 'YYYYMMDD' format

SIM_COL_VEH_ALIGHTS

Result column name: Alights.

SIM_COL_VEH_BOARDS

Result column name: Boards.

SIM_COL_VEH_FRICTION

Result column name: Friction.

SIM_COL_VEH_MSA_ALIGHTS

Result column name: MSA of column SIM_COL_VEH_ALIGHTS.

SIM_COL_VEH_MSA_BOARDS

Result column name: MSA of column SIM_COL_VEH_BOARDS.

SIM_COL_VEH_MSA_FRICTION

Result column name: MSA Friction.

SIM_COL_VEH_MSA_ONBOARD

Result column name: MSA Onboard.

SIM_COL_VEH_MSA_OVERCAP

Result column name: Number of MSA onboard passengers minus capacity.

SIM_COL_VEH_MSA_STANDEES

Result column name: MSA Standeeds.

SIM_COL_VEH_ONBOARD

Result column name: Onboard.

SIM_COL_VEH_OVERCAP

Result column name: Number of onboard passengers minus capacity.

SIM_COL_VEH_OVERCAP_FRAC

Result column name: Percentage of boards that are problematic.

SIM_COL_VEH_STANDEES

Result column name: Standees.

STOPTIMES_COLUMN_ARRIVAL_TIME

gtfs Stop times column name: Arrival time.

STOPTIMES_COLUMN_ARRIVAL_TIME_MIN

Stop times column name: Arrival time.

STOPTIMES_COLUMN_DEPARTURE_TIME

gtfs Stop times column name: Departure time.

STOPTIMES_COLUMN_DEPARTURE_TIME_MIN

Stop times column name: Departure time.

STOPTIMES_COLUMN_DROP_OFF_TYPE

gtfs Stop times stop times column name: Drop Off Type

STOPTIMES_COLUMN_DWELL_TIME

fasttrips Trips column name: Dwell Time.

STOPTIMES_COLUMN_DWELL_TIME_SEC

fasttrips Trips column name: Dwell Time in seconds.

STOPTIMES_COLUMN_HEADSIGN

gtfs Stop times stop times column name: Stop Headsign

STOPTIMES_COLUMN_ORIGINAL_TRAVEL_TIME

fasttrips Trips column name: Original Travel Time.

STOPTIMES_COLUMN_PICKUP_TYPE

gtfs Stop times stop times column name: Pickup Type

STOPTIMES_COLUMN_SHAPE_DIST_TRAVELED

gtfs Stop times stop times column name: Shape Distance Traveled

STOPTIMES_COLUMN_STOP_ID

gtfs Stop times column name: Stop unique identifier

STOPTIMES_COLUMN_STOP_ID_NUM

fasttrips Trips column name: Stop Numerical Identifier.

STOPTIMES_COLUMN_STOP_SEQUENCE

gtfs Stop times column name: Sequence number of stop within a trip.

STOPTIMES_COLUMN_TIMEPOINT

gtfs Stop times stop times column name: Time Point

STOPTIMES_COLUMN_TRAVEL_TIME

fasttrips Trips column name: Travel Time.

STOPTIMES_COLUMN_TRAVEL_TIME_SEC

fasttrips Trips column name: Travel Time in seconds.

STOPTIMES_COLUMN_TRIP_ID

gtfs Stop times column name: Trip unique identifier.

STOPTIMES_COLUMN_TRIP_ID_NUM

fasttrips Trips column name: Trip Numerical Identifier.

TRIPS_COLUMN_DIRECTION_ID

gtfs Trip column name: Direction binary identifier.

TRIPS_COLUMN_MAX_STOP_SEQUENCE

fasttrips Trips column name: Max Stop Sequence number.

TRIPS_COLUMN_MODE_NUM

fasttrips Trips column name: Mode Numerical Identifier.

TRIPS_COLUMN_ROUTE_ID

gtfs Trips column name: Route unique identifier.

TRIPS_COLUMN_ROUTE_ID_NUM

fasttrips Trips column name: Route Numerical Identifier.

TRIPS_COLUMN_SERVICE_ID

gtfs Trips column name: Service unique identifier.

TRIPS_COLUMN_SHAPE_ID

gtfs Trip column name: Shape ID

TRIPS_COLUMN_TRIP_DEPARTURE_TIME

fasttrips Trip column name: Trip departure time (from the first stop).

TRIPS_COLUMN_TRIP_ID

gtfs Trips column name: Unique identifier.

TRIPS_COLUMN_TRIP_ID_NUM

fasttrips Trips column name: Trip Numerical Identifier.

TRIPS_COLUMN_VEHICLE_NAME

fasttrips Trips column name: Vehicle Name

VEHICLES_COLUMN_ACCELERATION

fasttrips Vehicles column name: Acceleration (feet per (second^2)) float.

VEHICLES_COLUMN_BICYCLE_CAPACITY

fasttrips Vehicles column name: Bicycle Capacity

VEHICLES_COLUMN_DECELERATION

fasttrips Vehicles column name: Decelration (feet per (second^2)) float.

VEHICLES_COLUMN_DWELL_FORMULA

fasttrips Vehilces column name: Dwell formula (string)

VEHICLES_COLUMN_MAXIMUM_SPEED

fasttrips Vehicles column name: Maximum Speed (mph)

VEHICLES_COLUMN_MAXIMUM_SPEED_FPS

fasttrips Vehicles column name: Maximum Speed (fps)

VEHICLES_COLUMN_NUMBER_OF_DOORS

fasttrips Vehicles column name: Number of Doors

VEHICLES_COLUMN_PLATFORM_HEIGHT

fasttrips Vehicles column name: Platform Height (inches)

VEHICLES_COLUMN_PROPULSION_TYPE

fasttrips Vehicles column name: Propulsion Type

VEHICLES_COLUMN_SEATED_CAPACITY

fasttrips Vehicles column name: Seated Capacity

VEHICLES_COLUMN_STANDING_CAPACITY

fasttrips Vehicles column name: Standing Capacity

VEHICLES_COLUMN_TOTAL_CAPACITY

fasttrips Trips column name: Vehicle Total (Seated + Standing) Capacity

VEHICLES_COLUMN_VEHICLE_DESCRIPTION

fasttrips Vehicles column name: Vehicle Description

VEHICLES_COLUMN_VEHICLE_LENGTH

fasttrips Vehicles column name: Vehicle Length (feet)

VEHICLES_COLUMN_VEHICLE_NAME

fasttrips Vehicles column name: Vehicle name (identifier)

VEHICLES_COLUMN_WHEELCHAIR_CAPACITY

fasttrips Vehicles column name: Wheelchair Capacity (overrides trip)