From 1b7d1e894a0f3a94b09042aaad6276d798d49727 Mon Sep 17 00:00:00 2001 From: Eric Dasmalchi Date: Mon, 4 Nov 2024 23:59:51 +0000 Subject: [PATCH] testing --- ca_transit_speed_maps/01_new_speedmaps.ipynb | 209 +++++++++- .../40_speedmap_scratchpad.ipynb | 375 +----------------- 2 files changed, 202 insertions(+), 382 deletions(-) diff --git a/ca_transit_speed_maps/01_new_speedmaps.ipynb b/ca_transit_speed_maps/01_new_speedmaps.ipynb index a19e03f14..848a7315d 100644 --- a/ca_transit_speed_maps/01_new_speedmaps.ipynb +++ b/ca_transit_speed_maps/01_new_speedmaps.ipynb @@ -407,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 83, "id": "6af2c7fd-b769-4fbf-bbcf-75080972cc67", "metadata": {}, "outputs": [], @@ -417,7 +417,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 84, "id": "cedc030e-8d19-4a0b-b3a5-5a3d6c0dce23", "metadata": {}, "outputs": [], @@ -428,20 +428,180 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 85, "id": "87c7db4f-3da9-4ba4-915b-88432a841b39", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
schedule_gtfs_dataset_keyshape_array_keyshape_idroute_iddirection_idstop_pairstop_pair_namesegment_idtime_of_dayp50_mph...p80_mphnamecaltrans_districtorganization_source_record_idorganization_namebase64_urlgeometryn_trips_schtrips_hr_schroute_short_name
105010666caf3ec1ecc96b74f4477ee4bc939fedc605c108af558e4e545806741ea0f510358_JUNE2451-131830.0283__8824Avalon / Imperial__Avalon / 111th283-8824-1AM Peak12.34...12.34LA Metro Bus Schedule07 - Los AngelesrecPnGkwdpnr8jmHBLos Angeles County Metropolitan Transportation...aHR0cHM6Ly9naXRsYWIuY29tL0xBQ01UQS9ndGZzX2J1cy...POLYGON ((160449.331 -452365.708, 160434.047 -...10.33333351
105020666caf3ec1ecc96b74f4477ee4bc939fedc605c108af558e4e545806741ea0f510358_JUNE2451-131830.08824__8823Avalon / 111th__Avalon / 110th8824-8823-1AM Peak14.66...14.66LA Metro Bus Schedule07 - Los AngelesrecPnGkwdpnr8jmHBLos Angeles County Metropolitan Transportation...aHR0cHM6Ly9naXRsYWIuY29tL0xBQ01UQS9ndGZzX2J1cy...POLYGON ((160443.819 -452040.084, 160428.472 -...10.33333351
\n", + "

2 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " schedule_gtfs_dataset_key shape_array_key \\\n", + "10501 0666caf3ec1ecc96b74f4477ee4bc939 fedc605c108af558e4e545806741ea0f \n", + "10502 0666caf3ec1ecc96b74f4477ee4bc939 fedc605c108af558e4e545806741ea0f \n", + "\n", + " shape_id route_id direction_id stop_pair \\\n", + "10501 510358_JUNE24 51-13183 0.0 283__8824 \n", + "10502 510358_JUNE24 51-13183 0.0 8824__8823 \n", + "\n", + " stop_pair_name segment_id time_of_day p50_mph \\\n", + "10501 Avalon / Imperial__Avalon / 111th 283-8824-1 AM Peak 12.34 \n", + "10502 Avalon / 111th__Avalon / 110th 8824-8823-1 AM Peak 14.66 \n", + "\n", + " ... p80_mph name caltrans_district \\\n", + "10501 ... 12.34 LA Metro Bus Schedule 07 - Los Angeles \n", + "10502 ... 14.66 LA Metro Bus Schedule 07 - Los Angeles \n", + "\n", + " organization_source_record_id \\\n", + "10501 recPnGkwdpnr8jmHB \n", + "10502 recPnGkwdpnr8jmHB \n", + "\n", + " organization_name \\\n", + "10501 Los Angeles County Metropolitan Transportation... \n", + "10502 Los Angeles County Metropolitan Transportation... \n", + "\n", + " base64_url \\\n", + "10501 aHR0cHM6Ly9naXRsYWIuY29tL0xBQ01UQS9ndGZzX2J1cy... \n", + "10502 aHR0cHM6Ly9naXRsYWIuY29tL0xBQ01UQS9ndGZzX2J1cy... \n", + "\n", + " geometry n_trips_sch \\\n", + "10501 POLYGON ((160449.331 -452365.708, 160434.047 -... 1 \n", + "10502 POLYGON ((160443.819 -452040.084, 160428.472 -... 1 \n", + "\n", + " trips_hr_sch route_short_name \n", + "10501 0.333333 51 \n", + "10502 0.333333 51 \n", + "\n", + "[2 rows x 22 columns]" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "peak_test >> head(2)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 86, "id": "e7c32718-4eb2-4c2b-aba0-cca397aaabf3", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['schedule_gtfs_dataset_key', 'shape_array_key', 'shape_id', 'route_id',\n", + " 'direction_id', 'stop_pair', 'stop_pair_name', 'segment_id',\n", + " 'time_of_day', 'p50_mph', 'n_trips', 'p20_mph', 'p80_mph', 'name',\n", + " 'caltrans_district', 'organization_source_record_id',\n", + " 'organization_name', 'base64_url', 'geometry', 'n_trips_sch',\n", + " 'trips_hr_sch', 'route_short_name'],\n", + " dtype='object')" + ] + }, + "execution_count": 86, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "peak_test.columns" ] @@ -456,10 +616,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 87, "id": "10a3ff1d-04f8-40b8-ab91-5ef96fde9b6a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "writing to calitp-map-tiles/testing/182_new.geojson.gz\n" + ] + } + ], "source": [ "speedmap_state = shared_utils.rt_utils.set_state_export(\n", " peak_test, filename=f'{itp_id}_new', map_type='speedmap',\n", @@ -469,10 +637,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 88, "id": "75f2695e-4b80-4d91-8dce-1fa8e347729b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'state_dict': {'name': 'null',\n", + " 'layers': [{'name': 'Speedmap Segs PM Peak 2024-10-16',\n", + " 'url': 'https://storage.googleapis.com/calitp-map-tiles/testing/182_new.geojson.gz',\n", + " 'properties': {'stroked': False,\n", + " 'highlight_saturation_multiplier': 0.5,\n", + " 'tooltip_speed_key': 'p20_mph'},\n", + " 'type': 'speedmap'}],\n", + " 'lat_lon': (34.0539357609537, -118.29997523003668),\n", + " 'zoom': 13,\n", + " 'legend_url': 'https://storage.googleapis.com/calitp-map-tiles/speeds_legend_color_access.svg'},\n", + " 'spa_link': 'https://embeddable-maps.calitp.org/?state=eyJuYW1lIjogIm51bGwiLCAibGF5ZXJzIjogW3sibmFtZSI6ICJTcGVlZG1hcCBTZWdzIFBNIFBlYWsgMjAyNC0xMC0xNiIsICJ1cmwiOiAiaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL2NhbGl0cC1tYXAtdGlsZXMvdGVzdGluZy8xODJfbmV3Lmdlb2pzb24uZ3oiLCAicHJvcGVydGllcyI6IHsic3Ryb2tlZCI6IGZhbHNlLCAiaGlnaGxpZ2h0X3NhdHVyYXRpb25fbXVsdGlwbGllciI6IDAuNSwgInRvb2x0aXBfc3BlZWRfa2V5IjogInAyMF9tcGgifSwgInR5cGUiOiAic3BlZWRtYXAifV0sICJsYXRfbG9uIjogWzM0LjA1MzkzNTc2MDk1MzcsIC0xMTguMjk5OTc1MjMwMDM2NjhdLCAiem9vbSI6IDEzLCAibGVnZW5kX3VybCI6ICJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb20vY2FsaXRwLW1hcC10aWxlcy9zcGVlZHNfbGVnZW5kX2NvbG9yX2FjY2Vzcy5zdmcifQ=='}" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "speedmap_state" ] diff --git a/rt_segment_speeds/40_speedmap_scratchpad.ipynb b/rt_segment_speeds/40_speedmap_scratchpad.ipynb index 63e836a57..f405efc55 100644 --- a/rt_segment_speeds/40_speedmap_scratchpad.ipynb +++ b/rt_segment_speeds/40_speedmap_scratchpad.ipynb @@ -649,378 +649,9 @@ "id": "6a062796-ae2f-4081-b73b-8923c7bd85b2", "metadata": {}, "source": [ - "## Where'd the J line go??" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "1ded1f93-6458-4365-b30b-744417bbf19f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
route_idshape_idtime_of_dayschedule_gtfs_dataset_keyn_tripstrips_hr
16242910-131839100209_JUNE24AM Peak0666caf3ec1ecc96b74f4477ee4bc93972.333333
16243910-131839100209_JUNE24Early AM0666caf3ec1ecc96b74f4477ee4bc93982.666667
16244910-131839100209_JUNE24Midday0666caf3ec1ecc96b74f4477ee4bc939122.400000
16245910-131839100209_JUNE24Owl0666caf3ec1ecc96b74f4477ee4bc93910.250000
16246910-131839100209_JUNE24PM Peak0666caf3ec1ecc96b74f4477ee4bc939153.000000
16247910-131839100210_JUNE24AM Peak0666caf3ec1ecc96b74f4477ee4bc939196.333333
16248910-131839100210_JUNE24Early AM0666caf3ec1ecc96b74f4477ee4bc939186.000000
16249910-131839100210_JUNE24Evening0666caf3ec1ecc96b74f4477ee4bc939112.200000
16250910-131839100210_JUNE24Midday0666caf3ec1ecc96b74f4477ee4bc939214.200000
16251910-131839100210_JUNE24Owl0666caf3ec1ecc96b74f4477ee4bc93941.000000
16252910-131839100210_JUNE24PM Peak0666caf3ec1ecc96b74f4477ee4bc939306.000000
16253910-131839100214_JUNE24AM Peak0666caf3ec1ecc96b74f4477ee4bc939196.333333
16254910-131839100214_JUNE24Early AM0666caf3ec1ecc96b74f4477ee4bc939155.000000
16255910-131839100214_JUNE24Evening0666caf3ec1ecc96b74f4477ee4bc93991.800000
16256910-131839100214_JUNE24Midday0666caf3ec1ecc96b74f4477ee4bc939224.400000
16257910-131839100214_JUNE24Owl0666caf3ec1ecc96b74f4477ee4bc93941.000000
16258910-131839100214_JUNE24PM Peak0666caf3ec1ecc96b74f4477ee4bc939326.400000
16259910-131839100215_JUNE24AM Peak0666caf3ec1ecc96b74f4477ee4bc93972.333333
16260910-131839100215_JUNE24Early AM0666caf3ec1ecc96b74f4477ee4bc93982.666667
16261910-131839100215_JUNE24Evening0666caf3ec1ecc96b74f4477ee4bc93910.200000
16262910-131839100215_JUNE24Midday0666caf3ec1ecc96b74f4477ee4bc939112.200000
16263910-131839100215_JUNE24PM Peak0666caf3ec1ecc96b74f4477ee4bc939112.200000
\n", - "
" - ], - "text/plain": [ - " route_id shape_id time_of_day \\\n", - "16242 910-13183 9100209_JUNE24 AM Peak \n", - "16243 910-13183 9100209_JUNE24 Early AM \n", - "16244 910-13183 9100209_JUNE24 Midday \n", - "16245 910-13183 9100209_JUNE24 Owl \n", - "16246 910-13183 9100209_JUNE24 PM Peak \n", - "16247 910-13183 9100210_JUNE24 AM Peak \n", - "16248 910-13183 9100210_JUNE24 Early AM \n", - "16249 910-13183 9100210_JUNE24 Evening \n", - "16250 910-13183 9100210_JUNE24 Midday \n", - "16251 910-13183 9100210_JUNE24 Owl \n", - "16252 910-13183 9100210_JUNE24 PM Peak \n", - "16253 910-13183 9100214_JUNE24 AM Peak \n", - "16254 910-13183 9100214_JUNE24 Early AM \n", - "16255 910-13183 9100214_JUNE24 Evening \n", - "16256 910-13183 9100214_JUNE24 Midday \n", - "16257 910-13183 9100214_JUNE24 Owl \n", - "16258 910-13183 9100214_JUNE24 PM Peak \n", - "16259 910-13183 9100215_JUNE24 AM Peak \n", - "16260 910-13183 9100215_JUNE24 Early AM \n", - "16261 910-13183 9100215_JUNE24 Evening \n", - "16262 910-13183 9100215_JUNE24 Midday \n", - "16263 910-13183 9100215_JUNE24 PM Peak \n", - "\n", - " schedule_gtfs_dataset_key n_trips trips_hr \n", - "16242 0666caf3ec1ecc96b74f4477ee4bc939 7 2.333333 \n", - "16243 0666caf3ec1ecc96b74f4477ee4bc939 8 2.666667 \n", - "16244 0666caf3ec1ecc96b74f4477ee4bc939 12 2.400000 \n", - "16245 0666caf3ec1ecc96b74f4477ee4bc939 1 0.250000 \n", - "16246 0666caf3ec1ecc96b74f4477ee4bc939 15 3.000000 \n", - "16247 0666caf3ec1ecc96b74f4477ee4bc939 19 6.333333 \n", - "16248 0666caf3ec1ecc96b74f4477ee4bc939 18 6.000000 \n", - "16249 0666caf3ec1ecc96b74f4477ee4bc939 11 2.200000 \n", - "16250 0666caf3ec1ecc96b74f4477ee4bc939 21 4.200000 \n", - "16251 0666caf3ec1ecc96b74f4477ee4bc939 4 1.000000 \n", - "16252 0666caf3ec1ecc96b74f4477ee4bc939 30 6.000000 \n", - "16253 0666caf3ec1ecc96b74f4477ee4bc939 19 6.333333 \n", - "16254 0666caf3ec1ecc96b74f4477ee4bc939 15 5.000000 \n", - "16255 0666caf3ec1ecc96b74f4477ee4bc939 9 1.800000 \n", - "16256 0666caf3ec1ecc96b74f4477ee4bc939 22 4.400000 \n", - "16257 0666caf3ec1ecc96b74f4477ee4bc939 4 1.000000 \n", - "16258 0666caf3ec1ecc96b74f4477ee4bc939 32 6.400000 \n", - "16259 0666caf3ec1ecc96b74f4477ee4bc939 7 2.333333 \n", - "16260 0666caf3ec1ecc96b74f4477ee4bc939 8 2.666667 \n", - "16261 0666caf3ec1ecc96b74f4477ee4bc939 1 0.200000 \n", - "16262 0666caf3ec1ecc96b74f4477ee4bc939 11 2.200000 \n", - "16263 0666caf3ec1ecc96b74f4477ee4bc939 11 2.200000 " - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df >> filter(_.route_id.str.contains('910'))" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "a602c285-26f8-4d1f-8412-dd0437cb7543", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'dir': '${gcs_paths.SEGMENT_GCS}', 'stage1': '${speeds_tables.vp_dwell}', 'proxy_stop_times': 'stop_time_expansion/speedmap_stop_times', 'stage2': 'nearest/nearest_vp_speedmap_proxy', 'stage2b': 'nearest/nearest2_vp_speedmap_proxy', 'stage3': 'speedmap/stop_arrivals_proxy', 'stage3b': 'speedmap/stop_arrivals', 'stage4': 'speedmap/speeds', 'trip_stop_cols': ['trip_instance_key', 'stop_sequence', 'stop_sequence1'], 'shape_stop_cols': ['shape_array_key', 'shape_id'], 'stop_pair_cols': ['stop_pair', 'stop_pair_name', 'segment_id'], 'route_dir_cols': ['route_id', 'direction_id'], 'segments_file': 'segment_options/speedmap_segments', 'shape_stop_single_segment': 'rollup_singleday/speeds_shape_speedmap_segments', 'shape_stop_single_segment_detail': 'rollup_singleday/speeds_shape_speedmap_segments_detail', 'route_dir_single_segment': 'rollup_singleday/speeds_route_dir_speedmap_segments', 'route_dir_multi_segment': 'rollup_multiday/speeds_route_dir_speedmap_segments', 'min_trip_minutes': '${speed_vars.time_min_cutoff}', 'max_trip_minutes': 180, 'max_speed': '${speed_vars.max_speed}', 'min_meters_elapsed': 1609, 'segment_meters': 1000}" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "catalog.speedmap_segments" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "32cf4f45-bf10-4edf-a525-7804ea7ada47", - "metadata": {}, - "outputs": [], - "source": [ - "path = f'{catalog.speedmap_segments.dir}{catalog.speedmap_segments.shape_stop_single_segment_detail}_{analysis_date}.parquet'" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "id": "ad48874e-a6ea-4ee0-8e9d-7eb5f3f0a581", - "metadata": {}, - "outputs": [], - "source": [ - "path = f'{catalog.speedmap_segments.dir}{catalog.speedmap_segments.route_dir_single_segment}_{analysis_date}.parquet'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef401846-f54c-4805-a7aa-53ed1b630837", - "metadata": {}, - "outputs": [], - "source": [ - "speedmap_segs = gpd.read_parquet(path) # aggregated" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ffcec5ce-dcc2-402b-bef0-60f6bd25dd77", - "metadata": {}, - "outputs": [], - "source": [ - "speedmap_segs >> filter(_.route_id.str.contains('910'))" - ] - }, - { - "cell_type": "markdown", - "id": "f919f640-261f-427f-be55-e8b2e4349f12", - "metadata": {}, - "source": [ - "it has no route_short_name...\n", - "```\n", - "857-13183,857,Metro Local Line,C & K LINE LINK,3,,,\n", - "901-13183,,Metro G Line 901,METRO G LINE,3,FC4C02,FFFFFF,https://www.metro.net/g-line/\n", - "910-13183,,Metro J Line 910/950,METRO J LINE,3,ADB8BF,000000,https://www.metro.net/j-line/\n", - "```" + "## Where'd the J line go??\n", + "\n", + "Has no route_short_name, removed that from grouping cols and added at end" ] } ],