diff --git a/_posts/2019-06-16-Graphing-w2a.md b/_posts/2019-06-16-Graphing-w2a.md new file mode 100644 index 0000000..d94cd4f --- /dev/null +++ b/_posts/2019-06-16-Graphing-w2a.md @@ -0,0 +1,62 @@ +--- +layout: post +title: "Graphing the relation between wheels and awards for FRC" +description: "AKA. Why programmer + reddit + matplotlib is a bad idea." +date: 2019-06-16 15:51:00 +categories: frc +--- + +I was scrolling through reddit the other day, and came across [this great post](https://www.reddit.com/r/FRC/comments/byzv5q/i_know_what_im_doing/) by u/[MasterQuacks](https://www.reddit.com/user/MasterQuacks/). + +![My insporation](/assets/images/w2ainspo.jpg) + +I thought to myself "ha. Thats funny", and moved on. But that thought had stuck with me. + +So here I am, bored on a sunday afternoon, staring at the matplotlib documentation. + +## My creation +In only a few lines of python, I have a program that will (badly) graph the number of awards per wheel for any team, or set of teams. + +As always, feel free to tinker with the code. This one is not published anywhere, so if you want to share it, I would appreciate a mention. + +```python +import requests +import matplotlib.pyplot as plt + +class Team: + def __init__(self, id, wheels): + self.id = id + self.wheels = wheels * 2 + +### CONFIG ### + +teams = [Team(5024, 3), Team(254, 4), Team(1114, 3), Team(5406, 3), Team(2056, 4)] +year = 2019 + +############## + + +for i, team in enumerate(teams): + award_data = requests.get("https://www.thebluealliance.com/api/v3/team/frc" + str(team.id) + "/awards/" + str(year), params={"X-TBA-Auth-Key": "mz0VWTNtXTDV8NNOz3dYg9fHOZw8UYek270gynLQ4v9veaaUJEPvJFCZRmte7AUN"}).json() + + awards_count = len(award_data) + + team.w2a = awards_count / team.wheels + print(team.id, team.w2a) + + plt.bar(i + 1, team.w2a, tick_label=str(team.id)) + +# Plot +x_lables = [team.id for team in teams] +# plt.set_xticklabels(x_lables) + +with plt.xkcd(): + plt.title('Awards per wheel') + plt.show() + +``` + +## The result +Here is the resulting image. From left, to right: 5024, 254, 2224, 5406, 2056 + +![Thr result](/assets/images/w2a.png) \ No newline at end of file diff --git a/_site/all_posts.html b/_site/all_posts.html index 9cdf0b0..43d1b5d 100644 --- a/_site/all_posts.html +++ b/_site/all_posts.html @@ -79,6 +79,68 @@
+
+

Graphing the relation between wheels and awards for FRC

+
+ +

2019-06-16 11:51:00 -0400

+

I was scrolling through reddit the other day, and came across this great post by u/MasterQuacks.

+ +

My insporation

+ +

I thought to myself “ha. Thats funny”, and moved on. But that thought had stuck with me.

+ +

So here I am, bored on a sunday afternoon, staring at the matplotlib documentation.

+ +

My creation

+

In only a few lines of python, I have a program that will (badly) graph the number of awards per wheel for any team, or set of teams.

+ +

As always, feel free to tinker with the code. This one is not published anywhere, so if you want to share it, I would appreciate a mention.

+ +
import requests
+import matplotlib.pyplot as plt
+
+class Team:
+    def __init__(self, id, wheels):
+        self.id = id
+        self.wheels = wheels * 2
+
+### CONFIG ###
+
+teams = [Team(5024, 3), Team(254, 4), Team(1114, 3), Team(5406, 3), Team(2056, 4)]
+year = 2019
+
+##############
+
+
+for i, team in enumerate(teams):
+    award_data = requests.get("https://www.thebluealliance.com/api/v3/team/frc" + str(team.id) + "/awards/" + str(year), params={"X-TBA-Auth-Key": "mz0VWTNtXTDV8NNOz3dYg9fHOZw8UYek270gynLQ4v9veaaUJEPvJFCZRmte7AUN"}).json()
+
+    awards_count = len(award_data)
+
+    team.w2a = awards_count / team.wheels
+    print(team.id, team.w2a)
+
+    plt.bar(i + 1, team.w2a, tick_label=str(team.id))
+
+# Plot
+x_lables = [team.id for team in teams]
+# plt.set_xticklabels(x_lables)
+
+with plt.xkcd():
+    plt.title('Awards per wheel')
+    plt.show()
+
+
+ +

The result

+

Here is the resulting image. From left, to right: 5024, 254, 2224, 5406, 2056

+ +

Thr result

+

+ + +

GitHub's CSS is boring. So I refreshed the design

diff --git a/_site/assets/images/w2a.png b/_site/assets/images/w2a.png new file mode 100644 index 0000000..b6df1e5 Binary files /dev/null and b/_site/assets/images/w2a.png differ diff --git a/_site/assets/images/w2ainspo.jpg b/_site/assets/images/w2ainspo.jpg new file mode 100644 index 0000000..7140fa8 Binary files /dev/null and b/_site/assets/images/w2ainspo.jpg differ diff --git a/_site/feed.xml b/_site/feed.xml index 9573c9f..549f59e 100644 --- a/_site/feed.xml +++ b/_site/feed.xml @@ -1,4 +1,56 @@ -Jekyll2019-06-16T14:17:11-04:00http://localhost:4000/feed.xmlEvan PrattenComputer wizard, student, <a href="https://github.com/frc5024">@frc5024</a> programming team lead, and radio enthusiast.GitHub’s CSS is boring. So I refreshed the design2019-06-12T09:09:00-04:002019-06-12T09:09:00-04:00http://localhost:4000/css/2019/06/12/Styiling-GitHub<p>I have been using GitHub since 2017, and have been getting tired of GitHub’s theme. I didn’t need a huge change, just a small refresh. So, to solve this, I whipped out <a href="https://addons.mozilla.org/en-CA/firefox/addon/styl-us/">Stylus</a> and made a nice little CSS file for it.</p> +Jekyll2019-06-16T16:02:06-04:00http://localhost:4000/feed.xmlEvan PrattenComputer wizard, student, <a href="https://github.com/frc5024">@frc5024</a> programming team lead, and radio enthusiast.Graphing the relation between wheels and awards for FRC2019-06-16T11:51:00-04:002019-06-16T11:51:00-04:00http://localhost:4000/frc/2019/06/16/Graphing-w2a<p>I was scrolling through reddit the other day, and came across <a href="https://www.reddit.com/r/FRC/comments/byzv5q/i_know_what_im_doing/">this great post</a> by u/<a href="https://www.reddit.com/user/MasterQuacks/">MasterQuacks</a>.</p> + +<p><img src="/assets/images/w2ainspo.jpg" alt="My insporation" /></p> + +<p>I thought to myself “ha. Thats funny”, and moved on. But that thought had stuck with me.</p> + +<p>So here I am, bored on a sunday afternoon, staring at the matplotlib documentation.</p> + +<h2 id="my-creation">My creation</h2> +<p>In only a few lines of python, I have a program that will (badly) graph the number of awards per wheel for any team, or set of teams.</p> + +<p>As always, feel free to tinker with the code. This one is not published anywhere, so if you want to share it, I would appreciate a mention.</p> + +<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">requests</span> +<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="n">plt</span> + +<span class="k">class</span> <span class="nc">Team</span><span class="p">:</span> + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">id</span><span class="p">,</span> <span class="n">wheels</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="nb">id</span> <span class="o">=</span> <span class="nb">id</span> + <span class="bp">self</span><span class="o">.</span><span class="n">wheels</span> <span class="o">=</span> <span class="n">wheels</span> <span class="o">*</span> <span class="mi">2</span> + +<span class="c1">### CONFIG ### +</span> +<span class="n">teams</span> <span class="o">=</span> <span class="p">[</span><span class="n">Team</span><span class="p">(</span><span class="mi">5024</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">Team</span><span class="p">(</span><span class="mi">254</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="n">Team</span><span class="p">(</span><span class="mi">1114</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">Team</span><span class="p">(</span><span class="mi">5406</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">Team</span><span class="p">(</span><span class="mi">2056</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]</span> +<span class="n">year</span> <span class="o">=</span> <span class="mi">2019</span> + +<span class="c1">############## +</span> + +<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">team</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">teams</span><span class="p">):</span> + <span class="n">award_data</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"https://www.thebluealliance.com/api/v3/team/frc"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">team</span><span class="o">.</span><span class="nb">id</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/awards/"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">year</span><span class="p">),</span> <span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s">"X-TBA-Auth-Key"</span><span class="p">:</span> <span class="s">"mz0VWTNtXTDV8NNOz3dYg9fHOZw8UYek270gynLQ4v9veaaUJEPvJFCZRmte7AUN"</span><span class="p">})</span><span class="o">.</span><span class="n">json</span><span class="p">()</span> + + <span class="n">awards_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">award_data</span><span class="p">)</span> + + <span class="n">team</span><span class="o">.</span><span class="n">w2a</span> <span class="o">=</span> <span class="n">awards_count</span> <span class="o">/</span> <span class="n">team</span><span class="o">.</span><span class="n">wheels</span> + <span class="k">print</span><span class="p">(</span><span class="n">team</span><span class="o">.</span><span class="nb">id</span><span class="p">,</span> <span class="n">team</span><span class="o">.</span><span class="n">w2a</span><span class="p">)</span> + + <span class="n">plt</span><span class="o">.</span><span class="n">bar</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">team</span><span class="o">.</span><span class="n">w2a</span><span class="p">,</span> <span class="n">tick_label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">team</span><span class="o">.</span><span class="nb">id</span><span class="p">))</span> + +<span class="c1"># Plot +</span><span class="n">x_lables</span> <span class="o">=</span> <span class="p">[</span><span class="n">team</span><span class="o">.</span><span class="nb">id</span> <span class="k">for</span> <span class="n">team</span> <span class="ow">in</span> <span class="n">teams</span><span class="p">]</span> +<span class="c1"># plt.set_xticklabels(x_lables) +</span> +<span class="k">with</span> <span class="n">plt</span><span class="o">.</span><span class="n">xkcd</span><span class="p">():</span> + <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s">'Awards per wheel'</span><span class="p">)</span> + <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> + +</code></pre></div></div> + +<h2 id="the-result">The result</h2> +<p>Here is the resulting image. From left, to right: 5024, 254, 2224, 5406, 2056</p> + +<p><img src="/assets/images/w2a.png" alt="Thr result" /></p>I was scrolling through reddit the other day, and came across this great post by u/MasterQuacks.GitHub’s CSS is boring. So I refreshed the design2019-06-12T09:09:00-04:002019-06-12T09:09:00-04:00http://localhost:4000/css/2019/06/12/Styiling-GitHub<p>I have been using GitHub since 2017, and have been getting tired of GitHub’s theme. I didn’t need a huge change, just a small refresh. So, to solve this, I whipped out <a href="https://addons.mozilla.org/en-CA/firefox/addon/styl-us/">Stylus</a> and made a nice little CSS file for it.</p> <h2 id="the-css">The CSS</h2> <p>Here is the CSS. Feel free to play with it.</p> diff --git a/_site/frc/2019/06/16/Graphing-w2a.html b/_site/frc/2019/06/16/Graphing-w2a.html new file mode 100644 index 0000000..b565d29 --- /dev/null +++ b/_site/frc/2019/06/16/Graphing-w2a.html @@ -0,0 +1,178 @@ + + + + + + Evan Pratten + + + + + + + + + + + + +
+ + + + + + + + + +
+ + +
+
+
+

Graphing the relation between wheels and awards for FRC

+
+ +

I was scrolling through reddit the other day, and came across this great post by u/MasterQuacks.

+ +

My insporation

+ +

I thought to myself “ha. Thats funny”, and moved on. But that thought had stuck with me.

+ +

So here I am, bored on a sunday afternoon, staring at the matplotlib documentation.

+ +

My creation

+

In only a few lines of python, I have a program that will (badly) graph the number of awards per wheel for any team, or set of teams.

+ +

As always, feel free to tinker with the code. This one is not published anywhere, so if you want to share it, I would appreciate a mention.

+ +
import requests
+import matplotlib.pyplot as plt
+
+class Team:
+    def __init__(self, id, wheels):
+        self.id = id
+        self.wheels = wheels * 2
+
+### CONFIG ###
+
+teams = [Team(5024, 3), Team(254, 4), Team(1114, 3), Team(5406, 3), Team(2056, 4)]
+year = 2019
+
+##############
+
+
+for i, team in enumerate(teams):
+    award_data = requests.get("https://www.thebluealliance.com/api/v3/team/frc" + str(team.id) + "/awards/" + str(year), params={"X-TBA-Auth-Key": "mz0VWTNtXTDV8NNOz3dYg9fHOZw8UYek270gynLQ4v9veaaUJEPvJFCZRmte7AUN"}).json()
+
+    awards_count = len(award_data)
+
+    team.w2a = awards_count / team.wheels
+    print(team.id, team.w2a)
+
+    plt.bar(i + 1, team.w2a, tick_label=str(team.id))
+
+# Plot
+x_lables = [team.id for team in teams]
+# plt.set_xticklabels(x_lables)
+
+with plt.xkcd():
+    plt.title('Awards per wheel')
+    plt.show()
+
+
+ +

The result

+

Here is the resulting image. From left, to right: 5024, 254, 2224, 5406, 2056

+ +

Thr result

+

+
+
+ +
+ + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/_site/index.html b/_site/index.html index 6165333..a666581 100644 --- a/_site/index.html +++ b/_site/index.html @@ -121,6 +121,18 @@
+ + + +
diff --git a/assets/images/w2a.png b/assets/images/w2a.png new file mode 100644 index 0000000..b6df1e5 Binary files /dev/null and b/assets/images/w2a.png differ diff --git a/assets/images/w2ainspo.jpg b/assets/images/w2ainspo.jpg new file mode 100644 index 0000000..7140fa8 Binary files /dev/null and b/assets/images/w2ainspo.jpg differ