Page updated: May 23, 2021
Author: Curtis Mobley
View PDF

Spectra to Surfaces: 1D

The previous page showed the major features of the Fourier analysis of a sea-surface elevation record. We started with a sample of a random sea surface and ended with the corresponding discrete variance spectrum (or estimate of the variance spectral density after division by the frequency interval). This page shows how to go in the reverse direction: start with a variance spectrum and generate a random realization of the corresponding sea surface. We first outline the theory, and then show a specific example.

Theory for 1-D Surfaces

To create a one-dimensional (1-D) slice through a sea surface, the essence of the process is as follows:

Choose the domain size. To create a sea surface over a spatial domain at a given time, we pick the length L of the region [0,L]. To generate a time series at a given point, we pick the length of the time series.
Choose the number of points for the DFT. This number N is the number of frequencies at which we will sample the variance spectrum, and equals the number of samples of the sea surface that will be generated. In normal usage, pick N to be a power of 2 so that an inverse FFT routine can be used to evaluate the inverse DFT.
Choose the frequency variable. To generate a sea surface over a spatial domain at a given time, we can use either wavenumber ν or angular spatial frequency k. To generate a time series at a given point, we can use either f or ω.
Choose a variance spectrum The variance spectrum must be expressed in terms of the chosen frequency variable.
Choose the wind speed. Pick a wind speed, and perhaps other physical parameters such as the age of the waves to be generated if required by the chosen variance spectrum.
Create random Hermitian amplitudes. This is the tricky part. We must create an array of randomized discrete Hermitian Fourier amplitudes (u), starting with the chosen continuous variance spectrum.
Take the inverse DFT of the random amplitudes. The inverse DFT converts the Fourier amplitudes to the physical wave heights.
Extract the sea surface heights. The inverse DFT of the complex amplitudes returns a complex array. The real part of this array is the random realization of the sea surface heights, and the imaginary part is zero.
Check your results. This is extremely important during code development. For example, take the DFT of the generated surface heights to see if you get back to the Fourier amplitudes and variance spectrum you started with.

We now proceed through these steps and discuss them in detail for a specific example.

Steps 1 and 2: Let us generate a sea surface over the region from x = 0 to x = L = 100m. The longest wavelength that can be resolved is then 100 m. We use N = 1024, which gives a spatial grid resolution of Δx = LN = 0.0977m. This means that the shortest wavelength that can be resolved, the two-point wave or Nyquist wavelength, is 2Δx = 0.1954m.

Step 3: We used wavenumber ν in the previous pages because of its easy interpretation. Now let’s use angular spatial frequency k, which is more commonly used. The fundamental frequency is then kf = 2πL = 0.0628radm1. The highest frequency sampled, the Nyquist frequency, is kNy = (N2)kf = 32.15radm1. Note that (2π)kNy = 0.1954m which, as noted above, is the wavelength of the two-point wave.

Step 4: For this example, we use the Pierson-Moskowitz variance spectrum in terms of angular spatial frequency k. This is given by Eq. (1) of the Wave Variance Spectra: Examples page. Note that this is a one-sided spectrum, which is defined for positive k values.

Step 5: The wind speed at 10 m elevation is U10 = 5ms1. The wind speed is the only input to the Pierson-Moskowitz spectrum.

Step 6: We now discuss in detail how to generate a set of random discrete Fourier amplitudes that are physically consistent with the chosen variance spectrum. These amplitudes must be defined for both positive and negative frequencies, and the amplitudes must be Hermitian. We first define

o(ku) 1 2 ρ(ku) + iσ(ku) 𝒮1s (k = ku ) 2 Δk. (1)

Here 𝒮1s(k = ku) denotes the continuous spectral density 𝒮1s(k) evaluated at k = ku. Δk = kf is the spatial frequency sampling interval. o(ku) must be defined for both positive and negative discrete frequencies in order to create the Hermitian amplitudes for use in the inverse DFT. As was mentioned on the previous page, we must convert the one-sided continuous spectrum 𝒮1s(k) into a two-sided discrete variance function by

dividing its magnitude by 2, assuming that 𝒮2s(k) = 𝒮2s(k);
multiplying the continuous spectral density by the fundamental frequency interval Δk, which gives the variance contained in a finite frequency interval at each frequency ku.

To emphasize the discrete vs continuous functions, and for brevity of notation, let us write the frequency index u for the frequency ku. Then Eq. (1) becomes

o(u) = 1 2 ρ(u) + iσ(u) 𝒮2s (u), (2)

where 𝒮2s(u) denotes the two-sided discrete variance spectrum at frequency ku. o(u) can now be evaluated for both positive and negative ku. The 0 and Nyquist frequencies are always special cases: set 𝒮2s(0) = 0 and 𝒮2s(kNy) = 𝒮1s(kNy). ρ(ku) ρ(u) and σ(ku) σ(u) are independent random numbers drawn from a normal distribution with zero mean and unit variance, denoted ρ,σ 𝒩(0, 1). A different pair is drawn for each u value.

o(u) is a random variable. Let ... denote the expectation of the enclosed variable. The expected value of |o(u)|2, o(u)o(u), gives back whatever variance function is used for 𝒮2s(u):

o(u)o(u) = 1 2[ρ(u) + iσ(u)]𝒮2s (u) 1 2[ρ(u) iσ(u)]𝒮2s (u) = 𝒮2s(u) 2 ρ2 + σ2 = 𝒮 2s(u)

because ρ2 = σ2 = 1 for 𝒩(0, 1) random variables. Thus o(u) is consistent with the chosen variance spectrum. However, o(u) is not Hermitian, so the inverse DFT would not give a real sea surface.

Next define (u) as

(u) 1 2 o(u) + o(u) . (3)

This function is clearly Hermitian, so the inverse DFT applied to (u) will give a real-valued z(xr) z(r). Moreover, this (u) is consistent with the variance spectrum:

|(u)|2 =(u)(u) = 1 2 1 2[ρ(u) + iσ(u)]𝒮2s (u) + 1 2[ρ(u) iσ(u)]𝒮2s (u) × 1 2 1 2[ρ(u) iσ(u)]𝒮2s (u) + 1 2[ρ(u) + iσ(u)]𝒮2s (u) = 1 4 ρ2(u) iρ(u)σ(u) + iσ(u)ρ(u) + σ2(u) 𝒮 2s(u)+ ρ(u)ρ(u) + iρ(u)σ(u) + iσ(u)ρ(u) σ(u)σ(u) 𝒮2s (u)𝒮2s (u)+ ρ(u)ρ(u) iρ(u)σ(u) iσ(u)ρ(u) σ(u)σ(u) 𝒮2s (u)𝒮2s (u)+ ρ2(u) + iρ(u)σ(u) iσ(u)ρ(u) + σ2(u) 𝒮 2s(u) = 1 2[𝒮2s(u) + 𝒮2s(u)] = 𝒮2s(u).

Here we have noted that ρ(u)ρ(u) = 0, etc., because the random variables are uncorrelated for different u values.

Equations (1) and (3) are the key to generating random sea surfaces from variance spectra. (u) defined by these equations contains random noise, which leads to a sea surface with random amplitudes and phases for the component waves of different frequencies. Any one of these surfaces has a variance spectrum that looks like the chosen spectrum plus random noise. However, on average over many realizations, the the noise in these spectra will average out, leaving the variance spectrum. Figure 1 below illustrates these important ideas, but first we must complete the surface generation.

Step 7: Compute the inverse DFT of the (u) of Eq. (3). The result is a complex function Z(x):

Z(xr) Z(r) = 𝒟1{(u)}.

A crucial warning to this step is that the u = 0,...,N 1 elements of the (u) array must be in the FFT frequency order given by Eq. (13) of the Fourier Transforms page when using an FFT routine to evaluate the DFT. Z(r) is returned with xr values in the order from x0 = 0 to xN1 = (N 1)Δx.

Step 8: Extract the surface. The inverse DFT returns a complex array Z(xr) whose real part is the surface elevations z(xr) and whose imaginary part is 0. The surface elevations are extracted as the real part of Z(xr):

z(xr) = Re{Z(xr)}.

Step 9: Check the results! There are many places along the way to lose a 2 or to mess up array indexing. At the minimum, it is worthwhile to check that the mean of the generated surface is zero, and that the imaginary part of Z(xr) = 0 (to within a small amount of numerical roundoff error).

When developing computer code, or when first learning this material, it is also a good idea to take the forward DFT of Z(xr) to make sure that the input Fourier amplitudes (u) are recovered, and that the variance spectrum corresponding to z(xr) is consistent with the one chosen in Step 4. Indeed, it was the failure of this check in surfaces I was generating using equations from the literature that led me to develop the Mobley (2016) tutorial and these web pages.

Equations (1) and (3) are, with minor changes in notation, Eqs. (42) and (43), respectively, of Tessendorf (2004). However, Tessendorf’s version of Eq. (1) appears to use a one-sided variance spectrum (his example used the one-sided Phillips spectrum of his Eq. (40)) without the division by 2 seen in Eq. (1), which is needed to convert the one-sided spectrum to a two-sided spectrum. Nor does he show the Δk factor needed to convert a continuous spectral density to a discrete function. His version of Eq. (3) does not contain the overall factor of 12 seen above. These missing factors mean that in a round-trip calculation

variancespectrum DFT1 seasurface DFT variancespectrum,

you do not get back to the original variance spectrum. In other words, the Tessendorf equations do not conserve wave variance (i.e., wave energy). Even if he included the Δk factor in his actual computations, the missing factors of 12 in his versions of our Eqs. (1) and (3) give an overall factor one-half on the amplitudes, which corresponds to a factor of four error in the variance. That is, waves generated using the Tessendorf equations have amplitudes that are too large.

Tessendorf (2004) discusses much more than just Fourier transform techniques, and his notes have been very influential in the computer graphics industry. In 2008 he deservedly received an Academy Award for Technical Achievement for showing the movie industry how to generate and render sea surfaces, as well as for his many other pioneering accomplishments in efficiently computing and rendering fluid motions into visually appealing images. (The first movie to use his techniques was Waterworld, followed by dozens of others including Titanic.) When I checked with him about the missing numerical factors, he readily acknowledged that Eqs. (1) and (3) are the correct ones, but pointed out that “Hollywood doesn’t care about conservation of energy.” I suppose that should be no surprise, since movies seem to have no problem with rockets going faster than the speed of light, sound propagating through the vacuum of outer space, or time travel that violates causality. Tessendorf’s equations are widely cited (especially in the computer graphics literature), always without comment about the missing scale factors. Even if Tessendorf had included the needed numerical factors in his equations, graphics artists would distort the resulting images to make them look “better,” e.g., to make the ocean waves look bigger than nature would allow. That may be acceptable in a fantasy world, but such laxness is not permissible if we wish to use numerically generated waves to compute sea surface optical properties.

Example: A Roundtrip Calculation

Figure 1 shows an example of 1-D surface waves generated using the Pierson-Moskowitz spectrum for a wind speed of 5 m/s, and the recovery of the variance spectrum from the generated surface. The blue curve in the upper-left panel shows the Pierson-Moskowitz spectrum as defined by Eq. (1) on page Wave Variance Spectra: Examples. The red dots show the frequencies at which the continuous spectrum is sampled. Those dots blur together at the higher frequencies because of the log scale, but the ku points are equally spaced at intervals of the fundamental frequency Δk = kf = 2πL = 0.0628radm. The last sampled frequency is kNy = 32.17radm. The bottom panel shows the sea surface elevations z(xr) generated for a particular sequence of random numbers ρ(u),σ(u).


Figure 1: Example of a 1-D random sea surface generated from the Pierson-Moskowitz spectrum for U10 = 5ms1 (the wind speed at 10 m above mean sea level). The longest resolvable wave has wavelength L = 100m. For N = 1024, the two-point wave has wavelength 2LN = 0.195m. This is already less than the smallest wavelength (highest frequency) for which the Pierson-Moskowitz spectrum should be used. Generated by IDL routine

The red line in the upper-right panel shows the function

𝒫(u) |(u)|2 Δk = 1 Δk|𝒟{z(r)}|2. (4)

𝒫(u) is the discrete variance function for this particular z(xr) surface. Schuster (1898) called 𝒫(u) a periodogram. The periodogram 𝒫(u) contains random noise because z(xr) is a random realization of the sea surface, which was generated by applying random noise to the the variance spectrum. This particular z(xr) is analogous to a particular measurement of the sea surface. Had we drawn a difference sequence of random numbers for use in Eq. (2), we would have generated a different sea surface, and a different 𝒫(u). However, we can expect that if we average together many different 𝒫(u), corresponding to many different sets of z(xr), the noise would average out and we would be left with a curve close to the variance spectrum we started with, which is shown in blue. Numerical experimentation shows that averaging 100 𝒫(u) generated from 100 independent sea surface realizations gives an average 𝒫(u) that is almost indistinguishable from the blue curve at the scale of this plot. Thus 𝒫(u) 𝒫(ku) is an approximation of the variance density spectrum 𝒮(k), denoted 𝒫(ku)𝒮(k). This averaging processes leads to the topic of spectrum estimation, which considers such problems as how many sets of measurements of z(xr) are needed to estimate the variance spectrum to within certain error bounds. Fortunately, we need not pursue that here. (The noise is the upper right panel is Gaussian distributed about the theoretical spectrum. However, the log axis makes it look asymmetric about the blue curve.)

At the minimum, you should always check to see that Parseval’s relation, Eq. (17) of the Fourier Transforms page, is satisfied. For the simulation of Fig. 1, we have

r=0N1|z(r)|2 = N u=0N1|(u)|2 = 19.395m2.

There are sometimes other checks that can be made. For example, the Pierson-Moskowitz spectrum is simple enough that it can be analytically integrated over all frequencies. This gives

z2 =0𝒮 PM(k)dk = 3.04 103U104 g2 , (5)

where we have recalled that the variance spectral density is related to the variance of the sea surface. The variance of the generated zero-mean sea surface can be computed from

var(z) = 1 N r=0Nz2(x r) (6)

and compared with the analytical expectation. For the surface seen in Fig. 1, Eq. (6) gives var{z} = 0.0189m2 vs. the theoretical value of z2 = 0.0197m2 from Eq. (5). This agreement to within a small amount of random noise indicates that all is probably well with the calculations. Indeed, the average var(z)± one standard deviation for 100 independent simulations is 0.020 ± 0.007, which agrees well with the theoretical value.

The significant wave height H13 is by definition the height (trough-to-crest distance) of the highest one-third of the waves. To a good approximation, this is related to the expectation of the variance by

H13 = 4z2 .

In the present example, this formula gives H13 = 0.55m. The average significant wave height for 100 simulations is 0.56 ± 0.09 (average ± one standard deviation). If you spend enough time in a sea kayak to develop intuition about wave heights as a function of wind speed, a half-meter height for the largest waves is about right for a 5ms1 or 10 knot wind speed.

To summarize this page: we have learned how to start with a wave variance spectral density function and generate random discrete Fourier amplitudes. The inverse DFT of those amplitudes gives a random realization of a sea surface that is physically consistent with the chosen variance spectrum. That is all that we can ask of the Fourier transform technique.

Comments for Spectra to Surfaces: 1D:

Loading Conversation