Tuesday, May 5, 2020

Revenge of the Fifth



You didn't think I'd go through the trouble of making a Star Wars Day post and miss out on the obvious follow-up pun, did you?

The demo project (available here) is pretty much the same as the previous one except that it uses a different 3D model from  Star Wars: Thrawn's Revenge II: Ascendancy. Thanks again to CoreyLoses.

Monday, May 4, 2020

May the Fourth (be with you) - and some FireMonkey feature requests




Happy Star Wars Day!

What? Delphi programming types are allowed to be silly sometimes. :)

Wednesday, April 22, 2020

Climate Spiral Visualisation

Happy Earth Day!


April 22nd, 2020 marks the 50th anniversary of Earth Day. Initially started in the United States in response to things like the 1969 Santa Barbara oil spill, it has grown to include annual events coordinated in over 193 countries and continues to promote environmental and climate literacy today.

An effective way to communicate complex topics and the staggering amount of published data is to find a clear, approachable way to visualise it. Easier said than done, but a really interesting challenge for all of the data nerds and software developers out there.

Data is cool.

In 2016, British climate scientist Ed Hawkins created a simple, but clear, animated radar chart showing the progression of global warming over time. This is called a climate spiral and it's gotten a lot of public attention. It was featured in the opening ceremony of the 2016 Summer Olympics and similar charts have been created for atmospheric CO2, Arctic sea ice volume and extent and to show predicted temperature changes out to 2100 based on different scenarios.

If you like his climate spirals, check out his work on warming stripes.

Fortunately, the concept is simple enough that a layperson, like myself, could replicate it. So I thought it might make for an interesting Delphi programming exercise.


The Data. What's being measured?


The climate spiral measures changes in global average temperatures over time relative to a baseline. The nature of the chart makes it easy to spot year over year changes.

I'm using the HadCRUT4 dataset (4.6.0.0) published by The Met Office, the national meteorological service for the UK. It combines the CRUTEM4 (temperature over land) and the HadSST3 (temperature over water) datasets.

tl;dr: I use the second column in this file. The file's layout is described here.


What's this "baseline"?


The HadCRUT4 dataset uses the average global temperatures between 1961 and 1990 as its baseline. Readings in the dataset are how much the temperature differs from this. You might see these differences referred to as "temperature anomalies".

I believe the original chart used pre-industrial temperatures (between 1850 and 1900) as its baseline. This is why numbers in my chart don't seem to go as high.

If you wanted to use the pre-industrial baseline, just add 0.31 to the HadCRUT4 data values.


What's the deal with 2 degrees Celsius?


Doesn't seem like a lot, does it? It makes you wonder why climate scientists want that to be their line in the sand.

As it turns out, even 1.5 degrees of warming has worse consequences than previously thought. It's not just the amount of warming, but how fast the warming is happening. Instead of small changes over hundreds of years, we're seeing fairly large changes over decades. The Paris Agreement was intended as an international call to action to reduce the rate of warming and the resulting impact.

There has been about 1 degree of warming so far and we're already seeing the impact. We're expected to reach 1.5 degrees of warming by 2040 and without significant action on our part, we will pass 2 degrees of warming before the end of the century.


What do the colours mean?


Line colour changes represent time and not temperature. Though there is a bit of a correlation, so I understand why there might be some confusion.

The viridis colour map (sometimes called "option d") is used here. It's the default colour map in MATLAB, which was used to create the original chart. It's one of several colour sets designed to be perceived as uniform (no unnecessary hot spots), be colour-blind friendly and print well in greyscale.

Honestly, the topic of colour maps in data visualisation is interesting in itself and deserves its own dedicated write-up.


Application Notes


I've created a simple application that reproduces Ed Hawkins' climate spiral chart with the most recent data, which covers up to February of 2020 at the time of this blog post. The dataset at the link above is updated as new data becomes available.

The application was written with the free Delphi Community Edition and uses FireMonkey.

The trackbar along the bottom lets you scroll through the dataset month by month.

The Animate button animates the chart from the current position to the end.

I learned that you can draw text at an arbitrary angle on a FireMonkey canvas using the canvas' Matrix property. See the DrawTextOnCanvas method for an example.

I read the HadCRUT4 dataset from a text file in the bin folder rather than downloading it from the MET Office site on startup. Mostly for speed and to avoid any unexpected surprises.

And that's about all there is to it. You can find the source code here.




Additional information


If there are more questions on climate change, and I hope there are, here is some additional reading.






Thursday, February 13, 2020

I Heart Delphi

On February 14th, 2020, Delphi celebrates its 25th anniversary.

Wow.

Monday, May 20, 2019

Friday, August 17, 2018

Summer Books

"It’s always better to have too much to read than not enough."
-- Ann Patchett
Six months ago it was "reading by the fire" weather and now it's "reading on the patio in the shade" weather. Either way, it's always fine weather for reading.

Wednesday, February 7, 2018

New Books for a New Year

"Whenever you read a good book, somewhere in the world a door opens to allow in more light."
-- Vera Nazarian

Happy (belated) New Year!

And what better way to spend those cold, wintry days than in front of a fire with a nice book? Or more than one...