Friday, 21 February 2014

How the Sun Controls the Weather

The Sun is our nearest star, 93 million miles away, so far that it takes light just over 8 minutes to reach the Earth. Despite being so far away it supports nearly all life on Earth and drives the Earth's climate and weather. The effect of the sun has been recognised since pre-historic times but its only recently since the 19 century that astronomers have studied it in detail. 

One of the most easily observed features of the sun are sunspots. Sunspots are temporary phenomena on surface of the Sun that appear visibly as dark spots compared to
surrounding regions. The largest sunspots can the tens of thousands of kilometres across.

The number of sunspots visible on the Sun is not constant, but varies over an 11-year cycle known as the solar cycle. The solar cycle has a significant influence on the Earth's climate as the Sun's luminosity has a direct relationship with the magnetic activity associated with sunspots.Solar activity minima tend to be correlated with colder temperatures, and longer than average solar cycles tend to be correlated with hotter temperatures.

This Viz shows how the number of sunspots, cosmic rays, irradiance (energy) influences the weather on Earth. 

Note on how it was made

Creating this viz posed a challenge when it came to bringing the data together. Each of the 4 measures, sunspots, cosmic rays, irradiance and global temperatures came from different sources. And of course all them were in different formats. Two of the data sets contained daily readings, the other two, monthly. There were a variety of date formats used. For example in one set the date looked like "188001", in another "19781116". One then had a column for years months and days and the final one was a cross tab with 12 months per row. This seemed like a perfect chance to break out the newest tool in my vizzing armoury, Alteryx. 

I've mentioned Alteryx before in this blog post but this was the first time I used it in anger. Using the simple drag and drop interface and a few simple formulae, a little tweet to Chris Love and I was able to convert the various dates in the files to something that Tableau would recognise as a legitimate date. 
Converting the cross tab was a breeze using the Transpose tool. For the final part of the viz i then needed to convert the daily records into monthly records and then combine all 4 files into a single tableau extract.  Much like Tableau, Alteryx is easy to experiment with so it only took an hour or so to get what I needed. 
I've no doubt that what I have done is very amateur and that an expert could probably reduce the spiders web of connected modules down to a handful, but I was able to take 4 separate messy data sources and produce a unified Tableau data extract, and do it quickly. 

The only frustrating part was due to my lack of knowledge of Alteryx. I knew what I wanted to do and roughly how to do it but it took me longer than it felt it should have to get there. I have no doubt that next time it will be quicker as I know my way around that bit better. I think there could be an improvement in some of the help files and error messages but that would be picking holes. I have to say a special thank you to Chris Love who provided some very useful tips. 

Massive thanks goes to Emily Kund (whos superb blog can be found here) for her help with the viz. She pointed out the issue with the axis scales which lead to the 5th comparison chart. She gave me some terrific help with the colour choices and let me know which ones worked and which didn't. Her proof reading found all sorts of problems and I am eternally grateful for her to being my rubber duck with this viz.

Matt Francis

Author & Editor

Tableau Zen Master, Social Ambassador, Wrangler of Data, Vizzer of Data


  1. You know, you say showing this data illustrates how sunspots "control" weather (i.e. cause it), but your graphs only show correlation, right (as your text itself says). Correlation is not causation; what evidence do you have that the Earth's weather isn't controlling the sunspots? Not that I actually think weather causes sunspots, but these graphs alone aren't sufficient to prove causation in the other direction.