PyDynamic
PyDynamic copied to clipboard
Need for seperate high pass or low pass filter identification
The current filter design function(s) like LSIIR(...) try to fit a generic band-pass without any boundary conditions in the frequency range. Sometimes it is useful to limit the class of filters to either high- or low-pass in order to focus on the modelling of a specific characteristic of a system. For high-pass that means
- |H| decay to zero in the limit of f=0 Hz
- |H| converge to a constant k>0 for f-> infinity
For a low pass it's kind of inverse
- |H| decay to zero for f-> infinity
- |H| converge to a constant for f->0 in this case the denominator polynomial order has to be higher than the enumerator (I think).
I ask for a new feature to get the functionality to decide the filter class for the fitting process to be high-, low- or band-pass, where "band-pass" means the current implementation.
We probably can utilize scipy.optimize.lsq_linear to achieve the desired behaviour during the fitting routine. We could introduce a bounds parameter to allow for user specified boundaries as specified in lsq_linear's documentation. A second step might be preparing common preset bounds like "high", "low".
This is the result of today's discussion between @mgrub and @BjoernLudwigPTB .
@bruns01 Would a reference implementation to clone and try out be sufficient? Otherwise we could prepare a release candidate to allow for installation something like pip install PyDynamic==1.4.4-rc
.
- A reference implementation for testing is welcome.
- I remember to have encountered problems with linear fit approximation in my own attempts. I blamed the rational function vs. linear fitting issue for the dissimilarity of the outcome. However, the current LSIIR functions do follow a linear fitting scheme, too, if I remember correctly. Hence, this would mean a totally different story.
This commit could possibly resolve the issue already for
bounds = (np.array([b0, -np.inf, ..., -np.inf]), np.array([b0, np.inf, ..., np.inf]))
with preceding b0=0
for the high-pass and b0=S0
for the low-pass. We will carry on with some thorough testing from next week tuesday.
The call should work as before with appended bounds parameter:
a, b, tau = LSIIR( Hvals, Nb, Na, f, Fs, bounds=bounds)
@bruns01 To test this implementation setup a test environment and install PyDynamic via
pip install git+https://github.com/PTB-PSt1/PyDynamic.git@improve_LSIIR
We adapted the corresponding example as noted above. Please observe, if this fits your needs. We would be really happy to hear if this is, what you were looking for.
We close this now as it stalled long time ago.