Skip to content

IFFT

Download Flojoy Studio to try this app
Perform the Inverse Discrete Fourier Transform on an input signal. With the IFFT algorithm, the input signal will be transformed from the frequency domain back into the time domain. Inputs ------ default : OrderedPair The data to apply inverse FFT to. Params: real_signal : boolean whether the input signal is real (true) or complex (false) Returns: out : OrderedPair x = time y = reconstructed signal
Python Code
from scipy import fft
from flojoy import flojoy, OrderedPair, DataFrame
import pandas as pd


@flojoy
def IFFT(default: DataFrame, real_signal: bool = True) -> OrderedPair:
    """Perform the Inverse Discrete Fourier Transform on an input signal.

    With the IFFT algorithm, the input signal will be transformed from the frequency domain back into the time domain.

    Inputs
    ------
    default : OrderedPair
        The data to apply inverse FFT to.

    Parameters
    ----------
    real_signal : boolean
        whether the input signal is real (true) or complex (false)

    Returns
    -------
    OrderedPair
        x = time
        y = reconstructed signal
    """

    dc: pd.DataFrame = default.m

    x = dc["x"].to_numpy()
    realValue = dc["real"].to_numpy()
    imagValue = dc["imag"].to_numpy()

    fourier = realValue + 1j * imagValue

    result = fft.irfft(fourier) if real_signal else fft.ifft(fourier, len(x))
    result = result.real
    return OrderedPair(x=x, y=result)

Find this Flojoy Block on GitHub

Example App

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

In this example, LINSPACE generates an array of 600 samples, which would be the value of step. The sample rate in this case is 800, so the end parameter is samples/sample_rate = 0.75.

The generated array is then passed down to two SINE nodes, with one generating a sine wave of 50hz with 1 amplitude, and the other generating a sine wave of 80hz with 0.5 amplitude.

Then the sine wave is passed down to three different nodes, first a LINE node to display what it looks like. Then two FFT nodes, one of which have the display option set to true, and then passed to another LINE node to display the signal in the frequency domain. The other FFT node has the display option set to false in order to preserve the raw data, which isn’t used for displaying.

Finally, FFT node containing the raw data passes to an IFFT node, which performs the inverse fourier transform, changing the basis from the frequency domain back into the time domain. Since no modification is made(which we could’ve done), the signal come out the same as the original.