From f3de651428ee93d68869df3fb64b9212753b8487 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:23:48 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy_fft_1/README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/numpy_fft_1/README.md b/numpy_fft_1/README.md index 7440453..1c7e5e5 100644 --- a/numpy_fft_1/README.md +++ b/numpy_fft_1/README.md @@ -19,5 +19,38 @@ y: np.ndarray = np.sin(t * 2 * np.pi * frequency_hz) ``` ![figure 1](figure_1.png) - +## Fourier transform with rfft + +Since we deal with non-complex waveforms (i.e. only real values) we should use rfft. This is faster and uses less memory. + +### 1 dimension + + +| | | +| ------------- |:-------------:| +| [numpy.fft.rfft](https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html) | Compute the one-dimensional discrete Fourier Transform for real input. | +| [numpy.fft.irfft](https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html) | Computes the inverse of [rfft](https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html#numpy.fft.rfft). | +| [numpy.fft.rfftfreq](https://numpy.org/doc/stable/reference/generated/numpy.fft.rfftfreq.html) | Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft). | + +### 2 dimensions + +| | | +| ------------- |:-------------:| +| [numpy.fft.rfft2](https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html) | Compute the 2-dimensional FFT of a real array. | +| [numpy.fft.irfft2](https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html) | Computes the inverse of rfft2. | + +### N dimensions + +| | | +| ------------- |:-------------:| +| [numpy.fft.rfftn](https://numpy.org/doc/stable/reference/generated/numpy.fft.rfftn.html) | Compute the N-dimensional discrete Fourier Transform for real input. +| [numpy.fft.irfftn](https://numpy.org/doc/stable/reference/generated/numpy.fft.irfftn.html) | Computes the inverse of rfftn. + + +Since we deal with a 1 dimensional time series + +```python +y_fft: np.ndarray = np.fft.rfft(y) +frequency_axis: np.ndarray = np.fft.rfftfreq(y.shape[0]) * sampling_frequency +```