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.