Add files via upload
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -19,6 +19,7 @@
|
||||
"source": [
|
||||
"from IPython.core.display import HTML\n",
|
||||
"from typing import Iterator, Tuple, List, Dict\n",
|
||||
"import matplotlib\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
@@ -159,9 +160,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.rcParams[\"figure.figsize\"] = (10, 6)\n",
|
||||
"\n",
|
||||
"def show(X, Y, xlabel='Segment Grade (percent)', ylabel='Speed (mph)', degrees=(2, 3)): \n",
|
||||
" \"\"\"Plot X versus Y and a best fit curve to it, with some bells and whistles.\"\"\"\n",
|
||||
" plt.rcParams[\"figure.figsize\"] = (9, 6)\n",
|
||||
" grid(); plt.ylabel(ylabel); plt.xlabel(xlabel)\n",
|
||||
" plt.scatter(X, Y, c='grey', marker='+')\n",
|
||||
" X1 = np.linspace(min(X), max(X), 100)\n",
|
||||
@@ -185,6 +187,532 @@
|
||||
" return 60 * dist / mph(climb / dist)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Strava Data\n",
|
||||
"\n",
|
||||
"Here is my raw data from Strava, for rides and segments:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>date</th>\n",
|
||||
" <th>title</th>\n",
|
||||
" <th>hours</th>\n",
|
||||
" <th>miles</th>\n",
|
||||
" <th>feet</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>Sun, 2/7/2021</td>\n",
|
||||
" <td>Saratoga / Campbell</td>\n",
|
||||
" <td>5.8925</td>\n",
|
||||
" <td>78.38</td>\n",
|
||||
" <td>2270.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>Fri, 1/8/2021</td>\n",
|
||||
" <td>Coyote Hills Geocaching</td>\n",
|
||||
" <td>4.9689</td>\n",
|
||||
" <td>69.08</td>\n",
|
||||
" <td>797.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>Sun, 10/11/2020</td>\n",
|
||||
" <td>Los Altos Hills Paths</td>\n",
|
||||
" <td>5.8247</td>\n",
|
||||
" <td>65.03</td>\n",
|
||||
" <td>1870.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>Mon, 10/5/2020</td>\n",
|
||||
" <td>Half way around the bay on bay trail</td>\n",
|
||||
" <td>6.4431</td>\n",
|
||||
" <td>80.05</td>\n",
|
||||
" <td>541.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>Tue, 9/29/2020</td>\n",
|
||||
" <td>Saratoga Geocaching</td>\n",
|
||||
" <td>4.9722</td>\n",
|
||||
" <td>64.30</td>\n",
|
||||
" <td>961.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>474</th>\n",
|
||||
" <td>Sat, 3/19/2016</td>\n",
|
||||
" <td>Morning Ride</td>\n",
|
||||
" <td>1.4667</td>\n",
|
||||
" <td>24.00</td>\n",
|
||||
" <td>1125.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>475</th>\n",
|
||||
" <td>Sat, 7/13/2013</td>\n",
|
||||
" <td>Doug's Event</td>\n",
|
||||
" <td>1.8653</td>\n",
|
||||
" <td>21.35</td>\n",
|
||||
" <td>1677.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>476</th>\n",
|
||||
" <td>Sun, 8/4/2013</td>\n",
|
||||
" <td>Kris's first trike ride</td>\n",
|
||||
" <td>1.8558</td>\n",
|
||||
" <td>20.96</td>\n",
|
||||
" <td>988.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>477</th>\n",
|
||||
" <td>Sun, 11/24/2013</td>\n",
|
||||
" <td>Alpine Rd</td>\n",
|
||||
" <td>1.7100</td>\n",
|
||||
" <td>21.02</td>\n",
|
||||
" <td>1289.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>478</th>\n",
|
||||
" <td>Fri, 11/29/2013</td>\n",
|
||||
" <td>Woodside Loop</td>\n",
|
||||
" <td>1.5600</td>\n",
|
||||
" <td>22.75</td>\n",
|
||||
" <td>1011.0</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>479 rows × 5 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" date title hours miles \\\n",
|
||||
"0 Sun, 2/7/2021 Saratoga / Campbell 5.8925 78.38 \n",
|
||||
"1 Fri, 1/8/2021 Coyote Hills Geocaching 4.9689 69.08 \n",
|
||||
"2 Sun, 10/11/2020 Los Altos Hills Paths 5.8247 65.03 \n",
|
||||
"3 Mon, 10/5/2020 Half way around the bay on bay trail 6.4431 80.05 \n",
|
||||
"4 Tue, 9/29/2020 Saratoga Geocaching 4.9722 64.30 \n",
|
||||
".. ... ... ... ... \n",
|
||||
"474 Sat, 3/19/2016 Morning Ride 1.4667 24.00 \n",
|
||||
"475 Sat, 7/13/2013 Doug's Event 1.8653 21.35 \n",
|
||||
"476 Sun, 8/4/2013 Kris's first trike ride 1.8558 20.96 \n",
|
||||
"477 Sun, 11/24/2013 Alpine Rd 1.7100 21.02 \n",
|
||||
"478 Fri, 11/29/2013 Woodside Loop 1.5600 22.75 \n",
|
||||
"\n",
|
||||
" feet \n",
|
||||
"0 2270.0 \n",
|
||||
"1 797.0 \n",
|
||||
"2 1870.0 \n",
|
||||
"3 541.0 \n",
|
||||
"4 961.0 \n",
|
||||
".. ... \n",
|
||||
"474 1125.0 \n",
|
||||
"475 1677.0 \n",
|
||||
"476 988.0 \n",
|
||||
"477 1289.0 \n",
|
||||
"478 1011.0 \n",
|
||||
"\n",
|
||||
"[479 rows x 5 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rides"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>hours</th>\n",
|
||||
" <th>miles</th>\n",
|
||||
" <th>feet</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>count</th>\n",
|
||||
" <td>479.000000</td>\n",
|
||||
" <td>479.000000</td>\n",
|
||||
" <td>479.000000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>mean</th>\n",
|
||||
" <td>3.090990</td>\n",
|
||||
" <td>39.931900</td>\n",
|
||||
" <td>1632.755741</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>std</th>\n",
|
||||
" <td>1.294152</td>\n",
|
||||
" <td>15.772976</td>\n",
|
||||
" <td>1345.854656</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>min</th>\n",
|
||||
" <td>1.466700</td>\n",
|
||||
" <td>20.960000</td>\n",
|
||||
" <td>68.000000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>25%</th>\n",
|
||||
" <td>2.129850</td>\n",
|
||||
" <td>27.980000</td>\n",
|
||||
" <td>657.500000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>50%</th>\n",
|
||||
" <td>2.666900</td>\n",
|
||||
" <td>34.280000</td>\n",
|
||||
" <td>1286.000000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>75%</th>\n",
|
||||
" <td>3.616350</td>\n",
|
||||
" <td>45.180000</td>\n",
|
||||
" <td>2088.500000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>max</th>\n",
|
||||
" <td>8.137500</td>\n",
|
||||
" <td>101.000000</td>\n",
|
||||
" <td>7644.000000</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" hours miles feet\n",
|
||||
"count 479.000000 479.000000 479.000000\n",
|
||||
"mean 3.090990 39.931900 1632.755741\n",
|
||||
"std 1.294152 15.772976 1345.854656\n",
|
||||
"min 1.466700 20.960000 68.000000\n",
|
||||
"25% 2.129850 27.980000 657.500000\n",
|
||||
"50% 2.666900 34.280000 1286.000000\n",
|
||||
"75% 3.616350 45.180000 2088.500000\n",
|
||||
"max 8.137500 101.000000 7644.000000"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rides.describe()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>title</th>\n",
|
||||
" <th>miles</th>\n",
|
||||
" <th>feet</th>\n",
|
||||
" <th>hours</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>Alma Mountain Charlie</td>\n",
|
||||
" <td>3.12</td>\n",
|
||||
" <td>875.0</td>\n",
|
||||
" <td>0.5303</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>Alpine Westridge</td>\n",
|
||||
" <td>0.76</td>\n",
|
||||
" <td>99.0</td>\n",
|
||||
" <td>0.0572</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>Alpine Westridge</td>\n",
|
||||
" <td>0.76</td>\n",
|
||||
" <td>99.0</td>\n",
|
||||
" <td>0.0581</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>Alpine Westridge</td>\n",
|
||||
" <td>0.76</td>\n",
|
||||
" <td>99.0</td>\n",
|
||||
" <td>0.0619</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>Alpine last kicker</td>\n",
|
||||
" <td>0.39</td>\n",
|
||||
" <td>114.0</td>\n",
|
||||
" <td>0.0531</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>129</th>\n",
|
||||
" <td>Westridge Hill 2</td>\n",
|
||||
" <td>0.51</td>\n",
|
||||
" <td>166.0</td>\n",
|
||||
" <td>0.0861</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>130</th>\n",
|
||||
" <td>Westridge Hill 2</td>\n",
|
||||
" <td>0.51</td>\n",
|
||||
" <td>166.0</td>\n",
|
||||
" <td>0.0889</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>131</th>\n",
|
||||
" <td>Woodside Climb</td>\n",
|
||||
" <td>1.71</td>\n",
|
||||
" <td>295.0</td>\n",
|
||||
" <td>0.1347</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>132</th>\n",
|
||||
" <td>Woodside Climb</td>\n",
|
||||
" <td>1.71</td>\n",
|
||||
" <td>295.0</td>\n",
|
||||
" <td>0.1500</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>133</th>\n",
|
||||
" <td>Woodside Climb</td>\n",
|
||||
" <td>1.71</td>\n",
|
||||
" <td>295.0</td>\n",
|
||||
" <td>0.1597</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>134 rows × 4 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" title miles feet hours\n",
|
||||
"0 Alma Mountain Charlie 3.12 875.0 0.5303\n",
|
||||
"1 Alpine Westridge 0.76 99.0 0.0572\n",
|
||||
"2 Alpine Westridge 0.76 99.0 0.0581\n",
|
||||
"3 Alpine Westridge 0.76 99.0 0.0619\n",
|
||||
"4 Alpine last kicker 0.39 114.0 0.0531\n",
|
||||
".. ... ... ... ...\n",
|
||||
"129 Westridge Hill 2 0.51 166.0 0.0861\n",
|
||||
"130 Westridge Hill 2 0.51 166.0 0.0889\n",
|
||||
"131 Woodside Climb 1.71 295.0 0.1347\n",
|
||||
"132 Woodside Climb 1.71 295.0 0.1500\n",
|
||||
"133 Woodside Climb 1.71 295.0 0.1597\n",
|
||||
"\n",
|
||||
"[134 rows x 4 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"segments"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>miles</th>\n",
|
||||
" <th>feet</th>\n",
|
||||
" <th>hours</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>count</th>\n",
|
||||
" <td>134.000000</td>\n",
|
||||
" <td>134.000000</td>\n",
|
||||
" <td>134.000000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>mean</th>\n",
|
||||
" <td>0.927761</td>\n",
|
||||
" <td>264.037313</td>\n",
|
||||
" <td>0.141800</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>std</th>\n",
|
||||
" <td>0.631672</td>\n",
|
||||
" <td>223.422436</td>\n",
|
||||
" <td>0.113192</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>min</th>\n",
|
||||
" <td>0.170000</td>\n",
|
||||
" <td>35.000000</td>\n",
|
||||
" <td>0.026700</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>25%</th>\n",
|
||||
" <td>0.470000</td>\n",
|
||||
" <td>122.000000</td>\n",
|
||||
" <td>0.066450</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>50%</th>\n",
|
||||
" <td>0.760000</td>\n",
|
||||
" <td>193.000000</td>\n",
|
||||
" <td>0.109000</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>75%</th>\n",
|
||||
" <td>1.215000</td>\n",
|
||||
" <td>322.000000</td>\n",
|
||||
" <td>0.169200</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>max</th>\n",
|
||||
" <td>3.120000</td>\n",
|
||||
" <td>1255.000000</td>\n",
|
||||
" <td>0.612200</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" miles feet hours\n",
|
||||
"count 134.000000 134.000000 134.000000\n",
|
||||
"mean 0.927761 264.037313 0.141800\n",
|
||||
"std 0.631672 223.422436 0.113192\n",
|
||||
"min 0.170000 35.000000 0.026700\n",
|
||||
"25% 0.470000 122.000000 0.066450\n",
|
||||
"50% 0.760000 193.000000 0.109000\n",
|
||||
"75% 1.215000 322.000000 0.169200\n",
|
||||
"max 3.120000 1255.000000 0.612200"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"segments.describe()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -200,7 +728,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -209,7 +737,8 @@
|
||||
" def __str__(self): return f'{(self - 1) // 12}-{self % 12 or 12:02d}'\n",
|
||||
"\n",
|
||||
"start = Month(2020 * 12 + 7) # Starting month: July 2020\n",
|
||||
"dates = [Month(start + i) for i in range(7)]\n",
|
||||
"dates = [Month(start + i) for i in range(8)]\n",
|
||||
"bonuses = (25, 90, 99)\n",
|
||||
"\n",
|
||||
"Entry = Tuple[str, float, List[float]] # (Place_Name, miles_of_roads, [pct_by_month,...])\n",
|
||||
"\n",
|
||||
@@ -220,17 +749,24 @@
|
||||
" for (place, miles, pcts), marker in zip(entries, '^v><osdhxDHPX*1234'):\n",
|
||||
" X = [dates[i] for i in range(D) if pcts[i]]\n",
|
||||
" Y = [pcts[i] for i in range(D) if pcts[i]]\n",
|
||||
" L = f'{pcts[-1]}% {place} ({rounded(miles * pcts[-1] / 100)}/{rounded(miles)} mi)'\n",
|
||||
" ax.plot(X, Y, ':', marker=marker, label=L)\n",
|
||||
" ax.plot(X, Y, ':', marker=marker, label=label(pcts, place, miles))\n",
|
||||
" all_pcts = [p for _, _, pcts in entries for p in pcts if p]\n",
|
||||
" for p in (25, 90): # Bonus Points (also, 50, 75, 99)\n",
|
||||
" for p in bonuses: \n",
|
||||
" if min(all_pcts) < p < max(all_pcts):\n",
|
||||
" ax.plot(dates, [p] * D, 'k:', lw=1, alpha=3/4) # Plot bonus line\n",
|
||||
" ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), shadow=True)\n",
|
||||
" ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), shadow=True,\n",
|
||||
" prop=matplotlib.font_manager.FontProperties(family='monospace'))\n",
|
||||
" plt.xticks(dates, [str(d) for d in dates], rotation=90)\n",
|
||||
" plt.ylabel('Percent of Area Ridden')\n",
|
||||
" plt.title(category); plt.tight_layout(); grid(axis='y'); plt.show()\n",
|
||||
" \n",
|
||||
"def label(pcts, place, miles) -> str:\n",
|
||||
" pct = f'{rounded(pcts[-1]):>3}' if pcts[-1] > 1 else f'{pcts[-1]}'\n",
|
||||
" done = miles * pcts[-1]\n",
|
||||
" bonus = next((f' {rounded((p - pcts[-1]) / 100 * miles):>3} to {p}%' \n",
|
||||
" for p in bonuses if p >= pcts[-1]), '')\n",
|
||||
" return f'{pct}% ({rounded(done / 100):>3}/{rounded(miles):>3} mi){bonus} {place}'\n",
|
||||
" \n",
|
||||
"def parse_places(lines) -> Dict[str, List[Entry]]:\n",
|
||||
" \"Parse bikeplaces.txt into a dict of {'Title': [entry,...]}\"\n",
|
||||
" places = {}\n",
|
||||
@@ -249,6 +785,8 @@
|
||||
" \n",
|
||||
"def parse_entry(line: str, dates=dates) -> Entry:\n",
|
||||
" \"\"\"Parse line => ('Place Name', miles, [percents]); '=' can be used.\"\"\"\n",
|
||||
" if line.count(':') != 2:\n",
|
||||
" print('bad', line)\n",
|
||||
" place, miles, pcts = line.replace('|', ' ').split(':')\n",
|
||||
" pcts = re.sub('( [0-9.]+)[*]([0-9]+)', lambda m: m.group(1) * int(m.group(2)),\n",
|
||||
" pcts).split()\n",
|
||||
@@ -267,7 +805,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
||||
@@ -1,63 +1,94 @@
|
||||
:Around 90%:
|
||||
Los Altos: 138: 40.2 43.7 72.4 77.2 84.5 90.8 | 91.0
|
||||
Atherton: 56.8: 0*4 91.2 94.0 | 95.2
|
||||
East Palo Alto: 46.5: 74.4 91.2 91.9*2 92.2 93.3 | 93.4
|
||||
Menlo Park: 131.5: 67.7 76.8 87.7 90.7 91.2 90.1 | 92.5
|
||||
North Fair Oaks: 27: 48.1 90.4 93.1 93.8 94.8 96.1 | 96.9
|
||||
Mountain View: 205: 53.0 59.9 63.0 63.6 72.9 77.1 | 91.1
|
||||
Palo Alto: 292: 63.0 73.6 85.4 85.7 87.1 87.6 | 88.1
|
||||
Los Altos: 138: 40.2 43.7 72.4 77.2 84.5 90.8 | 91.0*2
|
||||
Atherton: 56.8: 0*4 91.2 94.0 | 95.2*2
|
||||
East Palo Alto: 46.5: 74.4 91.2 91.9*2 92.2 93.3 | 93.4*2
|
||||
Emerald Lake Hills: 24.8: 0.0 94.3*3 44.7 51.0 | 80.0 85.8
|
||||
Menlo Park: 131.5: 67.7 76.8 87.7 90.7 91.2 90.1 | 92.5*2
|
||||
North Fair Oaks: 27: 48.1 90.4 93.1 93.8 94.8 96.1 | 96.9*2
|
||||
Mountain View: 205: 53.0 59.9 63.0 63.6 72.9 77.1 | 91.1*2
|
||||
Palo Alto: 292: 63.0 73.6 85.4 85.7 87.1 87.6 | 88.1*2
|
||||
|
||||
:Around 50%:
|
||||
Burlingame: 88.4: 9.4*6 | 9.4 31.5
|
||||
Los Altos Hills: 91: 48.4*2 49.0 55.1*2 55.4 | 55.8*2
|
||||
Monte Sereno: 20.4: 20.5*6 | 20.5 39.8
|
||||
Portola Valley: 59: 0*4 57.3 59.8 | 59.8*2
|
||||
Redwood City: 241: 34.0 39.1 46.0 51.6 56.9 60.8 | 62.9*2
|
||||
San Carlos: 99: 22.2 26.0 32.9 32.9 37.2 39.0 | 40.5*2
|
||||
Woodside: 77: 51.9*2 52.3*3 54.0 | 54*2
|
||||
|
||||
:Around 25%:
|
||||
Cupertino: 172: 22.1 23.9 26.2*3 26.3 | 26.4
|
||||
Saratoga: 180: 14.5 15.7 17.4*4 | 17.4
|
||||
Sunnyvale: 357: 19.4 19.9 22.2*4 | 25.1
|
||||
Belmont: 98: 15.5 17.3 18.6 18.6 20.6 20.6 | 27.4
|
||||
Newark: 145: 15*3 17*3 | 18.7
|
||||
|
||||
:In Between 25% and 90%:
|
||||
Los Altos Hills: 91: 48.4*2 49.0 55.1*2 55.4 | 55.8
|
||||
Portola Valley: 59: 0*4 57.3 59.8 | 59.8
|
||||
Redwood City: 241: 34.0 39.1 46.0 51.6 56.9 60.8 | 62.9
|
||||
San Carlos: 99: 22.2 26.0 32.9 32.9 37.2 39.0 | 40.5
|
||||
Woodside: 77: 51.9*2 52.3*3 54.0 | 54
|
||||
Belmont: 98: 15.5 17.3 18.6 18.6 20.6*2 | 27.4*2
|
||||
Bodega Bay: 28.9: 18*6 | 18*2
|
||||
Campbell: 119: 8.9 10.1 12.4*4 | 12.4 25.2
|
||||
Cupertino: 172: 22.1 23.9 26.2*3 26.3 | 26.4*2
|
||||
Guerniville: 22.7: 23.4*6 | 23.4*2
|
||||
Healdsburg: 53.7: 18.5*6 | 18.5*2
|
||||
Foster City: 150: 9.1*6 | 9.1 27.4
|
||||
Hillsborough: 85.3: 3.3*6 | 3.6 24.5
|
||||
Los Gatos: 148: 7.5 8.6 8.8*4 | 8.8 26.1
|
||||
Millbrae: 65: 0*6 | 0 18.4
|
||||
Newark: 145: 15*3 17*3 | 18.7 26.8
|
||||
San Mateo: 256: 11.1*6 | 11.3 25.5
|
||||
Saratoga: 180: 14.5 15.7 17.4*4 | 17.4 26.9
|
||||
Sunnyvale: 357: 19.4 19.9 22.2*4 | 25.1*2
|
||||
Union City: 207: 7*3 8*3 | 8.8 14.51
|
||||
|
||||
:Just Getting Started:
|
||||
Campbell: 119: 8.9 10.1 12.4*4 | 12.4
|
||||
Los Gatos: 148: 7.5 8.6 8.8*4 | 8.8
|
||||
Milpitas: 224: 2.2*4 4.4*2 | 4.4
|
||||
San Jose: 2543: 1.3 1.36 5.3*4 | 5.3
|
||||
Santa Clara: 348: 6.4*2 9.6*4 | 9.6
|
||||
Foster City: 150: 9.1*6 | 9.1
|
||||
San Mateo: 412: 11.1*6 | 11.3
|
||||
Berkeley: 260: 5.0*3 7.0*3 | 7.0
|
||||
Fremont: 771: 9*3 10*3 | 11.7
|
||||
Union City: 207: 7*3 8*3 | 8.8
|
||||
Milpitas: 224: 2.2*4 4.4*2 | 4.4*2
|
||||
San Jose: 2543: 1.3 1.36 5.3*4 | 5.4*2
|
||||
Santa Clara: 348: 6.4*2 9.6*4 | 9.6*2
|
||||
Berkeley: 260: 5.0*3 7.0*3 | 7.0*2
|
||||
Fremont: 771: 9*3 10*3 | 11.7*2
|
||||
Cambridge: 180.8: 6.4*6 | 6.4*2
|
||||
|
||||
:Small Neighborhoods (under 25 road miles):
|
||||
Emerald Lake Hills: 24.8: 0.0 94.3*3 44.7 51.0 | 80.0
|
||||
Kensington Square: 0.6: 86.9 99.4 100*4 | 100
|
||||
Ladera: 8.0: 0*4 30.5 29.8 | 29.8
|
||||
Loyola: 18.3: 0*4 60.8 62.1 | 62.1
|
||||
Los Trancos Woods: 5.4: 0*4 71.4*2 | 71.4
|
||||
Menlo Oaks: 3.6: 0*4 98.4 99.7 | 99.7
|
||||
Monte Sereno: 20.4: 20.5*6 | 20.5
|
||||
Palomar Park: 3.9: 0*6 | 91.1
|
||||
San Mateo Highlands: 18: 0*6 | 18.0
|
||||
Sequoia Tract: 11.9: 0*4 72.8 82.3 | 92.5
|
||||
Sky Londa: 11.8: 0*4 72.1*2 | 73.2
|
||||
West Menlo Park: 11: 0*4 97.5 98.1 | 98.1
|
||||
:Small Neighborhoods (under 20 road miles):
|
||||
Burlingame Hills: 6: 0*6 | 0.8 34.5
|
||||
Kensington Square: 0.6: 86.9 100*5 | 100*2
|
||||
Ladera: 8.0: 0*4 30.5 29.8 | 29.8*2
|
||||
Loyola: 18.3: 0*4 60.8 62.1 | 62.1*2
|
||||
Los Trancos Woods: 5.4: 0*4 71.4*2 | 71.4*2
|
||||
Menlo Oaks: 3.6: 0*4 98.4 99.7 | 99.7*2
|
||||
Muir Beach: 4.6: 0*6 | 35.8*2
|
||||
Palomar Park: 3.9: 0*6 | 91.1*2
|
||||
San Mateo Highlands: 18: 0*6 | 18.0 29.2
|
||||
Sequoia Tract: 11.9: 0*4 72.8 82.3 | 92.5*2
|
||||
Stinson Beach: 11.2: 0*6 | 9.2*2
|
||||
Sky Londa: 11.8: 0*4 72.1*2 | 73.2*2
|
||||
West Menlo Park: 11: 0*4 97.5 98.1 | 98.1*2
|
||||
Mokelumne Hill: 14.7: 28.9*6 | 28.9*2
|
||||
MIT, Cambridge: 9.6: 37.2*6 | 37.2*2
|
||||
|
||||
:Large Places (over 300,000 road miles):
|
||||
California: 365188: .712 .811 .846 .867 .8875 .8873 | .9054
|
||||
USA: 6317607: .048 .052 .055 .05589 .0571 .05749 | .05853
|
||||
Earth: 38609276: .008 .0089 .0091 .00936 .009535 .009426| .009597
|
||||
:San Francisco Neighborhoods:
|
||||
Balboa Terrace: 3.4: 0*6 | 18.2*2
|
||||
Cole Valley: 1.7: 0*6 | 19.6*2
|
||||
Forest Hill: 6.1: 0*6 | 15.7*2
|
||||
Golden Gate Park: 40.5: 0*6 | 25.8*2
|
||||
Lincoln Park: 3.8: 0*6 | 42.4*2
|
||||
Pacific Heights: 18: 0*6 | 10.8*2
|
||||
Ashbury Heights: 3.7: 0*6 | 12.9*2
|
||||
Clarendon Heights: 6: 0*6 | 14.3*2
|
||||
Cow Hollow: 12: 0*6 |5*2
|
||||
Financial District: 9.4: 0*6 |5.8*2
|
||||
Golden Gate Heights: 17.8: 0*6 | 10.7*2
|
||||
Polk Gulch: 4: 0*6 | 18.2*2
|
||||
Presidio Heights: 6.5: 0*6 | 15.1*2
|
||||
Presidio Park: 43.1: 0*6 | 21.1*2
|
||||
Presidio Terrace: 2.7: 0*6 | 37.7*2
|
||||
Seacliff: 4.1: 0*6 | 23.1*2
|
||||
South Beach: 4.8: 0*6 | 28.2*2
|
||||
|
||||
:California Counties:
|
||||
San Mateo: 3248: 20.1 21.2 22.9 23.4 24.57 25.53 | 26.43
|
||||
Santa Clara: 7396: 12.7 13.6 15.4 15.6 16.04 16.29 | 16.78
|
||||
Alameda: 5704: 3.3*3 3.94*3 | 3.97
|
||||
Marin: 2322: 6.7*6 | 6.7
|
||||
Napa: 1524: 5.1*6 | 5.1
|
||||
Sonoma: 4556: 5.1*6 | 5.1
|
||||
San Francisco: 1183: 4.5*6 | 4.5
|
||||
Santa Cruz: 2767: 2.3*6 | 2.3
|
||||
San Mateo: 3248: 20.1 21.2 22.9 23.4 24.57 25.53 | 26.43 30.0
|
||||
Santa Clara: 7396: 12.7 13.6 15.4 15.6 16.04 16.29 | 16.78 17.73
|
||||
Alameda: 5704: 3.3*3 3.94*3 | 3.97*2
|
||||
Marin: 2322: 6.7*6 | 6.7*2
|
||||
Napa: 1524: 5.1*6 | 5.1*2
|
||||
Sonoma: 4556: 5.1*6 | 5.1*2
|
||||
San Francisco: 1183: 4.5*6 | 4.5*2
|
||||
Santa Cruz: 2767: 2.3*6 | 2.3*2
|
||||
|
||||
:Large Places (over 300,000 road miles):
|
||||
California: 365188: .712 .811 .846 .867 .8875 .8873 | .9054 .9624
|
||||
USA: 6317607: .048 .052 .055 .05589 .0571 .05749 | .05853 .06183
|
||||
Earth: 38609276: .008 .0089 .0091 .00936 .009535 .009426| .009597 .010136
|
||||
|
||||
Reference in New Issue
Block a user