Using Astral from a known location

I’ve been working out a minor idea involving the control of some household actions based on local time, but relative to sunrise and sunset rather than a naive time of day. Simon Kennedy’s Astral is a Python module that can compute these times, but its examples focus on retrieval of locations from major cities. Most places aren’t major cities in the module’s list, so I spent a little time to read the source to determine what other entry points were enabled.

It turns out that the Location class is perfect for those times when you can’t associate a site with a major city, but know the latitude and longitude (from GPS or a mapping service, for example). An example usage follows:


"""Example of using astral with a location not in the module's
built-in catalog."""

import astral
import datetime

# From A. Mariano, MacOS units(1), 1993.
FT_PER_METRE = 3.2808399

# Construct our location.  Longitude west and latitude south are
# negative.
los_altos = astral.Location(info=("Los Altos", "USA", 37.3681,
                                  -122.0975, "US/Pacific",

# "civil", which means 6 degrees below the horizon, is the default
# value for computing dawn and dusk.  But this usage shows how to
# set it before calculation.
los_altos.solar_depression = "civil"

tomorrow = + datetime.timedelta(1)

result = los_altos.sun(date=tomorrow)

for k in ["dawn", "sunrise", "noon", "sunset", "dusk"]:
    print "%7s %s" % (k, result[k])

Instrumented soccer, fall 2013

I just started the spring season in my recreational soccer league last weekend. And I’m still using Adidas’s miCoach system to record statistics in each game. Earlier I showed a couple of individual sessions, with image captures from the miCoach site. Here I’m going to summarize the season, and compare it to the previous season (Summer 2013). Top line summary of the season

  • 11 games, 9/8 – 12/29
  • 8 goals
    • Compared to 1 in Summer 2013
    • All on turf

For the quantities tracked by the Speed Cell, we have a group of measurements, summarized as follows

  • Distance: 4.0 ± 0.6 miles per game, with a best of 5.1 miles on 12/1. (Improved over Summer 2013, 3.9 ± 0.5 mpg.)
  • Sprints: 20.5 ± 4.5 sprints per game, with a best of 30 on 12/1. (Improved over Summer 2013, 18.5 ± 4.7 spg.)
  • Maximum speed: 15.0 ± 0.4 mph, with a best of 15.52 mph on 9/15 and 10/6. (Improved over Summer, 2013 14.5 ± 1.1 mph.)

miCoach offers badges (“achievements”) for various performance levels: on 12/1, 5.1 miles of total distance and 0.55 miles of “hi intensity distance” resulted in the Pro achievements for those two categories. Still haven’t reached the Pro mark for Maximum Speed, which I suspect will require a burst over 16 mph. (On 6/9, 3.9 miles of distance and 15.17 mph maximum speed earned the respective Club achievements. On 7/14, 0.38 miles of high intensity distance earned the corresponding Club achievement.)

I was pretty happy with my showing on December 1, but Sean Ingle’s Sunday article in The Guardian, on Chelsea and England defender Ashley Cole, shows how low on the performance scale these numbers are:

The additional physical demands are clear from Prozone’s data. In 2003-04 Premier League full-backs made an average of 29.5 sprints – any movement greater than seven metres a second – over a game. This season that figure is exactly 50. A decade ago the average recovery time for a full-back between high-intensity activities – any movement greater than 5.5m/s, or a three-quarters speed run – was 56.4sec. Now it is 40.4sec.

Ashley Cole faces life in the slow lane as demands of the job intensify

(Of course, I’m ten years older than Ashley Cole, so I am pleased just to be on the field, uninjured, and possessing a little bit of pace.)

It’s going to be hard to compare the spring season with this one, as the new team only has part-time goalkeepers, and I’ll have to take many more shifts in net. (The two times I played keeper during the fall were 13 sprint games.) Other than working on my metrics, my only goal for this season is to finally score one on the grass fields.

Sprinkler valve break and repair

Early last summer, Nathaniel was in the back yard, practicing his kicks into our KixKube. One particularly strong kick missed the cube, and smashed into the exposed sprinkler valves, breaking through the ¾” PVC pipe below one of the valves. The break led immediately to that portion of the garden and lawn being covered in water, so I rushed to close the water main at the street and then scurried to Home Depot to get a PVC cap and fresh (fast setting) PVC cement.

You can see the cap at the right of the above photo; it’s the piece below the blue PVC cement-stained pipe. The fragments of plastic are the remains of the storage container I placed over the valves to protect them from further misses. (Not successfully.)

I decided to make two improvements when I rebuilt this complex: to add a ball valve before the sprinkler valves, so that I can make repairs without turning off water to the entire house, and to add a third sprinkler valve for a drip system. You can see the ball valve underneath the rightmost valve in the picture below; the new valve is the leftmost.

It took a bit of tweaking to get the joints and valves sealed tight, with one or two connections having to be redone. Once I had the valves watertight and the wiring reconnected, my system testing showed that our Rain8 WLM, which was an X10 wireless-based irrigation control, had suffered a power blow-out as well.

Sprinklers repaired and robustly reboxed
OpenSprinkler Pi, a photo by schahn on Flickr.

Since the Rain8 WLM had been discontinued, I decided to replace the controller with an OpenSprinkler Pi, using WiFi for wireless access. For the X10-based controller, I had built my own set of irrigation programs for cooler, which had been moving from shell scripts invoking flipit driven by cron(1M) to using Redis for state and eventually to a web server model, but I dropped all of that—for now—in favour of Sprinklers Pi running directly on sprinkles (the Pi). With the combination of a regular and a seeding schedule, I have equivalent (or better, with the Weather Underground integration) capability to the previous implementation. The new system has been working well.


With the watering infrastructure restored, I did our fall overseeding, three months late, using a mix of low-water grass and white clover, topped with new soil and compost. These guys—mature and immature white-crested swallows (Zonotrichia leucophrys nuttalli)—showed up once the grass seed hit the ground (and walkway). Let’s hope they leave enough seed to grow. (The mature one is the one sporting the white crest with black stripes on his head.)

This is the second California animal species or subspecies we’ve mentioned here that is named in honour of Thomas Nuttall. (Earlier in the summer, we saw a Nuttall’s woodpecker.)

Weeding by grid

Now that we’ve begun repairing the lawn with new grass, the final phase will be plucking out the crabgrass that dominated one corner. I’m going to work systematically through the lawn using a grid system, plucking out each crabgrass shoot.

Grid, a photo by schahn on Flickr.

There’s about ½” of new soil spread over top to provide new nutrients, but there are also some pretty beaten down bare patches. We’ll see what the spring growth brings.

Next steps

Assuming I establish some level of control over the crabgrass, I’ll connect a small drip irrigation system to that unused valve and introduce a corresponding third schedule to the Sprinklers Pi configuration. If that goes well, I’ll add a second valve to the front lawn for drip—unless we decide that even a small front lawn is an indulgence during a severe drought. (In which case, maybe I’ll transplant the sod from the front to the back and go drip-only in the front to the citrus trees and oleander.)

Lunch: New England Lobster Market & Eatery, Burlingame

We drove farther than average to visit the New England Lobster Market & Eatery [Yelp], but the pleasant outdoor space they’ve created a hundred yards or so from the shore of San Francisco Bay combined with a very credible lobster roll made it worthwhile. The potato chips are also excellent.

Picoides nuttalli foraging

Nuttall’s woodpecker, originally uploaded by schahn.

While retrieving a few items from the car I parked out front, I heard the burst of a woodpecker tapping, and grabbed my camera (with an 80 – 320 mm lens for soccer) to see if I could get a good enough picture for identification. The camera rig was much more suitable than the camcorder I used to snap a merlin in 2005.

Ben looked at the photo and worked through his options in the AMNH Birds of North America. Based on the range, the barred back, and red crown, he thinks it’s an example of Nuttall’s Woodpecker (but it could be a Ladder-backed or a hybrid of the two).

This serene moment of observation ended when the squirrel in that same tree, directly above me, dropped a walnut on my head.