**Page updated:**
April 23, 2020 **Author:** Curtis Mobley

View PDF

# Surfaces to Spectra: 2D

The preceding pages have given a detailed look at one-dimensional surfaces. We now consider the more useful case of two-dimensional sea surfaces. The extension to two dimensions is mathematically straight forward.

Let $z\left(x,t\right)=z\left(x,y,t\right)$ be the sea surface elevation in meters at point $x=\left(x,y\right)$ at time $t$. The spatial extent of the sea surface is $0\le x<{L}_{x}$ and $0\le y<{L}_{y}$. This surface is sampled on a rectangular grid of ${N}_{x}$ by ${N}_{y}$ points, where both ${N}_{x}$ and ${N}_{y}$ are powers of 2 for the FFT. The spatial sampling points are then

$$\begin{array}{llll}\hfill x\left(r\right)=& \phantom{\rule{1em}{0ex}}\left[0,1,2,...,{N}_{x}-1\right]\frac{{L}_{x}}{{N}_{x}}=r\Delta x,r=0,...,{N}_{x}-1\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill y\left(s\right)=& \phantom{\rule{1em}{0ex}}\left[0,1,2,...,{N}_{y}-1\right]\frac{{L}_{y}}{{N}_{y}}=s\Delta y,s=0,...,{N}_{y}-1\phantom{\rule{0.3em}{0ex}}.\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$$This spatial sampling frequency gives ${N}_{x}$ and ${N}_{y}$ spatial frequencies ${k}_{x}$ and ${k}_{y}$ (in math frequency order)

$$\begin{array}{llll}\hfill {k}_{x}\left(u\right)=& \phantom{\rule{1em}{0ex}}\left[-\left({N}_{x}\u22152-1\right),...,-1,0,1,...,{N}_{x}\u22152\right]\frac{2\pi}{{L}_{x}}=u\Delta {k}_{x},u=-\left({N}_{x}\u22152-1\right),...,{N}_{x}\u22152\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill {k}_{y}\left(v\right)=& \phantom{\rule{1em}{0ex}}\left[-\left({N}_{y}\u22152-1\right),...,-1,0,1,...,{N}_{y}\u22152\right]\frac{2\pi}{{L}_{y}}=v\Delta {k}_{y},v=-\left({N}_{y}\u22152-1\right),...,{N}_{y}\u22152\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill \phantom{\rule{0.3em}{0ex}}.& \phantom{\rule{2em}{0ex}}& \hfill \end{array}$$As before, the x-dimension 0 frequency is at array element $u={N}_{x}\u22152-1$ and the Nyquist frequency is at element $u={N}_{x}-1$. Thus the positive and negative pairs of ${k}_{x}$ values are related by ${k}_{x}\left(u\right)=-{k}_{x}\left({N}_{x}-2-u\right),u=0,...,{N}_{x}-2$, with the Nyquist frequency always being a special case because there is only a positive Nyquist frequency. Corresponding relations hold for the $y$ direction.

Let $k=\left({k}_{x},{k}_{y}\right)$ denote a spatial frequency vector, where ${k}_{x}$ and ${k}_{y}$ are frequencies in the $x$ and $y$ directions, respectively. For discrete values, we write ${k}_{uv}=\left({k}_{x}\left(u\right),{k}_{y}\left(v\right)\right)$. The magnitude of $k$ is $k=\sqrt{{k}_{x}^{2}+{k}_{y}^{2}}$. In our $\left(x,y\right)$ coordinate system, let the wind blow in the $+x$ direction. The $-x$ direction is then upwind, and the $\pm y$ directions are the cross-wind directions. With this choice, ${k}_{x}>0$ indicates frequencies of waves propagating more or less downwind, and ${k}_{x}<0$ for waves propagating against the wind. ${k}_{x}=0$ and ${k}_{y}\ne 0$ indicates a wave propagating at exactly a cross-wind $\pm y$ direction. The angle of wave propagation relative to the downwind direction for a wave of frequency $\left({k}_{x}\left(u\right),{k}_{y}\left(v\right)\right)$ is given by

$$\phi \left({k}_{uv}\right)=\phi \left(u,v\right)={tan}^{-1}\left[\frac{{k}_{y}\left(v\right)}{{k}_{x}\left(u\right)}\right]\phantom{\rule{0.3em}{0ex}}.$$ | (1) |

We can thus write the 2-D surface as $z\left(x\right)$, its Fourier amplitude as $\u1e91\left(k\right)$, and the associated variance spectrum as $\Psi \left(k\right)$. The discrete variance spectrum $\Psi \left({k}_{uv}\right)=\Psi \left(u,v\right)$ gives the variance of the wave with wavelength $2\pi \u2215{k}_{uv}$ propagating in direction $\phi \left({k}_{uv}\right)$ relative to the downwind direction.

Even though the mathematical transition from one to two dimensions causes no problems, it is again educational to take a careful look at a couple of contrived examples.

#### 0.1 Example: A Random Sea Surface

For the ﬁrst example, a sea surface area of size ${L}_{x}\times {L}_{y}=10\times 10\phantom{\rule{1em}{0ex}}m$ is sampled using ${N}_{x}=16$ and ${N}_{y}=8$ points in the x and y directions. Sea surface elevations $z\left(x,y\right)$ were created by drawing a $\mathcal{\mathcal{N}}\left(0,1\right)$ random number at each $\left(x,y\right)$ value.

The upper-left panel of Fig. 1 shows a contour plot of this surface for a particular sequence of random numbers. The spatial periodicity of the Fourier representation is used to extend the contour plot to the full $\left({L}_{x},{L}_{y}\right)$ range of the tile, which gives a good visual appearance. Thus the elevations at $x={L}_{x}$ are the same as those at $x=0$, those at $y={L}_{y}$ equal those at $y=0$, and the elevation at $\left({L}_{x},{L}_{y}\right)$ duplicates the elevation at $\left(0,0\right)$. The ${N}_{x}\times {N}_{y}$ grid of sample points is shown by the solid silver dots. The points at $x={L}_{x}$ and $y={L}_{y}$ obtained by periodicity are shown by open silver circles at the right and top of the surface plot.

The Fourier amplitudes $\u1e91\left({k}_{uv}\right)=\u1e91\left({k}_{x}\left(u\right),{k}_{y}\left(v\right)\right)$ are obtained from the 2-D DFT of $z\left({x}_{rs}\right)=z\left(x\left(r\right),y\left(s\right)\right)$:

$$\u1e91\left({k}_{uv}\right)=\mathcal{\mathcal{D}}\left\{z\left({x}_{rs}\right)\right\}\phantom{\rule{0.3em}{0ex}}.$$ |

The usual warning on FFT frequency order applies here. The 2-D FFT gives back the amplitudes $\u1e91\left({k}_{uv}\right)$ with the array elements corresponding the the FFT frequency order of Eq. (??). Before plotting, the $\u1e91\left({k}_{uv}\right)$ array elements must be shifted into the math frequency order in both the ${k}_{x}$ and ${k}_{y}$ array directions using the appropriate shift function for the computer language used in the plotting. For the IDL routine used to generate Fig. 1, the 2-D circular shift is given by the IDL command

$$realzhatplot=SHIFT\left(REAL\text{\_}PART\left(zhat\right),{N}_{x}\u22152-1,{N}_{y}\u22152-1\right)$$ |

where zhat is the complex 2-D array returned by the FFT routine, and realzhatplot is the 2-D array plotted in the upper right panel of Fig. 1.

The upper right panel of Fig. 1 plots the real part of $\u1e91\left({k}_{uv}\right)$, and the lower left panel plots the imaginary part. The Nyquist frequency ${k}_{x}^{Ny}=2\pi \u2215\left(2\Delta x\right)=5.03\phantom{\rule{1em}{0ex}}rad\u2215m$ lies along the right side of the contour plot. The Nyquist frequency ${k}_{y}^{Ny}=2\pi \u2215\left(2\Delta y\right)=2.51\phantom{\rule{1em}{0ex}}rad\u2215m$ lies along the top of the contour plot. The white space at the left and bottom highlights that there are no negative Nyquist frequencies. In each amplitude plot a particular pair of $\pm {k}_{uv}$ values is indicated by the black arrows; the $\left(0,0\right)$ frequency is shown by a black dot. Note that in the plot of the real part, $Re\left\{\u1e91\left(-{k}_{uv}\right)\right\}=Re\left\{\u1e91\left(+{k}_{uv}\right)\right\}$, whereas in the plot of the imaginary part, $Im\left\{\u1e91\left(-{k}_{uv}\right)\right\}=-Im\left\{\u1e91\left(+{k}_{uv}\right)\right\}$. The contouring is rather low quality for so few points, but it is easy to see in the digital output that when the ${k}_{x}$ is the Nyquist frequency (the points along the right column of points in the plot), the symmetries are given by $Re\left\{\u1e91\left({k}_{x}^{Ny},-ky\right)\right\}=Re\left\{\u1e91\left({k}_{x}^{Ny},+ky\right)\right\}$ and $Im\left\{\u1e91\left({k}_{x}^{Ny},-ky\right)\right\}=-Im\left\{\u1e91\left({k}_{x}^{Ny},+ky\right)\right\}$. A corresponding relation holds for $\pm {k}_{x}$ when ${k}_{y}={k}_{y}^{Ny}$ (the points along the top row of the plot). The point at the upper right of the plot corresponds to both ${k}_{x}$ and ${k}_{y}$ being at their respective Nyquist frequencies. As always, the array elements at the Nyquist frequencies must be treated as special cases when writing computer programs. These symmetries show that the 2-D amplitudes are Hermitian: ${\u1e91}^{\ast}\left(-{k}_{uv}\right)=\u1e91\left({k}_{uv}\right)$. The discrete 2-D variance spectrum $\Psi \left({k}_{uv}\right)=\Psi \left(u,v\right)=\u1e91\left(u,v\right){\u1e91}^{\ast}\left(u,v\right)$ is contoured in the lower right panel of the ﬁgure. Note the $\Psi \left(-{k}_{uv}\right)=\Psi \left({k}_{uv}\right)$ symmetry.

For this example, the standard check on the 2-D discrete Parseval’s relation, Eq. (16) on page Fourier Transforms, gives

$$\begin{array}{llll}\hfill \sum _{r=0}^{{N}_{x}-1}\sum _{s=0}^{{N}_{y}-1}|z\left(r,s\right){|}^{2}=& {N}_{x}{N}_{y}\sum _{u=0}^{{N}_{x}-1}\sum _{v=0}^{{N}_{y}-1}|\u1e91\left(u,v\right){|}^{2}\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill =& {N}_{x}{N}_{y}\sum _{u=0}^{{N}_{x}-1}\sum _{v=0}^{{N}_{y}-1}\Psi \left(u,v\right)=130.90\phantom{\rule{1em}{0ex}}{m}^{2}\phantom{\rule{0.3em}{0ex}}.\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\end{array}$$In all of these plots, it should be remembered that the discrete values are known only at the locations of the silver dots. The contouring routine simply interpolates between these points to create a visually appealing ﬁgure. The continuous color in the plots does not imply that the values are continuous and known in between the discrete points.

#### 0.2 Example: A Sea Surface of Crossing Sinusoids

For a second example, let us deﬁne a surface from a pair of crossing sinusoids as follows:

where as usual $r=0,...,{N}_{x}-1;s=0,...,{N}_{y}-1;$ and where

- ${A}_{1}=1.0\phantom{\rule{1em}{0ex}}m$ is the amplitude of the ﬁrst wave
- ${N}_{x1}=2$ is the number of wave lengths in the x direction in $\left[0,{L}_{x}\right]$ for the ﬁrst wave
- ${k}_{x1}=2.0\pi {N}_{x1}\u2215{L}_{x}=1.257\phantom{\rule{1em}{0ex}}rad\u2215{m}^{2}$ is the ${k}_{x}$ frequency of the ﬁrst wave
- ${N}_{y1}=1$ is the number of wave lengths in the y direction in $\left[0,{L}_{y}\right]$ for the ﬁrst wave
- ${k}_{y1}=2.0\pi {N}_{y1}\u2215{L}_{y}=0.628\phantom{\rule{1em}{0ex}}rad\u2215{m}^{2}$ is the ${k}_{y}$ frequency of the ﬁrst wave
- ${\varphi}_{1}=0$ is the phase of the ﬁrst wave; 0 gives a cosine wave
- ${A}_{2}=0.5\phantom{\rule{1em}{0ex}}m$ is the amplitude of the second wave
- ${N}_{x2}=4$ is the number of wave lengths in the x direction in $\left[0,{L}_{x}\right]$ for the second wave
- ${k}_{x2}=2.0\pi {N}_{x2}\u2215{L}_{x}=2.513\phantom{\rule{1em}{0ex}}rad\u2215{m}^{2}$ is the ${k}_{x}$ frequency of the second wave
- ${N}_{y2}=3$ is the number of wave lengths in the y direction in $\left[0,{L}_{y}\right]$ for the second wave
- ${k}_{y2}=-2.0\pi {N}_{y2}\u2215{L}_{y}=-1.885\phantom{\rule{1em}{0ex}}rad\u2215{m}^{2}$ is the ${k}_{y}$ frequency of the ﬁrst wave
- ${\varphi}_{2}=\pi \u22152$ is the phase of the second wave; $\pi \u22152$ gives a sine wave

The wavelength of the ﬁrst wave is ${\Lambda}_{1}=2\pi \u2215\sqrt{{k}_{x1}^{2}+{k}_{y1}^{2}}=4.47\phantom{\rule{1em}{0ex}}m$, and that of the second wave is ${\Lambda}_{2}=2.00\phantom{\rule{1em}{0ex}}m$. The direction of propagation of the ﬁrst wave relative to the $+x$ axis is

$${\phi}_{1}={tan}^{-1}\left(\frac{{k}_{y1}}{{k}_{x1}}\right)=26.57\phantom{\rule{1em}{0ex}}deg\phantom{\rule{0.3em}{0ex}},$$ |

and the direction of propagation of the second wave relative to the $+x$ axis is

$${\phi}_{2}={tan}^{-1}\left(\frac{{k}_{y2}}{{k}_{x2}}\right)=-36.87\phantom{\rule{1em}{0ex}}deg\phantom{\rule{0.3em}{0ex}}.$$ |

The upper left panel of Fig. 2 shows this surface elevation pattern when Eq. (2) is sampled with ${N}_{x}={N}_{y}=16$. The dominant red-blue pattern shows the ﬁrst wave oriented with the direction of propagation along either the $+{k}_{1}$ direction at ${\phi}_{1}=26.57\phantom{\rule{1em}{0ex}}deg$ or the $-{k}_{1}$ direction at ${\phi}_{1}=26.57+180=206.57\phantom{\rule{1em}{0ex}}deg$. We cannot of course determine the actual direction $+{k}_{1}$ or $-{k}_{1}$ of propagation from sea surface elevations at a single time. The dominant wave pattern is modulated by the second wave, which has one half the amplitude of the ﬁrst wave.

The choice above of ${\varphi}_{1}=0$ in Eq. (2) makes the dominate wave a cosine in our coordinate system, and ${\varphi}_{2}=\pi \u22152$ makes the second wave a sine. As we saw in the 1-D examples, variance associated with cosine waves appears in the real part of the Fourier amplitudes, and the variance in sine waves appears in the imaginary parts. We see this again here for the ﬁrst (cosine) and second (sine) waves of the surface. Since each wave pattern has only one frequency, there is only one pair of points at $\pm {k}_{1}$ in the plot of the real part, and one pair at $\pm {k}_{2}$ in the plot of the imaginary part. The amplitudes at all other frequencies are zero. The symmetries of these points again show the Hermitian nature of the amplitudes.

The lower right panel shows the two-sided variance function ${\Psi}_{2s}\left(k\right)$ for this surface. Note that the ﬁrst wave has four times the variance of the second wave because the amplitude of the ﬁrst wave is twice that of the second wave. ${\Psi}_{2s}\left(-k\right)={\Psi}_{2s}\left(+k\right)$. Note also that you can look at a 2-D variance spectrum and see how much energy is propagating in a given $\pm k$ direction.

For this simple example involving just four frequencies it is easy (from the digital output) to hand check that the right-hand side of the 2D discrete Parseval’s relation, Eq. (16) of the Fourier Transforms page, is

$${N}_{x}{N}_{y}\sum _{u}\sum _{v}|\u1e91\left(u,v\right){|}^{2}=16\cdot 16\left[{\left(0.5\right)}^{2}+{\left(0.5\right)}^{2}+{\left(0.25\right)}^{2}+{\left(-0.25\right)}^{2}\right]=160\phantom{\rule{1em}{0ex}}{m}^{2}\phantom{\rule{0.3em}{0ex}}.$$ |

This value agrees exactly with the corresponding sums of the surface elevations, ${\sum}_{r}{\sum}_{s}{\left[z\left(r,s\right)\right]}^{2}$, and variance values, ${N}_{x}{N}_{y}{\sum}_{u}{\sum}_{v}\Psi \left(u,v\right)$.