# How to use the interactive graph / analyse tool

The interactive graph on this site uses the analyse tool to create the data. I'll describe here how to use the interactive graph - it should be fairly clear from this and the usage output of analyse how this works if you're using the tool directly

## Sources

The first thing you have to do is to choose a raw data source. This site automatically checks for new data at the public websites of the various organisations listed in the credits page. So you should always have the latest and best data to hand.

The main sources to use when you're starting are:

## Processing steps

After choosing your raw data source, you can then choose a number of processing steps to apply to the data to create the graph. If you don't choose any, you just get the raw data itself.

The steps can be applied in any order, and can even be repeated if you're feeling really adventurous. I've limited them to 10 for the interactive graph to stop the table getting too big, but in the analyse tool you can have as many as you like (if you really need more than 10 steps I might suggest you should be running it locally!)

Some steps take a numeric value which defines what they do - what the value does is defined below. Others don't take a value and you can just leave it blank.

### 1: Data selection

These are the easiest, and just select the time window you want to graph

Processing stepValueFunction
FromYear Selects data from the given year onwards
ToYear Selects data up to the given year (not including it)
LastSamples Selects the last number of samples given
EverySamples Selects samples at the interval given (usually 12)

If you want to select exact months, you have to use the decimal year, so June 1944 is 1944.42 (June = month 6, counting from 1; month 5 counting from zero; 5/12 = 0.42).

### 2: Data transformation

These are simple modifications of individual data values:

Processing stepValueFunction
ScaleScale factor Multiplies each sample by the given scale factor
OffsetOffset amount Adds the given offset to each sample (can be negative)
Normalise- Scales and offsets all samples so they fall into the range 0..1
DetrendEnd-to-end slope Removes a slope from 0 at the first sample to the given amount at the end (can be negative)
Derivative- Take the first derivative of the data (each sample has the one before subtracted)
Integral- Integrate the data (each sample is added to the cumulative total of the one before)

### 3: Simple averaging

The simplest way to remove short-term 'noise' from a graph is by averaging samples. Alternatively, you might be more interested in the 'noise' than the long term trend...

Processing stepValueFunction
MeanMonths Running mean over the given number of months. Keeps the number of samples the same, but smooths them by taking the average of that number of months around each sample.
IsolateMonths Does the same running mean as 'mean', but then subtracts this from the raw data to leave the 'noise'
CompressMonths Reduces the number of samples by averaging across the given number of months and replacing with the average. Use this to simplify a dataset before doing complex operations on it.

### 4: Trend lines

To see the overall trend in the data, you can use a best-fit trend line:

Processing stepValueFunction
Linear trend- Produces a basic trend line using Ordinary Least Squares (OLS). The result is a graph with two points, one at each end of the time range, which represent the best-fit linear trend over that time.

#### Examples:

Note that since the graphs are auto-scaling, trend lines by themselves will always be the same shape! It's the vertical scale that matters.

### 5: Frequency-domain (Fourier) analysis

These are the most complex and most powerful of the processing steps. Fourier analysis works on the principle that any waveform can be decomposed into a combination of simple sine waves (here is Wikipedia's page on Fourier analysis).

Note: When using these processes keep in mind whether you are in the frequency domain or time (normal) domain, otherwise you can get some very strange results indeed!

Processing stepValueFunction
Fourier- Converts the data into the frequency domain. The first resulting sample is the DC offset, the second the 1st harmonic, etc.
Technical note: this a complex DFT of a real dataset, so the result is symmetric around N/2
Inverse-Fourier- Converts the data back to the time domain again.
Technical note: Complex IDFT, only real parts kept in output.
Low-PassHarmonic number Removes all frequencies from the given harmonic number and above. Must be used in frequency domain.
Technical note: Zeros samples from n to (N-1-n)
High-PassHarmonic number Removes all frequencies up to the given harmonic number. Must be used in frequency domain.
Technical note: Zeros samples from 0..n-1 and (N-n)..(N-1)
Window- Applies a Hann window to the data before Fourier analysis. This shapes the data so it produces a more accurate frequency spectrum, but don't rely on the shape of the output, particularly at each end.Must be used in time domain.
Magnitude- Takes the absolute magnitude of the complex Fourier transform. You must use this to display frequency spectra, otherwise the complex component will be lost.

## Tips & Tricks

### Multiple series

You can plot multiple series at once by clicking "Add Series" and filling in another source/steps form for that series. Click "Delete Series" to remove one if you have more than one.

When there are multiple series the axes of the graph are set to the outer range of each - hence you may need to apply 'scale' and 'offset' factors to one or more of the series to get a usable comparison.

### Listen to the data!

There is an experimental feature where you can generate an audio file from the graph. The data samples are normalised, then used as 44.1Khz samples and then looped 128 times and turned into an MP2 file (not MP3 because of patent issues).

Thanks to Tony Edwards for first suggesting using one of the best pattern-recognition devices for repeating signals available!