Tuesday, October 13, 2009

Solar Car Strategy

One of my jobs over the past couple of days has been to program a weather data feed for the solar car. (The race is in twelve days! More on that soon.) After a lot of looking, we settled on NOAA's Global Forecast System as our source.


the world, simulated. thanks NOAA!

(That, by the way, is a really cool system. It gives you everything that's going on at any point on the globe, in three hour increments, from right now to more than a week in advance. By "everything", I mean everything from the chance of rain to "soil porosity" and "total cloud water (atmospheric column)." They run the simulation four times a day. That means that the NOAA guys crank out gigabytes of data every six hours, and anyone can just go there and download it.)

For the World Solar Challenge, we're interested in two things: the amount of power we're going to get (or as NOAA likes to call it, "downward shortwave radiation flux") and the amount of headwind or tailwind.


solar power, in W/m^2

The only problem is that the race is one one of the most remote highways in the world. We're bringing extra fuel canisters so that our vans make it from one outpost to the next. Those gigabytes of real-time data aren't going to get there. Instead, we're bringing a satellite phone, which gets us a couple kilobits per second--1991 style--and at exorbitant cost. Sasha calculated that loading Gmail would take more than an hour and cost $400.

To get around this, I wrote a script that runs at regular intervals on my server back in California. Each time, it downloads the latest weather data and parses out only the variables we care about, does a little bit of voodoo, and samples them roughly every kilometer along the race route.

Plan A was to compress the output into a hackish text file. I'd output one line for each waypoint along the route, and each line would have one character per forecast: the first character would be the amount of sun we're getting now, the second would be the amount of sun we expect in three hours, and so on for the entire six-day race.

~3000 waypoints * 60 forecast times * 1 character per value = 180000 bytes. 180 kB. Doable over a satellite phone! Still, I forgot the obvious part: the weather at one point in the middle of nowhere in the desert is very similar to the weather a kilometer away, or a kilometer after that... as a result, many of the lines in the script output were very similar to each other. Not optimal. So I tried something else...


scriptin'

Plan B was to round each value to the nearest integer, then write them as a regular text file. Number, comma, number, comma, on every line, one per waypoint.

Then I zipped the file and made it available for download. Much easier, and fewer moving parts since we can just open the zip file with software we already have. As Donald Knuth once famously said,

premature optimization is the root of all evil.

Simplicity rules.

Tomorrow at the crack of dawn (according to Sasha), we are leaving for Adelaide, then for Darwin. I'll post when I can, but internet will be spotty. In fact, internet access sucks in Australia, in general. More on that later. Peace!

No comments:

 
Views