Signal processing
In this section, we are going to use NumPy functions to simulate several signal functions and translate them to Fourier transforms. We will focus on using numpy.fft
and its related functions. We hope after this section that you will get some sense of using a Fourier transformation in NumPy. The theory part will be covered in the next section.
The first example we are going to use is our heartbeat signal, which is a series of sine waves. The frequency is 60 beats per minutes (1 Hz), and our sampling period is 5 seconds long, with a sampling interval of 0.005 seconds. Let's create the sine wave first:
In [1]: time = np.arange(0, 5, .005) In [2]: x = np.sin(2 * np.pi * 1 * time) In [3]: y = np.fft.fft(x) In [4]: show(x, y)
In this ...
Get NumPy Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.