Here we introduce a simple spectrum, the example taken from the optical, where it all started.
To quote Roger Wesson, the author of this particular spectrum:
The sample spectrum was extracted from a FORS2 observation of a planetary nebula with strong recombination lines. The extract covered Hβ, some collisionally excited lines of [Ar IV], and a number of recombination lines of O II, N II, N III and He II. I chose the spectrum so that it would contain some strong isolated lines and some weak blended lines, such that codes could be compared on the strong lines where user input should make minimal difference, and on the weak lines where subjective considerations come into play.
This particular spectrum was used in a comparison of codes that identify spectral lines
In [1]:
%matplotlib inline
In [2]:
# python 2-3 compatibility
from __future__ import print_function
The astropy package has an I/O package to simplify reading and writing a number of popular formats common in astronomy.
In [3]:
from astropy.io import ascii
We obtained a very simple ascii table with two columns, wavelength and intensity, of a spectrum at a particular point in the sky. The astropy module has some classes to deal with such ascii tables. Although this is not a very reliable way to store data, it is very simple and portable. Almost any software will be able to deal with such ascii files. Your favorite spreadsheet program probably prefers "csv" (comma-separated-values), where the space is replaced by a comma.
In [4]:
data = ascii.read('../data/extract.dat')
print(data)
In [5]:
x = data['col1']
y = data['col2']
In [6]:
import matplotlib.pyplot as plt
In [7]:
plt.plot(x,y)
Out[7]:
There is a very strong line around 4865 Angstrom dominating this plot, and many weaker lines. If we rescale this plot and look what is near the baseline, we get to see these weaker lines much better:
In [8]:
plt.plot(x,y)
z = y*0.0
plt.plot(x,z)
plt.ylim(-0.5,2.0)
Out[8]:
Exercise : in the notebook you should see a little icon in the lower right of this plot that you can drag out and make the plot bigger, but notice it is simply enlarging some plot. There are no more details.
There is a fair amount of noise in this data, and you can also see the baseline is not 0. This means in this object there was some continuum emission, as astronomers call this. Without understanding more about the instrument, which is not the purpose of this excersize, you cannot say much more about separating the lines from the continuum.
In [ ]: