Sunrise sunset

Some 10 or so years ago, I sought some data showing sunrise and sunset times throughout the year for New York and London. I was interested in how the day lengths and sun times differed between the two cities, having lived in both. Below is the result.

It was hardly rocket science. But it showed how New York’s winter days were longer than London’s, while London enjoyed longer summer days. The spikes represented the slightly different times at which our respective clocks changed to summer time.

Roll on ten years, and on a whim I decided to recreate this in Tableau. Before doing so, I didn’t revisit the original work. (“Work” here is a word used in its loosest form.) I vaguely remembered what it had looked like, but in hindsight I didn’t fully appreciate how truly ugly it had been.

So the other evening I set about cobbling together the sunrise and sunset times again. This time, picturing how my Tableau viz might look, I augmented it with some other cities:

  • Glasgow: to see how northerliness within the UK affects things
  • Reykjavík: to see what happens when you go even further north
  • Sydney: to add a representative from the Southern Hemisphere
  • Singapore: as it’s almost exactly on the Equator
  • Rio de Janeiro: because Sydney was looking lonely in the Southern Hemisphere

The first chart was straightforward to create.

A dual axis plot of the sunrise and sunset times by day, coloured by city; and day length below it. Things were complicated slightly by the fact that in summer, Reykjavík’s sun sets after midnight. Only by three minutes or so, but that necessitated a little Excel pre-prep jiggery-pokery.

This is when I got a little excited. The curves were beautiful. I was mesmerised by the fact that the equinoxes saw 12-hour days for the whole world, with the lines all meeting beautifully. I should have known this, but it was nonetheless beautiful to see, something that wasn’t apparent in the ugly Excel viz.

Here, I added a couple of little tricks. I allowed the user to remove the daylight saving element, thus smoothing the lines. I did this by using a time field that I had to convert back to the non-summer equivalent. And I also gave the option of artificially flipping the cities in the Southern Hemisphere to the Northern Hemisphere. This I did by artificially shifting the dates in the first half of the calendar to the second half and vice versa. So viewers could now compare Sydney to London in a meaningful way.

I then decided to throw in an additional viz that showed the height of the sun at its peak, using a full circuit from 1 January at the top, moving clockwise through the year to 1 July at the base and then back to the top. This involved intricate trigonometry and many iterations of buggy code. But it was utterly satisfying when it all came together. I found Singapore (green) carved a fascinating pattern.

And finally, more as an intellectual challenge than something overtly tangible, I decided to add the direction of the sunrise and sunset to the tooltips, not as degrees clockwise from north as the data was pulled, but instead as traditional compass bearings. So instead of giving the user 71°, they are presented with the delectable E 19° N.

The full viz can be found here. Hope you like it.

St. Totteringham’s Day

Yesterday, Arsenal’s ten men came back to draw against Spurs in arguable the most important North London derby in living memory. Before the match my good friend, who is a Leicester fan, suggested an Arsenal victory would have been an ideal result, as it would have left Leicester three points clear of both North London teams, with a game in hand. I argued that a draw was ideal, as it left fewer serious competitors for the title race.

In looking into the numbers, I discovered the concept of St. Totteringham’s Day. This is the day upon which Tottenham mathematically are unable to beat Arsenal in the Premier League. Given that Arsenal have beaten Spurs for the last 20 seasons, there has been such a day in each of those years.

In these years, the earliest it took place was in 2007/08, when Spurs were unable to surpass their rivals on 8 March 2008. (Spurs finished 11th in the table, to Arsenal’s third.) The latest was on 19 May 2013, the last day of the 2012/13 season, when Arsenal secured third spot, one point ahead of fourth-place Spurs.

Here’s my visualisation of the history. I wonder whether there’ll be such a day in this 2015/16 season.