Esempio n. 1
0
def quick_and_dirty_schedule_qjump_mapping(path_wmata_schedule_data,
                                           analysis_routes):
    xwalk_seg_pattern_stop_in = tribble_xwalk_seg_pattern_stop_in()
    xwalk_wmata_route_dir_pattern = (wr.read_sched_db_patterns(
        path=path_wmata_schedule_data,
        analysis_routes=analysis_routes)[['direction', 'route',
                                          'pattern']].drop_duplicates())
    xwalk_seg_pattern_stop = (xwalk_seg_pattern_stop_in.merge(
        xwalk_wmata_route_dir_pattern,
        on=['route', 'direction']).reindex(columns=[
            'route', 'pattern', 'direction', 'seg_name_id', 'stop_id',
            'approx_time_qjump'
        ]).assign(approx_time_qjump=lambda df: pd.to_timedelta(
            df.approx_time_qjump, unit="s")))
    del xwalk_seg_pattern_stop_in
    # 2. load segment-pattern crosswalk
    # (could be loaded separately or summarized from above)
    xwalk_seg_pattern = (xwalk_seg_pattern_stop.drop('stop_id',
                                                     1).drop_duplicates())
    return xwalk_seg_pattern
import wmatarawnav as wr

executionTime = str(datetime.now() - begin_time).split('.')[0]
print("Run Time Section 1 Import Libraries and Set Global Parameters : {}".
      format(executionTime))
print("*" * 100)

# 2 Read, analyze and summarize Schedule data
########################################################################################################################
print(
    "Run Section 2: Read, analyze and summarize rawnav, WMATA schedule data..."
)
begin_time = datetime.now()
# Read the Wmata_Schedule data
wmata_schedule_dat = wr.read_sched_db_patterns(path=os.path.join(
    path_source_data, "wmata_schedule_data", "Schedule_082719-201718.mdb"),
                                               analysis_routes=analysis_routes)

wmata_schedule_gdf = (gpd.GeoDataFrame(wmata_schedule_dat,
                                       geometry=gpd.points_from_xy(
                                           wmata_schedule_dat.stop_lon,
                                           wmata_schedule_dat.stop_lat),
                                       crs='EPSG:4326').to_crs(epsg=wmata_crs))

# Make Output Directory
path_stop_summary = os.path.join(path_processed_data, "stop_summary.parquet")
if not os.path.isdir(path_stop_summary):
    os.mkdir(path_stop_summary)

path_stop_index = os.path.join(path_processed_data, "stop_index.parquet")
if not os.path.isdir(path_stop_index):
Esempio n. 3
0
    "H4",
    "EAST",
    "irving_fifteenth_sixteenth_stub",
    2368,
    "H8",
    "EAST",
    "irving_fifteenth_sixteenth_stub",
    2368,
    "W47",
    "EAST",
    "irving_fifteenth_sixteenth_stub",
    2368)

xwalk_wmata_route_dir_pattern = (wr.read_sched_db_patterns(
    path=os.path.join(path_source_data, "wmata_schedule_data",
                      "Schedule_082719-201718.mdb"),
    analysis_routes=analysis_routes).filter(
        items=['direction', 'route', 'pattern']).drop_duplicates())

xwalk_seg_pattern_stop = (xwalk_seg_pattern_stop_in.merge(
    xwalk_wmata_route_dir_pattern, on=['route', 'direction']).drop(
        'direction',
        1).reindex(columns=['route', 'pattern', 'seg_name_id', 'stop_id']))

del xwalk_seg_pattern_stop_in

xwalk_seg_pattern = (xwalk_seg_pattern_stop.drop('stop_id',
                                                 1).drop_duplicates())

# 3. load shapes
# Segments