
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - ihfft() Function
The SciPy ihfft() method is a specialized function to perform the inverse FFT on Hermitian symmetric data, which converts frequency domain representations into time domain signals. It is very useful for the processing of real-world signals where the time-domain data is real-valued, and Hermitian symmetry is effective in handling frequency domain data.
This technology finds in many applications that involve audio signal processing, biomedical engineering (EEG/ECG analysis), and real-time communication systems. It ensures that frequency spectrum attributes are preserved after back transformation to the time domain.
Unlike a simple inverse FFT, ihfft can only be used for Hermitian symmetric inputs to guarantee a real valued result in the time domain.
Using ihfft with non-Hermitian symmetric data produces incorrect or complex values. Mismatched n values can lead to truncation or zero padding, which reduces reconstruction accuracy. Invalid axes raise IndexErrors, and inconsistent normalization modes can introduce amplitude scaling errors.
Syntax
The syntax for the SciPy ihfft() method is as follows −
.ihfft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, *, plan=None)
Parameters
This method accepts the following parameters −
x (array_like) − Input array containing the frequency-domain data.
n (int, optional) − Specifies the length of the inverse FFT. If n is smaller than the input length, the data is truncated; if larger, it's zero-padded.
axis (int, optional) − Determines the axis over which to compute the inverse FFT. The default is the last axis.
norm (str, optional) − Defines the normalization mode. Options include "backward", "ortho", and "forward", affecting the scaling of the FFT and its inverse.
overwrite_x (bool, optional) − If set to True, allows the function to overwrite the input data, which can improve performance.
plan (object, optional) − Precomputed plan for FFT optimization (advanced use). Default is None.
Return Value
out (ndarray) − The real-valued time-domain signal computed from the Hermitian symmetric frequency spectrum.
Example 1: Reconstructing Time-Domain Signal with ihfft
The below code is the basic example of SciPy ihfft() applied to a real-valued signal to reconstruct frequency domain into time domain accurate time-domain restoration, enabling analysis, filtering, and manipulation of signals in their natural domain. Following is the code −
import numpy as np from scipy.fft import hfft, ihfft # Original time-domain signal time_data = np.array([1, 2, 3, 2, 1]) # Real-valued signal # Transform to Hermitian symmetric frequency spectrum freq_data = hfft(time_data) # Reconstruct the time-domain signal using ihfft reconstructed_signal = ihfft(freq_data) print("Hermitian Symmetric Frequency Spectrum:", freq_data) print("Reconstructed Signal:", reconstructed_signal)
When we run above program, it produces following result
Hermitian Symmetric Frequency Spectrum: [16. 0. -4. 0. 0. 0. -4. 0.] Reconstructed Signal: [1.+0.j 2.-0.j 3.+0.j 2.-0.j 1.+0.j]
Example 2: Truncated Signal Reconstruction Using Output Length (n
If the input length is less than n, it is truncated, which may result in loss of essential information.
In the below code we have created a array with the input length m=5, and applied ihfft() with output length parameter (n=3 i.e, n demonstrating how the parameter controls the output length. Following is the code −
import numpy as np from scipy.fft import ihfft # Hermitian symmetric input freq_data = np.array([0.0, 0.3, 0.8, 0.3, 0.0]) time_signal = ihfft(freq_data, n=3) print("Truncated Signal:", time_signal)
Following is an output of the above code −
Truncated Signal: [ 0.36666667+0.j -0.18333333-0.14433757j]
Example 3: Audio Compression with ihfft
In audio signal processing, ihfft is used to reconstruct a time-domain signal after removing frequencies considered inaudible to humans. Therefore, it simulates audio compression.
The below code, performs lossy compression using the deletion of lower magnitudes frequencies in the spectrum, reconstructing the signal to its time domain using ihfft() method. This is widely used in such approaches like compression of audio format including mp3 to optimize storage while keeping quality on acceptable levels.
import numpy as np from scipy.fft import hfft, ihfft audio_signal = np.array([0.5, 0.7, 1.0, 0.7, 0.5]) freq_data = hfft(audio_signal) # Apply lossy compression by zeroing out high frequencies compressed_freq_data = np.where(np.abs(freq_data) > 0.6, freq_data, 0) # Reconstruct the compressed audio signal compressed_audio_signal = ihfft(compressed_freq_data) print("Original Signal:", audio_signal) print("Compressed Frequency Spectrum:", compressed_freq_data) print("Reconstructed Compressed Signal:", compressed_audio_signal)
Following is an output of the above code −
Original Signal: [0.5 0.7 1. 0.7 0.5] Compressed Frequency Spectrum: [ 5.8 0. -1. 0. 0. 0. -1. 0. ] Reconstructed Compressed Signal: [0.475+0.j 0.725-0.j 0.975+0.j 0.725-0.j 0.475+0.j]
Example 4: Inconsistent Normalization Modes
The inconsistency of normalization modes between the hfft, and the inverse FFT, ihfft, leads to amplitude scaling problems that reduces the accuracy of the reconstructed signal.
This example illustrates how using the default "backward" normalization in hfft() and "ortho" in ihfft() leads to amplitude mismatches. Avoiding this requires using consistent normalization, such as "ortho" for both transforms, which preserves energy and achieves accurate reconstruction.
import numpy as np from scipy.fft import hfft, ihfft time_data = np.array([1, 2, 3, 2, 1]) # Forward transform with default normalization ("backward") freq_data = hfft(time_data) # Inverse transform with "ortho" normalization reconstructed_signal = ihfft(freq_data, norm="ortho") print("Hermitian Symmetric Frequency Spectrum:", freq_data) print("Reconstructed Signal with 'ortho' normalization:", reconstructed_signal)
Following is an output of the above code −
Hermitian Symmetric Frequency Spectrum: [16. 0. -4. 0. 0. 0. -4. 0.] Reconstructed Signal with 'ortho' normalization: [2.82842712+0.j 5.65685425-0.j 8.48528137+0.j 5.65685425-0.j 2.82842712+0.j]