Saturday, July 4, 2015

Simple Cosine Wave UI: illustrating frequency and phase

A new simple user interface has been added to github: SimpleCosineWaveUI! It's not terribly advanced, but it does illustrate two fundamental concepts in exploration geophysics: frequency and phase. The UI graphs a plot of: $$ f(t) = cos(2\pi ft+\phi ) $$ The two sliders at the bottom of the page allow the user to change the frequency and the phase of the signal and interactively view how those changes affect the plot. A "RESET" button is added that sets the phase and frequency of the signal back to zero. Finally, if you would like to see the waves with the area under of the curve filled in, click the check box "add fill". It does make the plot visually more interesting and allows the user to see more in my opinion.

A few of the details for those not interested in scanning through the code:

The minimum time and maximum time of the plot is set to zero and one second, respectively. The interval between samples is 0.001 seconds or one millisecond. Many of you will immediately jump to the fact that that means the sampling frequency (or sampling rate) is 1000 Hz (Fs = 1/dt), and thus the Nyquist frequency is 500 Hz. Although, technically you could reconstruct any frequency (NOT THE SIGNAL ITSELF NECESSARILY, a discussion tabled for another UI) up to Nyquist frequency, I have limited the frequency range from 0 to 100 Hz.

There are 2 interesting things that will notice after playing with the UI:(1) a cosine wave with zero frequency is a linear function with zero slope. In other words a constant: $ f(t) = C $. (2) an increase in phase (moving the phase slider to the right) causes the function to appear to move to the left. The function has undergone a negative translation or time delay. Both of these phenomena will be discussed in a later post and accompanying UI or IPython notebook. For now, it is important to recognize them.

Below are some screenshots. I hope you enjoy this tool and maybe even learn something.

No comments:

Post a Comment