One of my eventual amateur astronomy goals is to venture into the colourful world of spectroscopy. Today I took my first steps on that path.

We have a small cut glass pendant hanging in our window which casts pretty rainbows around the living room in the evening sun. A while ago I took photo of one of these with the intention of one day seeing what data could be extracted from it.

Not much to look at, but I decided tonight to see how much information can be extracted from this humble image.

First step was to massage the file into FITS format, the standard for astronomical data, with the hope that I could use some standard tools on the resulting file.

I cropped the rainbow, converted it to grayscale, and saved it as FITS in Gimp. I’d hoped to use my usual swiss army knife for FITS files, SAOImage DS9, to extract a graph from the resulting file, but no dice. Instead I used the following Python script to plot a graph of the averages brightness values of the columns of pixels across the spectrum. Averaging the vertical columns of pixels helps cancel out the effects of noise in the source image.

```
# spectraplot.py
import pyfits
import matplotlib.pyplot as plt
import sys
hdulist = pyfits.open(sys.argv[1])
# Grab the mean value of each column in the image
mean_data = hdulist[0].data.mean(axis=0)
plt.plot(mean_data)
plt.show()
```

Here’s the resulting graph, with the cropped colour and grayscale spectra added for context.

If you weren’t asleep during high school physics class, you may recognise the tell tale shape of a black body radiation curve.

From the image above we can see that the Sun’s peak intensity is actually in green light, not yellow as we perceive it. But better still we can (roughly!) measure the surface temperature of the Sun using this curve.

Here’s a graph of colour vs wavelength.

I estimate the wavelength of the green in the peak of the graph above to be about 510nm. With this figure the Sun’s surface temperature can be calculated using Wien’s displacement law.

λmax * T = b

This simple equation says that the peak frequency (*λmax*) of the black body
curve times the temperature (*T*) is a constant, *b*, called Wien’s
displacement constant. We can rearrange the equation …

T = b / λmax

… and then plug in the value of *b* to get the surface temperature of the Sun
in degrees Kelvin.

T = 2,897,768 / 510 = 5681 K

That’s close enough to the actual value of 5780 K for me!

I’m pretty encouraged by this result with nothing more than a piece of glass and a basic digital camera. A huge amount of what we know about the cosmos comes from examining spectra, but it’s a field that doesn’t get much love from amateur astronomers. Stay tuned for some hopefully more refined experiments in future.