Tutorial: Lots of PlotsThis tutorial assumes that you already know how to use Python to read LIGO data files. If you don't, you may want to take a look at the Introductory Tutorial before you go any further.This tutorial will show you how to make a few common plots with time series data, including a Fourier domian representation, an amplitude spectral density, and a spectrogram.
All of the plots described in this tutorial can be seen in
this figure. You can
also download the entire
script described in this tutorial.
Create a file called
Notice that readligo just refers to the
sample reader functions
described in step 4, which
read data from a LIGO data file. Of course, you can also
write your own code for this.
We also added the mlab module from matplotlib ,
which includes a function to calculate a power spectral density (PSD).
To start, we'll read the strain data and data quality information
from the
LIGO data file
that you downloaded in
step 1 of the introductory
tutorial:
To make some example plots, let's pick a segment of "good data", and then
work with just the first 16 seconds of data in the segment:
In the example, we'll use pyplot.suplot so that all of the
plots will be on one figure. You may prefer to use pyplot.figure()
instead to make separate figures. To set up a grid of
6 figures, with a little extra space for axis labels:
Plot a Time SeriesYou can plot the time series data like this:
If you don't see the plot, try the command plt.show() .
Fourier Transform (FFT)Next, let's try plotting the data in the Fourier domain, using a Fast Fourier Transform (FFT). Because GWOSC data has a great deal of excess noise at low frequencies, spectral leakage is often an issue. To mitigate this, we'll apply a Blackman Window before we take the FFT:
The vector returned in freq_domain is complex.
Let's just plot the magnitude of this vector:
Power Spectral Density and Amplitude Spectral DensityPlotting in the Fourier domain gives us an idea of the frequency content of the data. Another way to visualize the frequency content of the data is to plot the power spectral density:
You can also plot an amplitude spectra density the same way,
just by taking the square root, np.sqrt() , of Pxx .
SpectrogramsA spectrogram shows the power spectral density of a signal in a series of time bins. Pyplot has a convienient function for making spectrograms:
Mainly, this spectrogram shows what we already knew from the PSD:
there is a lot more power at very low frequencies than high frequencies.
If we are looking for time variation in the data, it can be
helpful to normalize each frequency bin by the typical power
at that frequency. We can do this, and then replot the
spectrogram, using the colormesh function:
You can see all of these plots
in this figure. You can
also download the entire
script described in this tutorial.
