The routines pointed to by this file are offered for use but with no warranty as to their fitness for any purpose. Use entirely at your own risk!

2-d spectra

Consider F(x,t)=sum_a,b{A_a,b * e^i(k_a*x - w_b*t)} ie a 2-d fourier decomposition of a given function. We wish to find A_a,b for the frequencies (b) and wavenumbers (a). In theory this may not be too hard, but in practive we have to know how the FFT routine behaves and what it does with -ve frequencies, etc.

Lets take an example:

data=fltarr(60,30)
for i=0,29 do data(*,i)=sind(indgen(60)*6*5+i*12*2)+sind(indgen(60)*6*3-i*12*4)*3
contour,abs(fft(data)),indgen(60),indgen(30),/xs,/ys,lev=[.1,1],xticks=12,xr=[0,60],xminor=5

So, if we call (in the data) the first dimension longitude and the second time, "data" represents 2 waves, one of amplitude 1 travelling W'wards with wavenumber 5 and frequency 2, and one of amplitude 3 travelling E'wards with wavenumber 6 and frequency 4. In the fft, first dimension is wavenumber and second is frequency.

[Note the abs: we don't care about phase at all.]

Looking at the contour plot (go on, do it!) we see 4 points. Considering the lower 2, the BL has lowest amplitude (0.5), frequency 2, wavenumber 5. The BR has higher amplitude (1.5, in fact), frequency 4 and wavenumber -3. So, -ve (wavenumbers past 30 are really -ve; subtract 60 from them) wavenumbers are E'wards and +ve are W'wards.

Now lets get more complex:

for i=0,29 do data(*,i)=sind(indgen(60)*6*5+i*12*2)+sind(indgen(60)*6*3-i*12*4)*3+sind(indgen(60)*6*30+90)*7+10+sind(indgen(60)*6*15+90)+sind(indgen(60)*6*3-i*12*15)+sind(indgen(60)*6*5-i*12*14)

which has the 2 waves as before, plus an amplitude-7 no-propagation wave-30, plus an amplitude-10 constant, plus an amplitude-1 no-propagation wave-15 plus an amplitude-1 wave-3 frequency 15, plus an amplitude-1 wave-5 frequency-14. Wheew!

Contour this up:

contour,abs(fft(data)),indgen(60),indgen(30),/xs,/ys,lev=[.1,1,4],xticks=12,xr=[0,60],xminor=5

The amplitudes of the peaks at on the zero-freq axis are:

      10.0000     0.500000      7.00000     0.500000

ie, the power is what-we-expect at wave-0 and wave-30, but half that at wave-15 because this is folded onto 2 waves.

Further up the plot, there is rotational symmetry in the upper half but its slightly tricky: frequencies 16 to 29 get folded (rotated) into frequencies 1 to 14. Frequency 15 folds onto itself (since it goes 1/2 way round each time you can't tell E'wards from W'wards propagation).

Is that clear? Well, we can re-plot as:

data1=abs(fft(data))
data2=data1(*,indgen(15+1))
for i=1,14 do data2(*,i)=data2(*,i)+reverse(data1(*,30-i))
contour,data2,indgen(60),indgen(16),/xs,/ys,lev=[.1,1,4],xticks=12,xr=[0,60],xminor=5

We can clarify the E'wards and W'wards a bit by shifting things in X:

data3=data2
n=60/2
data3(n-1+indgen(n+1),*)=data2(indgen(n+1),*)
data3(indgen(n-1),*)=data2(n+1+indgen(n-1),*)
contour,data3,indgen(60)-n+1,indgen(16),/xs,/ys,lev=[.1,1,4] 

Now, lets wrap all this up in a pro: spectra_2d,data

Other stuff

  • spectra_2d_plot - plot up a spectrum
  • spectra_2d_remake - filter a spectrum to include only a specified band of frequencies


    NERC / BAS / ICD / Navigate
    Author: W. M. Connolley, June 1998