Sunday, October 30, 2011

Mount Hamilton

Yesterday I rode up Mount Hamilton, the first time I had done so since March, when the grass was green and there was still snow on the ground on the peak.

View Mount Hamilton in a larger map

The day was cloudless and cool, and the parking area at Alum Rock was more crowded than I've ever seen it. We got started at about 9 AM, just as a large group was setting off. Riding among that group was enjoyable, both for the conversation as well as the confirmation that I wasn't the slowest climber on the mountain. Wise riders climb at their own pace, so the bunch quickly strung out and before we got to  the Grandview restaurant we were alone again.

I was riding with a significantly stronger rider, so I had the odd experience of feeling slow because I was holding him up, while knowing that I was keeping up a darned good pace by my own standards.

A lone tarantula on Mount Hamilton Road

On the climb out of Grant Park I spotted a tarantula walking along the road. We stopped to get some pictures, and kept a few fellow riders from accidentally running it over while we did so. Luckily no cars were coming. I've heard of (but never seen) mass Tarantula migrations on the mountains around here, but this one was by itself.

Like Route 9 a couple of weeks ago, Mount Hamilton Road just goes on and on. I kept a steady (but quite slow) pace. I had to stop a couple of times to calm my heart, but not as many as on previous trips. Sometimes toward the end of long climbs I'm completely drained, and every little ramp looks impossible. I didn't get to that point on this ride, although I was happy to reach the parking lot at the observatory.

Elevation profile of Mount Hamilton.
See a note about data for details.
The climb for an up-and-back trip should be about 4800 feet. There's a 3800 foot difference between Alum Rock and the peak, and then there's 500 extra feet of climbing on the way up, and the same on the way down. My little algorithm only gave me 4500 feet, so I have some tinkering to do.

Monday, October 17, 2011

Bear Creek Road and Saratoga Gap

Last week I tried to climb up Route 9 to Saratoga Gap, but what with the length of the ride, possibly the early stages of a cold, and last but not least my lack of fitness, I didn't make it. I abandoned, and called for a ride home.

My wife is very generous about coming to get me, reasoning that having the rescue option easily available means I can consider more ambitious rides. Nonetheless, it's disappointing and embarrassing to have to make the call.

Yesterday I wanted to salvage some ego, if I could. I wanted to climb that road, but if I tried the same ride it would likely have the same outcome. So what went wrong last week? I think the main problem was that I was facing the last climb after 60 miles of riding. I don't have that kind of stamina. So the big change today would be to cut out the whole first part of the ride by taking Bear Creek Road over the ridge, directly into Boulder Creek.

View Bear Creek Road and Saratoga Gap in a larger map

First, I had to get to Bear Creek Road. That meant the same ol' route to Los Gatos, down the Los Gatos Creek Trail, up the dam, then down the dirt trail next to Highway 17 to the overpass.

Looking east from Bear Creek Road
I was a little worried about Bear Creek Road, since the unofficial Stanford cycling page describes it as both "steep" and "busy". I sat for a few minutes at the base of the hill, trying to get a sense for how many cars were heading up. At this point it was a little after 10 AM on a Sunday, and in the few minutes I sat there no cars went up at all. OK, now it's just the "steep" part to worry about.

Bear Creek Road is indeed steep, but at this early stage of the ride, it was manageable for me. I just went very slowly, standing up on the especially steep parts. There was very little traffic on the way up, but enough that I couldn't weave across the lane, much as I would have liked to.

The road grinds up to about 2000 feet, where it levels off and meets Summit. Then it climbs gradually to 2200, where it meets Skyline. I think part of my problem last week was that I didn't eat any quick energy food, although I did eat a real lunch, which should count for something. In any case, trying to do everything right this time, I sat at the top of the road and ate a Clif bar.

Bear Creek Summit
As I coasted down the other side of Bear Creek Road, I was thinking back to my last time on this road. It was nearly a year ago, and I had meant to go from Skyline to Summit. But for whatever reason turning right seemed appropriate, and I had descended to 1400 feet before I started to think "This can't be right". Now, with much more familiarity with the roads up here, that seems especially laughable.

Waterman Gap
Eventually I rolled into Boulder Creek, and stopped at Johnnie's Market to refill my water bottles. Then it was time to start retracing my steps from last week. On that ride, the part of Route 9 just north of Boulder Creek was very quiet, with almost no traffic. That was also a Sunday, but about 5:30 in the evening. This time it was closer to noon, and traffic was much heavier.

Immediately north of Boulder Creek, Route 9 climbs gradually, gaining only about 300 feet in five or six miles. Suddenly, at about 800 feet of elevation and perhaps a mile short of the intersection with 236, it begins climbing at a very steady 5%. That's a pretty reasonable climb, but man, it just goes on forever. Finally at about 2500 feet it levels off a bit, and slowly climbs to about 2600 feet at Saratoga Gap, the summit.

Looking South-Southwest from the Overlook
That was the high point of the ride. I flew down the east side of Route 9, comfortably exceeding the 30 mph speed limit most of the way. I took the Saratoga/Los Gatos road, which is also Route 9, to Los Gatos, then Blossom Hill home.
Elevation profile for this ride.
See a note about data for details
The whole ride was just about 54 miles, with about 4200 feet of climbing. Both Bear Creek Road and the top of Route 9 were first-time climbs for me, which is always great. I'm still working on the stamina to have more adventurous rides in the mountains, so this is progress.

Monday, October 10, 2011

Boulder Creek

Yesterday I headed out on my road bike with no destination in mind. I enjoyed a recent ride down to Santa Cruz, and decided that riding down to the beach would be a good way to start.

View Boulder Creek in a larger map

I left the house about 9:30 in the morning. It was overcast and cool. I took my standard route through Los Gatos, not especially inspired for this ride but enjoying the time on the bike nonetheless.

Highway 17 supports above
the Los Gatos Creek Trail.
A couple of days ago I got a book called Highway 17, which as you might expect is about the history and construction of Highway 17. Definitely a transportation nerd's book. It's easy for a bicyclist to develop an interest in transportation minutia, because you spend all your time riding on obsolete infrastructure.

Among other things the book describes building the road south of Los Gatos, just above the Los Gatos Creek Trail. Back then the trail was an active railroad bed, and they squeezed the road into the steep hill above it. To do that, they had to build a "sidehill viaduct", basically cantilever supports. So on this trip I had my eye out for them, and sure enough they're still visible. OK, it's a little thing, but I had never noticed that before.

 I felt pretty good riding around the reservoir and up Old Santa Cruz Highway. I was so aimless that I thought about riding the southern part of the old highway again, just because it's so pretty. But instead I decided that the point of the ride would be a visit to the beach. So it was down the Soquel/San Jose Road to Capitola.

Capitola was cool, in the temperature sense, and bustling. I headed west toward Santa Cruz, again retracing my steps from a few weeks before. I missed the turn onto Opal Cliff Drive, and learned that riding along Portola isn't nearly as interesting as the beachfront.

By this time it was about 1 in the afternoon, and I was passing by Betty Burger again,  and oh what the heck, I stopped there again for lunch. I wasn't being very original on this ride, but what's not to like?

Train trestle across the San Lorenzo
Once I got going again, I headed toward the boardwalk. Along the way I talked to a friendly pedestrian who, among other things, suggested that I think about Route 9 on the way home. Works for me; that's the new plan.

I rode up the path next to the San Lorenzo River, which eventually meets up with River Street, the southern end of Route 9.

Route 9 starts by climbing a bit up into Henry Cowell Redwoods State Park. As you might expect, that means being among some tall trees. Unfortunately, it also means being in the midst of a lot of traffic. I don't mind traffic much, but it means that I rarely stop and enjoy the sights.

Rincon Gulch trestle
One stop I did make was to take a picture of another train trestle, this one over something called Rincon Gulch. As it turns out, this is the train line that goes up to Roaring Camp. A few minutes later, I saw an odd train on that line, made up of five or six small maintenance engines, the size of compact cars. Surreal. Like a clown train.

Route 9 through Felton, and then Ben Lomond.  All along the way it's very pretty, but busy. As I got into Boulder Creek I was thinking about stopping at the Fosters Freeze, which I've visited on car trips before. Somehow I rode right by it.

Once I passed Bear Creek Road the traffic lightened dramatically, but I started feeling lousy. My legs were tired of course, but worse yet my shoulders were achy and my back was starting to worry me. I trudged along.

A few miles up the road I had climbed very gradually to about 1000 feet, but there the real climb starts. I was about 60 miles into it, my phone battery was almost dead, and I was taking the hills so slowly that I was worried I'd be riding home in the dark. I turned around, rode back to Boulder Creek (I found the Fosters Freeze this time) and called for a ride home.

It's probably the case that I just don't have the strength to undertake a big climb 60 miles into a ride. But as I write this 24 hours later, I know I was coming down with something, so maybe there's hope for me yet.

Elevation profile. See a note about data for details.

The Garmin reported about 65 miles and a little over 3000 feet of climbing, a large part of which was in undulations on Route 9. The web site reported a ton of calories burned, but considering the burger and an ice cream at Fosters, I may have consumed more than I expended.

Saturday, October 8, 2011

A Note about Data

The elevation profile for the Hecker Pass ride

Source Data

The elevation profiles presented here are based on data collected from my Garmin Forerunner 305. This device measures elevation solely through GPS; it doesn't have a barometric altimeter.

My experience with the device is that it gives accurate, absolute results when it has a good view of the sky, and generates random numbers when I'm riding in canyons or (sometimes) along steep ridges. Between these two extremes the readings appear to be realistic, but can be very slow to update and may vary by 100 feet or more.

I'm basing my opinion of the clear-sky results on the readings I get when the absolute elevation is known, such as on mountaintops or at the ocean. I'm basing the canyon observation on the way the value can vary wildly as I slowly ride along steady grades. In some cases, the values can rise and fall so much, so quickly, that the only explanation would be that I was shot out of a cannon.

I use the Garmin Connect web site, which applies some level of correction, apparently through USGS data or similar. The GPX files I'm using to generate these graphs come through that web site, and I'm not sure whether they apply those corrections to the downloaded data or not.

Calculating accumulated climb

A simple approach to calculating the total climb would be to compare each elevation data point with the previous point, and accumulate any positive differences.

There are a couple of problems with that approach. First, the raw data coming from the device is not entirely accurate. Even on a perfectly constant grade the raw data fluctuates up and down, so the naive approach would give you some climb on flat roads. It might even register some climb on a consistent descent. You don't want that.

The second problem is that you really want to count only "meaningful" climbs. This problem isn't in the device, it's in our heads. Even if the measurements from the device were perfect, roads do in fact undulate. If you counted every little rise after every little dip, you would again accumulate climb even on roads that you perceive as flat. You don't want that, either.

To address the first problem, I'm calculating a decaying average of the raw elevation readings from the device, and using that for all subsequent calculations. In my case I'm using a decay level of 10, so:
    ele = (raw + ele*9) / 10.
The elevation graph is actually showing the decaying average, not the raw data, although at this scale the difference is minimal.

To address the second problem, I'm only accumulating climbs when they exceed a threshold of about 50 feet. I have a running "base" value, which is the lowest elevation (using the decaying average) I've seen. Once the elevation climbs 50 feet above the base, I credit the delta and reset the base. Thus if you're riding rollers on the way to the hill, you'll end up getting credited for those little rises... but just once. You will be cheated out of 25 feet (on average) at the top of each climb.

Ultimately this is a subjective measurement, but this approach gives me a result I can accept. If I look at the graph itself and estimate the climb by eye, I normally get to 80-90% of the calculated result, which is probably reasonable. Since it's based solely on the data from the device, if the elevation noise varies too much (more than 50 feet despite the decaying average) then I'll accumulate too much climb. The decaying average removes most of those noisy variations, but on some specific rides the effect has been noticeable.

Calculating Grade

It's easy to calculate the overall grade of a hill, and realistically that's the most important number to me as a rider. But in the interest of teasing some additional information from the data I've collected, I decided to try to calculate the grade at a finer granularity. An instantaneous grade, if possible.

The grade is basically the first derivative (with respect to distance) of noisy elevation data, so it's especially susceptible to bad data. I tried a number of methods to get sensible results. What I settled on was this: every 100 meters of linear travel, I calculate the change in the decaying average elevation and report that as a percentage.

This produces a satisfying result, apart from the rare regions of extremely noisy data. The spikes in grade normally correspond to actual steep ramps, the reported grade of those ramps is believable, and to the extent that you can get a sense of overall grade from the graph, it seems accurate.

The problem with this approach is that it's arbitrary. Two rides over the same road will produce different graphs. They'll be broadly similar, but one point of variation will almost always be in the maximum grade, which is the highest spike in the graph and therefore the most visible result.

The Map

To show a Google map, I start off with a KML file, again downloaded from The raw KML files have thousands of points, but it appears that Google maps will only show about 200 points before starting to break the path into segments. So I needed to find a way to cut down the number of points dramatically while retaining as much of the overall shape as possible.

My first attempt was to try to eliminate intermediate points that didn't matter much. So I took each set of three points (let's call them A, B and C) and determined the angle between AB and AC. If the angle was small, then the B was close to the line AC, and we wouldn't miss it much. That might have worked in principle, but it was hard to debug the angle calculation. I also iterated over the points several times trying to get down to 200, and in later rounds the algorithm would fixate on one segment, gradually straightening it out. Harrumph.

As I was debugging that problem, viewing intermediate results in gnuplot, I finally noticed that just sampling every n'th point gave me much better results than my "smart" approach. It works best when I'm going slowly (which is most of the time), but it does tend to straighten out roads when going quickly (descending, perhaps). Maybe I'll get around to adjusting for speed, but for now simple sampling seems to give reasonable results.

The Tools

I normally upload my ride data to, then later pull it back down through the "export" function as GPX and KML files. To generate the graph I run the GPX file through a C++ program, and pump the results through gnuplot. I'd like to use an SVG result, but Blogger wants only bitmap images, so I use the pngcairo terminal.

The gnuplot script I generate looks something like this:
set grid
set y2tics
set xlabel 'Distance (miles)'
set ylabel 'Elevation (feet)'
set y2label 'Grade (%)'
set style line 1 linewidth 2 linecolor rgb '#60b060'
set style line 2 linewidth 1 linecolor rgb '#b06060'
set object 1 rectangle from graph 0, graph 0 to graph 1, graph 1
  behind fillcolor rgb '#f0ffff' fillstyle solid 1.0
set terminal pngcairo size 800,400
plot '-' using ($1*0.62137):(($2 > 0) ? $2 : 0)
         with filledcurves above x1 fill solid 0.6 border linestyle 2
         axis x1y2 title 'Grade (%)',
       '' using ($1*0.62137):($2*3.2808)
         with filledcurves above x1
         fill transparent solid 0.8 border linestyle 1"
         title 'Elevation'
The data is generated by the program, and of course is metric, converted to feet and miles only in this display step. The grade values include negative grades (ie descents), but I mask those off because they made the graph more difficult to read.

To produce the map I run the KML through a different C++ program that samples the points and removes any points near my house (otherwise these maps would all point directly to my house, which I'd prefer not to do). I upload the result to Google Maps using the My Places feature, then generate embedding code for that.

I started with KML because that's the natural format for Google Maps, but at this point I'm using none of the original file except the lat/lon/elevation points, and therefore could just use the GPX for both purposes.