fasttrips.Stop

class fasttrips.Stop(input_archive, output_dir, gtfs, today)[source]

Bases: object

Stop class.

One instance represents all of the Stops as well as their transfer links.

Stores stop information in Stop.stops_df, an instance of pandas.DataFrame,

__init__(input_archive, output_dir, gtfs, today)[source]

Constructor. Reads 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, gtfs, today) Constructor.
add_daps_tazs_to_stops(dap_df, …) Drive access points (PNR lots, KNR lots, etc) and TAZs are like stops.
add_numeric_stop_id(input_df, id_colname, …) Passing a pandas.DataFrame with a stop ID column called id_colname, adds the numeric stop id as a column named numeric_newcolname and returns it.
add_numeric_stop_zone_id(input_df, …[, …]) Passing a pandas.DataFrame with a stop zone ID column called id_colname, adds the numeric stop zone id as a column named numeric_newcolname and returns it.
add_stop_id_for_numeric_id(input_df, …) Passing a pandas.DataFrame with a stop ID num column called numeric_id, adds the string stop id as a column named id_colname and returns it.
add_stop_lat_lon(input_df, id_colname, …) Passing a pandas.DataFrame with a stop ID column called id_colname, adds the stop latitude and longitude as columns named new_lat_colname and new_lon_colname and returns it.
add_stop_zone_id(input_df, id_colname, …) Passing a pandas.DataFrame with a stop ID column called id_colname, adds the stop zone id as a column named zone_colname and returns it.
add_trips(stop_times_df) Add myself to the given trip.
get_transfers(stop_id, xfer_from)
get_trips_arriving_within_time(stop_id, …) Return list of [(trip_id, sequence, arrival_time)] where the arrival time is before latest_arrival but within time_window.
get_trips_departing_within_time(stop_id, …) Return list of [(trip_id, sequence, departure_time)] where the departure time is after earliest_departure but within time_window.
is_transfer(stop_id, xfer_from) Returns true iff this is a transfer stop; e.g.
stop_min_max_lat_lon() Returns (min_stop_lat, max_stop_lat,

Attributes

INPUT_STOPS_FILE File with fasttrips stop information (this extends the gtfs stops file).See stops_ft specification..
OUTPUT_STOP_ID_NUM_FILE File with stop ID, stop ID number correspondence
STOPS_COLUMN_BIKE_PARKING fasttrips Stops column name: Bike Parking
STOPS_COLUMN_BIKE_SHARE_STATION fasttrips Stops column name: Bike Share Station
STOPS_COLUMN_LEVEL fasttrips Stops column name: Level
STOPS_COLUMN_LIGHTING fasttrips Stops column name: Lighting
STOPS_COLUMN_OFF_BOARD_PAYMENT fasttrips Stops column name: Off-Board Payment
STOPS_COLUMN_PLATFORM_HEIGHT fasttrips Stops column name: Platform Height
STOPS_COLUMN_SEATING fasttrips Stops column name: Seating
STOPS_COLUMN_SHELTER fasttrips Stops column name: Shelter
STOPS_COLUMN_STOP_ID gtfs Stops column name: Unique identifier (object)
STOPS_COLUMN_STOP_ID_NUM fasttrips Stops column name: Stop Numerical Identifier.
STOPS_COLUMN_STOP_LATITUDE gtfs Stops column name: Latitude
STOPS_COLUMN_STOP_LONGITUDE gtfs Stops column name: Longitude
STOPS_COLUMN_STOP_NAME gtfs Stops column name: Stop name (string)
STOPS_COLUMN_ZONE_ID gtfs Stops column name: Zone ID
STOPS_COLUMN_ZONE_ID_NUM fasttrips Stops column name: Zone Numerical Identifier.
add_daps_tazs_to_stops(dap_df, dap_id_colname, taz_df, taz_id_colname)[source]

Drive access points (PNR lots, KNR lots, etc) and TAZs are like stops. Add the DAPs and TAZs to our stop list and their numbering in the Stop.stop_id_df.

Pass in dataframes with JUST an ID column.

This method will also update the Stop.transfers_df with Stop IDs since this is now possible since DAPs needed to be numbered for this to work.

add_numeric_stop_id(input_df, id_colname, numeric_newcolname, warn=False, warn_msg=None, drop_failures=True)[source]

Passing a pandas.DataFrame with a stop ID column called id_colname, adds the numeric stop id as a column named numeric_newcolname and returns it.

add_numeric_stop_zone_id(input_df, id_colname, numeric_newcolname, warn=False, warn_msg=None)[source]

Passing a pandas.DataFrame with a stop zone ID column called id_colname, adds the numeric stop zone id as a column named numeric_newcolname and returns it.

add_stop_id_for_numeric_id(input_df, numeric_id, id_colname)[source]

Passing a pandas.DataFrame with a stop ID num column called numeric_id, adds the string stop id as a column named id_colname and returns it.

add_stop_lat_lon(input_df, id_colname, new_lat_colname, new_lon_colname, new_stop_name_colname=None)[source]

Passing a pandas.DataFrame with a stop ID column called id_colname, adds the stop latitude and longitude as columns named new_lat_colname and new_lon_colname and returns it.

Pass new_stop_name_colname to also get the stop name.

add_stop_zone_id(input_df, id_colname, zone_colname)[source]

Passing a pandas.DataFrame with a stop ID column called id_colname, adds the stop zone id as a column named zone_colname and returns it.

If no zone_ids specified, this is a no-op.

add_trips(stop_times_df)[source]

Add myself to the given trip.

Parameters:stop_times_df (a pandas.DataFrame instance) – The Trip.stop_times_df table
get_transfers(stop_id, xfer_from)[source]
get_trips_arriving_within_time(stop_id, latest_arrival, time_window)[source]

Return list of [(trip_id, sequence, arrival_time)] where the arrival time is before latest_arrival but within time_window.

Parameters:
  • latest_arrival (a datetime.time instance) – The latest time the transit vehicle can arrive.
  • time_window (a datetime.timedelta instance) – The time window extending before latest_arrival within which an arrival is valid.
get_trips_departing_within_time(stop_id, earliest_departure, time_window)[source]

Return list of [(trip_id, sequence, departure_time)] where the departure time is after earliest_departure but within time_window.

Parameters:
  • earliest_departure (a datetime.time instance) – The earliest time the transit vehicle can depart.
  • time_window (a datetime.timedelta instance) – The time window extending after earliest_departure within which a departure is valid.
is_transfer(stop_id, xfer_from)[source]

Returns true iff this is a transfer stop; e.g. if it’s served by multiple routes or has a transfer link.

stop_min_max_lat_lon()[source]
Returns (min_stop_lat, max_stop_lat,
min_stop_lon, max_stop_lon)
INPUT_STOPS_FILE = 'stops_ft.txt'

File with fasttrips stop information (this extends the gtfs stops file). See stops_ft specification.

OUTPUT_STOP_ID_NUM_FILE = 'ft_intermediate_stop_id.txt'

File with stop ID, stop ID number correspondence

STOPS_COLUMN_BIKE_PARKING = 'bike_parking'

fasttrips Stops column name: Bike Parking

STOPS_COLUMN_BIKE_SHARE_STATION = 'bike_share_station'

fasttrips Stops column name: Bike Share Station

STOPS_COLUMN_LEVEL = 'level'

fasttrips Stops column name: Level

STOPS_COLUMN_LIGHTING = 'lighting'

fasttrips Stops column name: Lighting

STOPS_COLUMN_OFF_BOARD_PAYMENT = 'off_board_payment'

fasttrips Stops column name: Off-Board Payment

STOPS_COLUMN_PLATFORM_HEIGHT = 'platform_height'

fasttrips Stops column name: Platform Height

STOPS_COLUMN_SEATING = 'seating'

fasttrips Stops column name: Seating

STOPS_COLUMN_SHELTER = 'shelter'

fasttrips Stops column name: Shelter

STOPS_COLUMN_STOP_ID = 'stop_id'

gtfs Stops column name: Unique identifier (object)

STOPS_COLUMN_STOP_ID_NUM = 'stop_id_num'

fasttrips Stops column name: Stop Numerical Identifier. Int.

STOPS_COLUMN_STOP_LATITUDE = 'stop_lat'

gtfs Stops column name: Latitude

STOPS_COLUMN_STOP_LONGITUDE = 'stop_lon'

gtfs Stops column name: Longitude

STOPS_COLUMN_STOP_NAME = 'stop_name'

gtfs Stops column name: Stop name (string)

STOPS_COLUMN_ZONE_ID = 'zone_id'

gtfs Stops column name: Zone ID

STOPS_COLUMN_ZONE_ID_NUM = 'zone_id_num'

fasttrips Stops column name: Zone Numerical Identifier. Int.

max_stop_id_num = None

Note the max stop ID num in Stop.max_stop_id_num.

trip_times_df = None

Trips table.