Skip to content

Characterizing Wave-like Data: Extracting Angular Frequency and Wavelength

Published: at 04:30 PM

I’ve never considered myself a modeler or theoretical physicist. Even now, as I find myself modifying model source code, I still view it as territory outside my comfort zone. My true strength has always been in data - handling it, analyzing it, and bringing it to life through visualization.

Recently, my work has shifted from analyzing observational data to examining simulation outputs, putting these analytical skills to a new kind of test. This transition has led me to explore various tools for characterizing wave-like behavior in discrete data, whether it comes from observations or simulations. In this post, I want to share some key insights I’ve gained about one of these analytical tools and their applications.

Waves

We all know waves. They are curvy, periodic, and they move. The simplest scenario of wave is that which travels along one dimension over time. It’s described by the following second-order linear partial differential equation,

2 ut2=c22ux2 \frac{\partial^2\ u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2}

where cc is the wave speed.

A wave can take any forms, take for example the 1D standing waves below. The total wave (standing wave) is made up of two wave modes, a negative and positive traveling wave modes. The wave evolves over time, at each position of the x-axis the amplitude changes over time.

1D Wave Equation Animation

Then we can have a 2D wave function, where the amplitude at x- and y- coordinates in a system change and evolve over time as shown below,

2D Wave Function

It may be the case that you have observations or simulation outputs in any shape or number of dimensions that has an underlying wave-like behaviour. In this case you may want to use certain tools to analyze your data, and extract the characteristics within the data.

A wave

Let’s create a simple wave dataset. We’ll generate a sinusoid that moves through space and time (1D) with a decreasing amplitude in the spatial direction:

u(x,t)=A(x)sin(2πtϕ(x)),(1)u(x,t) = A(x) \sin{\left(2 \pi t - \phi(x)\right)}, \tag{1}

where ϕ(x)=2x\phi(x) = 2 x, and A(x)=ex/5A(x)= e^{-x/5}. Here, 55 represents the decay length scale.

For a general sinusoidal function sin(kxωt)\sin(kx - \omega t), the angular frequency ω\omega is the coefficient of tt. In Equation 1, we have sin(2πtφ(x))\sin(2\pi t - \varphi(x)). Comparing this to the standard form, we see ω=2π\omega = 2\pi radians per unit time.

To find the wavelength λ\lambda, we look at how φ(x)\varphi(x) changes. Since φ(x)=2x\varphi(x) = 2x, one wavelength corresponds to a phase change of 2π2\pi. Thus, 2Δx=2π2\Delta x = 2\pi and Δx=π\Delta x = \pi. Therefore, λ=π\lambda = \pi.

Here’s what the wave described by Equation 1 looks like at different spatial distances (xx):

Wave propagation Figure: Visualization of the wave defined by Equation 1 over time and the x-positions with added noise.

Of course I added noise to make the example more realistic as scientists usually deal with background signals like noise. The vertical dashed lines in the plot will serve a purpose below. The question now is how do we characterize this wave? In the real world we don’t know the underlying equation, so I am interested in extracting the period and spatial wavelength straight from the signal.

Phase computation

To characterize wave-like features in our data, let’s pick six evenly spaced spatial locations, let’s say x=0,1,2,3,5x=0,1,2,3,5, the same vertical dashed lines on the figure above. Next we take the time evolution of the amplitude uu at those locations, and we will compute the analytic signal of each time series, using the Hilbert transform.

💡

Here is a short AI generated discussion on the Hilbert transform for more information. Source: The Hilbert transform by Mathias Johansson

The analytic signal is a complex-valued representation of a real-valued signal. It’s formed by taking the original signal and adding its Hilbert transform as its imaginary component. We can visualize it as a point moving in the complex plane: 1D Wave Equation Animation Figure: Visualization of the analytic signal in the complex plane. Top shows the imaginary component, and the bottom shows the real component. Left hand side shows the complex plane.

At each moment in time, the analytic signal’s value corresponds to a point in this plane (left hand side of figure).

The Hilbert transform, by providing the imaginary component of the analytic signal, enables us to calculate this phase. This is done by calculating the angle of the point on the plane,

φ=arctan(Im[sa(t)]Re[sa(t)])\varphi = \arctan{\left( \frac {\mathfrak{Im}[s_a(t)]} {\mathfrak{Re}[s_a(t)]} \right)}

Now we can visualize the unwrapped phase over time, that is the progression of the wave propagation over time: alt text Figure: Visualization of the wave unwrapped phase over time

Here we see the wave progresses linearly over time, that is straight lines, indicating no acceleration or change in propagation rate. The Hilbert transform and the analytic signal reveal how the signal’s frequency changes over time, making them essential tools for analyzing complex, evolving signals.

The time for the phase to change by 2π2\pi corresponds to one period. By calculating the slope of the phase vs. time plot, we can determine the frequency and, subsequently, the period of the wave.

We observe different phase offsets for various x-positions, with each color line shifted up or down,indicating spatial propagation of the wave. This phase offset θx\theta_x varies at each spatial location. To better visualize this, we can examine the unwrapped phase over spatial distance at fixed timesteps:

alt text

This plot shows the wave’s progression along the x-direction. The slope of the line relates to the wavelength λ\lambda. A steeper slope indicates a shorter wavelength. The phase offset θt\theta_t here is due to time evolution, not spatial evolution.

Both θt\theta_t and θx\theta_x are functions of tt and xx respectively, but since we are drawing the wave snapshots at fixed tt and xx, we can see how the phase evolves at constant phases offsets, and give us information about the underlying angular frequency ω\omega, and wavelength λ\lambda of the wave. In fact, we know

φt=ω,andφx=k=2πλ \frac{\partial \varphi}{\partial t} = \omega, \quad \text{and} \quad \frac{\partial \varphi}{\partial x} = k = \frac{2 \pi}{\lambda}

By fitting a line and extracting the slopes we can come up with estimates to ω\omega and λ\lambda. In this experiment we get, ω6.284\omega \approx 6.284, and λ3.1761\lambda \approx 3.1761. These numbers should be familiar since they are 2π2 \pi and π\pi respectively (with a margin of error).

These are exactly the properties embedded in the signal by Equation 1! Therefore, we successfuly characterized the underlying wave in the data by obtaining,

In practice, these values can be the frequency of a sound wave, or the wavelength of a perturbation traveling through the atmosphere.

Conclusion

In this post, we explored the characterization of wave-like data using a combination of mathematical tools and visualization techniques. By generating a simple wave dataset and applying the Hilbert transform, we were able to extract key wave properties such as the angular frequency and wavelength. This approach demonstrates the power of combining theoretical knowledge with practical data analysis skills to uncover underlying patterns in complex datasets. Whether dealing with observational data or simulation outputs, these methods provide a robust framework for analyzing wave phenomena in various scientific fields.


Next Post
Stress Tensors in Spherical Coordinates: A Quick Dive