Wave Walker DSP

DSP Algorithms for RF Systems

New Posts Wednesday!

Most Popular

Half Band Filter Design Function in Python
December 8, 2021

Table of Contents

Introduction

The half band filter is an incredibly efficient filter useful in a number of applications as well as a great starting point for understanding fundamental DSP concepts. Previous posts covered the design of the filter weights and how to optimize the filter structure for computational efficiency. This blog posts simplifies the design of the half band filter weights using a Python function.

Don’t forget to check out the other posts on the half band filter:

Half Band Filter Design Function

The design function halfBandDesign.py can be downloaded from the WaveWalkerDSP GitHub page. The function is called by:

from halfBandDesign import halfBandDesign
weights = halfBandDesign(filterLength,transitionBand)

where filterLength is the length of the filter and transitionBand is the normalized bandwidth of the transition band.

The parameter filterLength must be an integer greater than 6 such that filterLength+1 is divisible by 4. For example, filterLength can be 7, 11, 15 or 19. This avoids a situation where a zero weight is added to the beginning and end of the filter’s impulse response which is wasted computation. The parameter transitionBand must be greater than 0 and less than 0.5.

The function performs error checking on the input parameters to make sure the weights are generated to maximize efficiency, abstracts the Remez design function call and forces all even index weights to be exactly zero.

Example Half Band Filter Design

Figure 1 and Figure 2 give the impulse response and frequency response when halfBandDesign.py is called with filterLength=19 and transitionBand=0.1.

Figure 1: An example impulse response for a half band filter designed with halfBandDesign.py.
Figure 1: An example impulse response for a half band filter designed with halfBandDesign.py.
Figure 2: An example frequency response for a half band filter designed with halfBandDesign.py.
Figure 2: An example frequency response for a half band filter designed with halfBandDesign.py.

Takeaway

The halfBandDesign.py function designs an efficient half band filter. The error checking on the parameters force the weights to be designed with maximum computational efficiency.

Have you seen the other posts on the half band filter?

Leave a Reply