GPX GPS trace files and elevation gain

I carry a GPS with me on long bike rides and pull the resulting trace into Google Earth and Garmin's MapSource software. Google Earth is nice for looking at, but doesn't provide much useful information, and MapSource is pretty awful to look at (and will only run in Windows so I have to boot up VMware) but does provide elevation maps (as well as the ability to load maps). I recently started using a bike computer with cadence, and a heart rate monitor, and the last missing piece of information was total elevation gain over a ride. This information is nowhere in MapSource or Google Earth.

I can get GPX format (The standard interchangable format for GPS information) files out of MapSource and it's just XML, so after trying several tools online and several programs I downloaded that didn't work, I wrote a quick python script to get me the info I want. Hopefully this will help someone else:

from xml.dom import minidom

file = minidom.parse('./file.gpx')

min = 1000000
max = 0
gain = 0
loss = 0
last = 0

for node in file.getElementsByTagName("ele"):
        cur = float(node.childNodes[0].data)
        if (cur > max):
                max = cur
        if (cur < min):
                min = cur
        if (last != 0):
                if (cur > last):
                        gain = gain + (cur - last)
                elif (cur < last):
                        loss = loss + (last - cur)
        last = cur

print "max: %.2fft" % (float(max * 3.2808399))
print "min: %.2fft" %  (float(min * 3.2808399))
print "gain: %.2fft" % (float(gain * 3.2808399))
print "loss: %.2fft" % (float(loss * 3.2808399))

So for my 43 mile ride on sunday:
max: 1110.63ft
min: 773.16ft
gain: 3328.98ft
loss: 3232.78ft

Getting those numbers were a lot harder than it should have been! Good ride though..

riding bikes and Faster Mustache: RACE

I had my last set of X-Rays yesterday and while it's very obvious where the break was, it's mostly healed and I can perhaps try some mountain biking again soon! I posted about my new road bike exactly a month ago, and in that month I've put 500 miles on it. Every morning during the week except Wednesdays I ride for ~2 hours, usually with a few other people, and on weekends I try to do ~3 hours twice. Sunday I rode out to Stone Mountain and did a lap around it before coming back, usually it's just a turnaround point, and in the mornings I've followed green arrows marked with "safari" (turned out to be ~25 mile tour to 8 parks with some hunting for the route at each one), gone on known routes such as the Outback Bikes Wednesday night ride route, and come up with a few of my own including one that is definitely going to be a regular route and put online somewhere. It's great to not be stuck inside on the trainer any more!

In related news, the Faster Mustache race team had our first organizational meeting last night. We're doing very well in lots of races: everything from 3rd place in an expert levels trials competition, to taking the vast majority of top 10 finishes in sport level mountain bike racing, to winning both our category and overall at a 24 hour mountain bike race in Conyers, GA. However, sponsorships have been very slow! If you'd like your name on our website, it only takes $25 and for $250 and up, you can have things like: your company linked to from our website, your logo on our jerseys, your logo on our tents and banners at races, etc! Please get in touch with me if you'd like to know more about sponsoring our team! Just email! Every little bit helps because the team covers 50% of entry fees for people that commit to 10 races a season, and races cost between $20 and $100 a person to enter.

Griffin PowerMate and Rhythmbox

I was going through some drawers and stumbled across my good old Griffin PowerMate that I got back before I started using Linux. It controlled iTunes in Mac OS 10.1 and was great because I could change volume and pause music without having to change programs or anything. These days I use Rhythmbox in Linux to listen to music and theres not a plugin for it. Yet!

Rhythmbox supports plugins written in python, a guy has some skeleton python code for talking to the powermate, and that means something could work out!

I got the powermate working by compiling and loading the powermate module for 2.6 linux kernels (In 2.6.23 it's in Device Drivers -> Input device support -> Miscellaneous devices -> Griffin PowerMate and Contour Jog support), adding a udev.d entry:

# /etc/udev/rules.d/45-powermate.rules
KERNEL=="event*", SYSFS{product}=="Griffin PowerMate", NAME="powermate", GROUP="users", MODE="0660"

I plugged it in, catted /dev/powermate, and with each twist or push it spit out garbage to the screen. Success!

A quick glance through everything shows that Rhythmbox doesn't support threads and the python code here uses polling so I'd need to delve into the Rhythmbox docs to figure out the best way to do that, but Rhythmbox also exposes itself through DBus and there are some examples of using this around the internet. In a few minutes, I hacked together something dirty to cover the basics and perhaps later on I'll make something that works as a Rhythmbox module. Right now pushing the button is play/pause, turning it adjusts the volume, and the LED shows volume when playing and pulses slowly when paused. Here ya go:


import powermate
import dbus



bus = dbus.SessionBus()
(success, status) = bus.start_service_by_name('org.gnome.Rhythmbox')

proxy_obj = bus.get_object('org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player')
player = dbus.Interface(proxy_obj, 'org.gnome.Rhythmbox.Player')

pm = powermate.PowerMate("/dev/powermate")
while 1:
	event = pm.WaitForEvent(-1)
	if (event[2] == EVENT_BUTTON_PRESS and event[4] == 0):
		if player.getPlaying():
			pm.SetLEDState((int)(player.getVolume() * 255), 0, 0, 0, 0)
			pm.SetLEDState(255, 252, 1, 1, 1);
	elif (event[2] == EVENT_RELATIVE_MOTION and player.getPlaying()):
		player.setVolumeRelative(event[4] * 0.02)
		pm.SetLEDState((int)(player.getVolume() * 255), 0, 0, 0, 0)

Download and the code above, save the code above as, run it, and you'll be able to control rhythmbox with your PowerMate in Linux!


I've been participating at DP Challenge off and on for a while now, but my images have rarely finished in the top 50% of challenges. (here's my profile there) Photography is a very subjective thing and the end result of everyones votes can be surprising! I was fairly confident with my entry into the Bicycles II challenge:

but as voting went progressed, it swung around between 4.9 (more typical for me) to 6.8 (a possible first place!). Could I win for once? After the week of voting, I ended up in 15th place out of 135, which is in the top 10%! That works for me. I like first place and tenth place better than mine, but if it was up to me, I would have given myself third :)

Hopefully I'll start doing this more regularly, if only they'd offer and RSS feed of new challenges!

New Road Bike

I figured that starting off on a fixed gear or a full suspension mountain bike might not be the best thing for my still recovering collarbone, so I decided a few weeks ago that I was going to get a road bike. I researched around online and narrowed it down to a 2008 Roubaix Elite Compact. All Shimano 105 except the brakes and cranks, about what my budget was, and I like the way it looks. However, when I got to Outback Bikes to buy one, they had some 2007 models left over... So I ended up picking up a 2007 version of the Roubaix Comp Compact for a few hundred dollars less than they were selling the Elite for. This one has Shimano 105 brakes and cranks, and slightly nicer wheels. Another great deal on a bike from Outback (I got my full-suspension mountain bike in a similar situation there a few years ago). I'm going to try a few laps around the block later today and hopefully the doctor on Monday will say that I'm good to start seriously riding outside again! Hopefully those ~1000 miles I've done on the trainer will pay off...


I take a lot of pictures. I figure I should post them on here. Here goes one. This is a HDR of the trees in my backyard:

(If you see a "used without permission" watermark on the image in your feed reader, please let me know in a comment or by email, so that I can add it to the list of allowed referrers!)