Saturday, 13 August 2016

For the love of Spherical Harmonics

I hate starting every blog post with an apology as I have been busy, but I have. But I have. Teaching Electromagnetism to our first year class, computational physics using MatLab, and six smart talented students to wrangle, takes up a lot of time.

But I continue to try and learn a new thing every day! And so here's a short summary of what I've been doing recently.

There's no secret I love maths. I'm not skilled enough to be a mathematician, but I am an avid user. One of the things I love about maths is its shock value. What, I hear you say, shock? Yes, shock.

I remember when I discovered that trigonometric functions can be written as infinite series, and finding you can calculate these series numerically on a computer by adding the terms together, getting more and more accurate as we add higher terms.

And then there is Fourier Series! The fact that you can add these trigonometric functions together, appropriately weighted, to make other functions, functions that look nothing like sines and cosines. And again, calculating these on a computer.

This is my favourite, the fact that you can add waves together to make a square wave.
But we can go one step higher. We can think of waves on a sphere. These are special waves called called Spherical Harmonics.

Those familiar with Schrodinger's equation know that these appear in the solution for the hydrogen atom, describing the wave function, telling us about the properties of the electron.

But spherical harmonics on a sphere are like the sines and cosines above, and we can describe any function over a sphere by summing up the appropriately weighted harmonics. What function you might be thinking? How about the heights of the land and the depths of the oceans over the surface of the Earth?

This cool website has done this, and provide the coefficients that you need to use to describe the surface of the Earth in terms of spherical harmonics. The coefficients are complex numbers as they describe not only how much of a harmonic you need to add, but also how much you need to rotate it.

So, I made a movie.
What you are seeing is the surface of the Earth. At the start, we have only the zeroth "mode", which is just a constant value across the surface. Then we add the first mode, which is a "dipole", which is negative on one side of the Earth and positive on the other, but appropriately rotated. And then we keep adding higher and higher modes, which adds more and more detail. And I think it looks very cool!

Why are you doing this, I hear you cry. Why, because to make this work, I had to beef up my knowledge of python and povray, learn how to fully wrangle healpy to deal with functions on a sphere, a bit of scripting, a bit of ffmpeg, and remember just what spherical harmonics are. And as I've written about before, I think it is an important thing for a researcher to grow these skills.

When will I need these skills? Dunno, but they're now in my bag of tricks and ready to use.