Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

March hqta rerun #1056

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions high_quality_transit_areas/A1_rail_ferry_brt_stops.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
ac_transit_route_id = ["1T"]
metro_route_desc = ["METRO SILVER LINE", "METRO ORANGE LINE",
"METRO J LINE", "METRO G LINE"]

muni_route_id = [
'1', '1X', '2',
'8', '8AX', '8BX', '9', '9R',
'12', '14', '14R', '15', '19', '22', '27', '28',
'30', '33', '36', '38', '38R', '45', '49', '55',
'90', '91', '714','TBUS',
]
]

muni_brt_include = pd.read_parquet(
f"{GCS_FILE_PATH}operator_input/muni_brt_stops.parquet"
).stop_id.tolist()

'''
Eric double checked for bus shelters
Expand Down Expand Up @@ -215,14 +220,23 @@ def additional_brt_filtering_out_stops(
df: geopandas.GeoDataFrame
Input BRT stops data (combined across operators)
"""
metro_name = "LA Metro Bus Schedule"
muni_name = "Bay Area 511 Muni Schedule"

muni = df[df.name == muni_name].query(
'stop_id in @muni_brt_include'
)

# For Metro, unable to filter out non-station stops using GTFS, manual list
metro = df[df.name == "LA Metro Bus Schedule"].query(
metro = df[df.name == metro_name].query(
'stop_id not in @metro_j_exclude')

other_operators = df[df.name != "LA Metro Bus Schedule"]
muni_metro = pd.concat([muni, metro], axis=0)

other_operators = df[~df.name.isin([metro_name, muni_name])]

brt_df_stops = pd.concat(
[metro, other_operators], axis=0
[muni_metro, other_operators], axis=0
).sort_values(["feed_key", "name"]).reset_index(drop=True)

return brt_df_stops
Expand Down
2 changes: 1 addition & 1 deletion high_quality_transit_areas/B1_create_hqta_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def select_shapes_and_segment(
gdf = gtfs_schedule_wrangling.longest_shape_by_route_direction(
analysis_date
).query(
'shape_array_key not in @outside_ca_amtrak_shapes'
'shape_array_key not in @outside_amtrak_shapes'
).drop(
columns = ["schedule_gtfs_dataset_key",
"shape_array_key", "route_length"]
Expand Down
7 changes: 6 additions & 1 deletion high_quality_transit_areas/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ hqta_data:
python C3_create_bus_hqta_types.py
python D1_assemble_hqta_points.py
python D2_assemble_hqta_polygons.py


# Only need this is operator input changes
# For now, Muni sent over a date-versioned list of stops
# they want included as BRT
add_operator_input:
python operator_input.py
8 changes: 8 additions & 0 deletions high_quality_transit_areas/logs/hqta_processing.log
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@
2024-03-14 11:56:55.334 | INFO | __main__:<module>:163 - C3_create_bus_hqta_types 2024-03-13 execution time: 0:00:27.390021
2024-03-14 12:12:21.763 | INFO | __main__:<module>:295 - D1_assemble_hqta_points 2024-03-13 execution time: 0:00:26.480160
2024-03-14 12:13:12.687 | INFO | __main__:<module>:167 - D2_assemble_hqta_polygons 2024-03-13 execution time: 0:00:29.033860
2024-03-21 11:54:40.930 | INFO | __main__:<module>:354 - A1_rail_ferry_brt_stops 2024-03-13 execution time: 0:00:51.987419
2024-03-21 12:01:28.365 | INFO | __main__:<module>:249 - B1_create_hqta_segments execution time: 0:03:02.428114
2024-03-21 12:02:23.099 | INFO | __main__:<module>:256 - B2_sjoin_stops_to_segments 2024-03-13 execution time: 0:00:35.845848
2024-03-21 12:02:46.911 | INFO | __main__:<module>:142 - C1_prep_pairwise_intersections 2024-03-13 execution time: 0:00:05.864652
2024-03-21 12:03:24.770 | INFO | __main__:<module>:125 - C2_find_intersections 2024-03-13 execution time: 0:00:21.158652
2024-03-21 12:04:01.449 | INFO | __main__:<module>:163 - C3_create_bus_hqta_types 2024-03-13 execution time: 0:00:19.553787
2024-03-21 12:04:42.807 | INFO | __main__:<module>:295 - D1_assemble_hqta_points 2024-03-13 execution time: 0:00:22.988739
2024-03-21 12:05:20.102 | INFO | __main__:<module>:167 - D2_assemble_hqta_polygons 2024-03-13 execution time: 0:00:19.166756
3 changes: 1 addition & 2 deletions high_quality_transit_areas/muni_brt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
"import pandas as pd\n",
"\n",
"from segment_speed_utils import helpers\n",
"from update_vars import analysis_date\n",
"from utilities import GCS_FILE_PATH\n",
"from update_vars import analysis_date, GCS_FILE_PATH\n",
"\n",
"analysis_date"
]
Expand Down
30 changes: 30 additions & 0 deletions high_quality_transit_areas/operator_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Script to save any custom operator request
to include in our workflow.
For now, this is Muni's list of bus stops to include
as BRT.
Initially, we tagged all of the routes on which
these stops took place, but that flagged over 1_000 stops
as major_stop_brt.
Here, it's just 136 stops.
"""
import pandas as pd

from update_vars import GCS_FILE_PATH

if __name__ == "__main__":
FILE = "SFMTA_muni_high_quality_transit_stops_2024-02-01.csv"

muni_stops = (
pd.read_csv(f"{GCS_FILE_PATH}operator_input/{FILE}",
dtype={"bs_id": "str"})
.drop(columns=["latitude", "longitude"])
.rename(columns={"bs_id": "stop_id"})
)

muni_stops.to_parquet(
f"{GCS_FILE_PATH}operator_input/"
f"muni_brt_stops.parquet"
)

print(f"saved muni stops")
Loading