Skip to content
Snippets Groups Projects
Commit d2140911 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Put pfb_os and rtdsp in new separate repository rtdsp.

parent 189cebdb
No related branches found
No related tags found
No related merge requests found
Pipeline #102010 passed with warnings
Showing
with 0 additions and 11659 deletions
Author: Eric Kooistra, nov 2023
* Practise DSP [1].
* Try to reproduce LOFAR subband filter FIR coefficients using scipy instead
of MATLAB.
The pfs_coeff_final.m from the Filter Task Force (FTF) in 2005 use fircls1
with r_pass and r_stop to define the ripple. In addition it post applies a
Kaiser window with beta = 1 to make the filter attenuation a bit more deep
near the transition. The pfir_coeff.m from Apertif also uses fircls1.
Both use fircls1 with N = 1024 FIR coefficients and then Fourier
interpolation to achieve Ncoefs = 1024 * 16 FIR coefficients. Both scripts
can not exactly reproduce the actual LOFAR1 coefficients, therefore these
are loaded from a file Coeffs16384Kaiser-quant.dat
* Try low pass filter design methods using windowed sync, firls, remez [4]
The windowed sync method, firls leased squares method and remez method all
yield comparable results, but firls and remez perform slightly better near
the transition band. The firls and remez functions from scipy.signal use
transition bandwidth and weights between pass and stop band to influence
the transition region and ripple. For remez the ripple is constant in the
pass band and stop band, for firls the ripple is largest near the band
transition.
* It is possible to design a good FIR filter using Python scipy. Possibly with
some extra help of a filter design and analysis (FDA) tool like pyfda [2].
[1] dsp_study_erko.txt, summary of DSP books
[2] pyfda, dsp, at https://github.com/chipmuenk
[3] python package rtdsp, for radio telescope DSP investigations in Python
[4] python jupyter notebooks
* Try FIR filter design methods
- rectangular_window_and_ideal_lpf.ipynb
- filter_design_windowed_sync.ipynb
- filter_design_firls.ipynb
- filter_design_remez.ipynb
* Try Hilbert transform
- hilbert_transform_design.ipynb
- hilbert_transform_application.ipynb
* Try IIR filter design methods
- iir_filter.ipynb
* Try multirate processing
- up_down_sampling.ipynb
- narrowband_noise_generator.ipynb
* Try polyphase filterbanks
- one_pfb.ipynb
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id:ea8e78bf tags:
# Filter design based on complementary error function (erfc)
Author: Eric Kooistra, Jun 2024
Purpose:
* Practise DSP [1].
* Design filter based on the complementary error function erfc = 1 - erf, as used in [2]
Description:
The erfc() is point symmeric around (0, 1) and decreases from 2 at -inf to 0 at +inf.
The shape of the erfc() is used as the template for the transfer function of a filter.
The advantage of using the erfc(), compared to e.g. a raised cosine filter with roll off beta, is that the shape has no discontinuities.
References:
1. dsp_study_erko, summary of DSP books
2. near perfect reconstruction, W. Lubberhuizen
%% Cell type:code id:7bf5ef09 tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
from scipy import special
```
%% Cell type:code id:01918bc7 tags:
``` python
K = 4
Ndft = 16
Ntaps = 8
Ncoef = Ndft * Ntaps
F = np.arange(Ncoef) / Ncoef
x = K * (Ndft * F - 0.5)
A = 0.5 * special.erfc(x)
plt.plot(A)
plt.xlim((0,Ntaps))
print('%e' % A[0])
print('%e' % A[20])
print('%e' % A[-1])
```
%% Output
9.976611e-01
5.612149e-30
0.000000e+00
%% Cell type:code id:4611e655 tags:
``` python
```
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Radio Telescope Digital Signal Processing (RTDSP) python package.
## Description
The RTDSP package contains DSP functions for experimenting with DSP in Python jupyter notebooks.
## Usage in jupyter notebook cell:
```
# Auto reload module when it is changed
%load_ext autoreload
%autoreload 2
# # Alternative auto reload module:
# import importlib
# importlib.reload(dsp)
# Add rtdsp module path to $PYTHONPATH
import os
import sys
module_path = os.path.abspath(os.path.join('<relative from notebook or absolute path to module>'))
if module_path not in sys.path:
sys.path.insert(0, module_path)
# Import
from rtsdp.firfilter import <list of items>
# or
import rtsdp.firfilter as firfilter
```
"""Init file for the Radio Telescope Digital Signal Processing (RTDSP) package.
Modules:
. utilities : Basic functions used in the other modules
. windows : Windows functions for filter design
. fourier : DFT based functions
. hilbert : Hilbert transform
. firfilter : FIR filter design
. iirfilter : IIR filter design
. multirate : Multirate functions for resampling
. singlechannel : Single channel downconverter downsampler and single channel
upconverter upsampler, using LO
. dftfilterbank : Multi channel analysis filterbank and multi channel synthesis
filterbank, using DFT and IDFT
. plotting : Plotting impulse responses and spectra
References:
[1] dsp_study_erko.txt
[2] https://github.com/chipmuenk, with dsp library and pyfda = python filter design analysis tool
"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment