<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>OUseful.Info, the blog... &#187; F1 Data Junkie &#8211; Looking at What&#8217;s There</title>
	<atom:link href="http://blog.ouseful.info/2010/03/21/f1-data-junkie-looking-at-whats-there/feed/?withoutcomments=1" rel="self" type="application/rss+xml" />
	<link>http://blog.ouseful.info</link>
	<description>Trying to find useful things to do with emerging technologies in open education</description>
	<lastBuildDate>Thu, 23 May 2013 03:14:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.ouseful.info' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>OUseful.Info, the blog... &#187; F1 Data Junkie &#8211; Looking at What&#8217;s There</title>
		<link>http://blog.ouseful.info</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.ouseful.info/osd.xml" title="OUseful.Info, the blog..." />
	<atom:link rel='hub' href='http://blog.ouseful.info/?pushpress=hub'/>
		<item>
		<title>F1 Data Junkie &#8211; Looking at What&#8217;s There</title>
		<link>http://blog.ouseful.info/2010/03/21/f1-data-junkie-looking-at-whats-there/</link>
		<comments>http://blog.ouseful.info/2010/03/21/f1-data-junkie-looking-at-whats-there/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 10:44:26 +0000</pubDate>
		<dc:creator>Tony Hirst</dc:creator>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[Tinkering]]></category>
		<category><![CDATA[Uncourse]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[f1data]]></category>

		<guid isPermaLink="false">http://ouseful.wordpress.com/?p=3104</guid>
		<description><![CDATA[&#8230;and by looking, I mean looking at what&#8217;s there as raw data structure format and content, rather than looking at what stories a visual data analysis reveals, I&#8217;m afraid&#8230; (that&#8217;ll come later:-) But if you do need something visual to inspire you, here&#8217;s a tease of what the data from a single lap of Hamilton&#8217;s [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=3104&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&#8230;and by <em>looking</em>, I mean looking at what&#8217;s there as raw data structure format and content, rather than looking at what stories a visual data analysis reveals, I&#8217;m afraid&#8230; (that&#8217;ll come later:-) But if you do need something visual to inspire you, here&#8217;s a tease of what the data from a single lap of Hamilton&#8217;s race day tour of the Bahrain 2010 F1 Grand Prix looks like:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4448390997/" title="Hamilton - single lap data from bahrain by psychemedia, on Flickr"><img src="http://farm5.static.flickr.com/4047/4448390997_7524a6b1f6.jpg" width="480" height="500" alt="Hamilton - single lap data from bahrain" /></a></p>
<p>In his book <a href="http://www.amazon.co.uk/Visualizing-Data-Explaining-Processing-Environment/dp/0596514557?tag=ouseful-21">Visualising Data: Exploring and Explaining Data with the Processing Environment</a>, Ben Fry describes a seven stage process for understanding data:</p>
<blockquote><p><em>Acquire</em><br />
Obtain the data, whether from a file on disk or a source over a network.<br />
<em>Parse</em><br />
Provide some structure for the data&#8217;s meaning, and order it into categories.<br />
<em>Filter</em><br />
Remove all but the data of interest.<br />
<em>Mine</em><br />
Apply methods from statistics or data mining as a way to discern patterns or place the data in a mathematical context.<br />
<em>Represent</em><br />
Choose a basic visual model, such as a bar graph, list or tree.<br />
<em>Refine</em><br />
Improve the basic representation to make it clearer and more visually engaging.<br />
<em>Interact</em><br />
Add methods for manipulating the data or controlling what features are visible.</p></blockquote>
<p>I&#8217;m not sure I&#8217;d agree with the elements above defining a rigid <em>linear</em> process</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4450321980/" title="Photo Sharing"><img src="http://farm3.static.flickr.com/2732/4450321980_efa4714cd4.jpg" width="500" height="42"></a><br />
<em>(Produced using Graphviz; <a href="http://gist.github.com/339172">dot file</a>)</em></p>
<p>I prefer to think of the way I work as something like this:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4450349446/" title="Photo Sharing"><img src="http://farm5.static.flickr.com/4065/4450349446_3e40653317.jpg" width="500" height="481"></a><br />
<em>(Produced using Graphviz; <a href="http://gist.github.com/339182">dot file</a>)</em></p>
<p>but what is clear is that we need to understand what data is available to us.</p>
<p>As I mentioned in <a href="http://ouseful.wordpress.com/2010/03/19/f1-data-junkie-getting-started/">F1 Data Junkie – Getting Started</a>, the data I&#8217;m going to be playing with (at least at first) is data grabbed from the <a href="http://mclaren.com/home">Mclaren F1 Live Dashboard</a> (as developed by <a href="http://www.work-club.com/index.php/page/portfolio/28">Work Club</a>) so let&#8217;s have a look at it&#8230; (I&#8217;ll come back to how the data was <em>acquired</em> in a later post.)</p>
<p>The data &#8211; which I think is updated on the server at a rate of once per second (maybe someone form Work Club could confirm that?) &#8211; is published as JSON (Javascript Object Notation) data in a callback function (so it uses what is referred to as the <a href="http://en.wikipedia.org/wiki/JSONP#JSONP">JSON-P</a> (&#8220;JSON with Padding&#8221;) convention. What this means is that the dashboard web page can call the server and get a some data back in such a way that as soon as the data is loaded into the page, a Javascript programme function can run using the data that has just been downloaded).</p>
<p>Here&#8217;s what the data as grabbed from the server looks like:</p>
<pre class="brush: jscript; title: ; notranslate">Dashboard.jsonCallback('{
 &quot;drivers&quot;:{
  &quot;HAM&quot;:{
   &quot;code&quot;:&quot;HAM&quot;,
   &quot;telemetry&quot; {
    &quot;timestamp&quot;:&quot;15:40:58.383&quot;,
    &quot;nEngine&quot;:13920,
    &quot;NGear&quot;:2,
    &quot;rThrottlePedal&quot;:68,
    &quot;pBrakeF&quot;:2,
    &quot;gLat&quot;:1,
    &quot;gLong&quot;:1,
    &quot;sLap&quot;:3116,
    &quot;vCar&quot;:96.9,
    &quot;NGPSLatitude&quot;:26.03185,
    &quot;NGPSLongitude&quot;:50.51304
   },
   &quot;additional&quot;:{
    &quot;lap&quot;:&quot;17&quot;,
    &quot;position&quot;:&quot;5&quot;,
    &quot;is_racing&quot;:&quot;1&quot;
   }
  },
  &quot;BUT&quot;:{&quot;code&quot;:&quot;BUT&quot;,&quot;telemetry&quot;:{&quot;timestamp&quot;:&quot;15:40:58.790&quot;,&quot;nEngine&quot;:13106,&quot;NGear&quot;:3,&quot;rThrottlePedal&quot;:49,&quot;pBrakeF&quot;:2,&quot;gLat&quot;:2,&quot;gLong&quot;:0,&quot;sLap&quot;:2681,&quot;vCar&quot;:140.2,&quot;NGPSLatitude&quot;:26.0333,&quot;NGPSLongitude&quot;:50.51635},&quot;additional&quot;:{&quot;lap&quot;:&quot;17&quot;,&quot;position&quot;:&quot;8&quot;,&quot;is_racing&quot;:&quot;1&quot;}}},
  &quot;commentary&quot;:[
   {
    &quot;name&quot;:&quot;COM&quot;,
    &quot;initials&quot;:&quot;CM&quot;,
    &quot;text&quot;:&quot;Lewis sets the fastest lap with a 2\'00:447 that time around.&quot;,
    &quot;timestamp&quot;:&quot;2010-03-14 12:40:14&quot;
   }
  ]
 }
');</pre>
<p>So what data is there? Well, there are <strong>telemetry</strong> data fields for each driver:</p>
<ul>
<li><em>timestamp</em> &#8211; the time of day;</li>
<li><em>nEngine</em> &#8211; the number of revs the engine is doing;</li>
<li><em>NGear</em> &#8211; the gear the car is in (over the range 1 to 7);</li>
<li><em>rThrottlePedal</em> &#8211; the amount of throttle depression(?) (as a percentage);</li>
<li><em>pBrakeF</em> &#8211; the amount of brake depression(?) (as a percentage)</li>
<li><em>gLat</em> &#8211; the lateral &#8220;g-force&#8221; (that is, the side-to-side g-force that you feel in a car when going round a corner too quickly);</li>
<li><em>gLong</em> &#8211; the longitudinal &#8220;g-force&#8221; (that is, the forwards and backwards force you feel in a car that accelerates or decelerates quickly when going in a straight line);</li>
<li><em>sLap</em> &#8211; the distance round the lap (in metres); this resets to zero on each tour, presumably at the start/finish line);</li>
<li><em>vCar</em> &#8211; the speed of the car (km/h);</li>
<li><em>NGPSLatitude</em> &#8211; the GPS identified latitude of the car;</li>
<li><em>NGPSLongitude</em> &#8211; the GOS identified longitude of the car.</li>
</ul>
<p>On some samples, there is also commentary information, but I&#8217;m going to largely ignore that..</p>
<p><strong>Parsing</strong></p>
<p>The data I got hold of was a bundle of files containing data in the JSONP format like that shown above, with one file containing one package of data created once a second.</p>
<p>In order to <em>parse</em> the data, I needed to decide what format I wanted it in for processing. The format I chose was CSV &#8211; comma separated variable data &#8211; that looks like this:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4449640239/" title="Photo Sharing"><img src="http://farm5.static.flickr.com/4072/4449640239_635771378e.jpg" width="500" height="174"></a></p>
<p>The first column is the original filename, the other columns correspond to data downloaded from the Mclaren site.</p>
<p>In order to generate the CSV data, I wrote a Python script that would:<br />
- strip off the padding around the JSON data;<br />
- parse the JSON using a standard Python JSON parsing library;<br />
- (add a line to strip out escape characters that weren&#8217;t handled correctly by the parser and place it before the parsing step);<br />
- use a CSV library to write out the data in the CSV format.</p>
<p>(See an example Python script <a href="http://gist.github.com/339219">here</a>.)</p>
<p>I then refined my parsing script so that it would generate one CSV file per lap. To do this, the script had to:<br />
- detect when the lap distance in one sample was <em>less</em> than the distance in the previous sample (i.e. the lap distance measure has been reset to zero between the two samples, using a construction of the form <em>if oldDist &gt; d['sLap']:</em> where <em>oldDist = d['sLap']</em> once we have written the corresponding data record to the CSV file);<br />
- if a new lap has been started, close the old CSV file, create a new one, write the column header information into the top of the file, and then start adding the data to that file.</p>
<p>Having got the data into a CSV format, I could then load it in to an environment where I could start to think about visualising it. A spreadsheet for example, or  <a href="http://processing.org/">Processing</a>, (which is what I used to create the single lap view shown at the start of this post).</p>
<p>But to see how do that on the one hand, and what stories we can find in the data on the other, we&#8217;ll need to move on to another post&#8230;</p>
<p>[<em>Reflection on this post:</em> to get a large number of folk interested, I really need to do less of the geeky techie stuff, and more of the "what does the data say" cool viz stuff... but if I don't log the bootstrap techie stuff now before I overcomplicate it(?!) my record of the simplest file handling and parsing code will get lost...;-) In the book version, a large part of this post would be a technical appendix... But the "what data fields are available" bit would be in Chapter 2 (after a fluffy Chapter 1!).]</p>
<p>PS some of the technical details behind the Mclaren site have started appearing on the personal blog of one of the developers &#8211; e.g. <a href="http://kenneth.kufluk.com/blog/2010/04/building-mclaren-com-–-part-3-reading-telemetry/">Building McLaren.com – Part 3: Reading Telemetry</a>. In that post it was pointed out I haven&#8217;t been adding copyright notices about the data to the posts &#8211; which I&#8217;ll happily do once I know who to acknowledge, and how&#8230; In the meantime, it appears that &#8220;the speed, throttle and brake are sponsored by <a href="http://www.vodafone.com/start/sponsorship/f1.html/">Vodafone</a>&#8221; and &#8220;McLaren are providing this data for you to view&#8221; so I should link to them: thanks <a href="http://mclaren.com/home">McLaren</a> :-)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ouseful.wordpress.com/3104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ouseful.wordpress.com/3104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=3104&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.ouseful.info/2010/03/21/f1-data-junkie-looking-at-whats-there/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/abbd9f90565ce9ae4d065d93a81d8c03?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Tony Hirst</media:title>
		</media:content>

		<media:content url="http://farm5.static.flickr.com/4047/4448390997_7524a6b1f6.jpg" medium="image">
			<media:title type="html">Hamilton - single lap data from bahrain</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2732/4450321980_efa4714cd4.jpg" medium="image" />

		<media:content url="http://farm5.static.flickr.com/4065/4450349446_3e40653317.jpg" medium="image" />

		<media:content url="http://farm5.static.flickr.com/4072/4449640239_635771378e.jpg" medium="image" />
	</item>
	</channel>
</rss>
