Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fc does not update filter properly #15

Closed
josef-dunbar opened this issue Oct 22, 2015 · 6 comments
Closed

Fc does not update filter properly #15

josef-dunbar opened this issue Oct 22, 2015 · 6 comments

Comments

@josef-dunbar
Copy link

First of this tool looks great! thank you so much for your effort in putting this together.

I'm trying to use this to plot / design low and high pass filters though noticed that in changing the Fc value the filters are not changing. The filters always seem to be calculated using the default Fc value for the filter type. Is there a known work around for this issue? The filter order does seem to be working properly.

@chipmuenk
Copy link
Owner

Thanx for filing the issue, this is a regression that came with one the last major reworks. For the moment, try switching between minimum and manual order to enter corner frequencies.

@josef-dunbar
Copy link
Author

Thank you for responding so quickly. I tried your solution and still do not see the F_PB and F_SB values having an affect on the filter. They also do not seem to be updating the "Show Specs" plot either. I am able to coerce your program to use alternate values of F_C by changing the default value in the fil[0] dictionary so I'm thinking it may just be an issue with updating the values in this structure. I'm really interested in getting this working, trying to wean a colleague off matlab, and this looks like the best tool out there for our work flow. I'll keep looking around to see if I can figure it out- though any direction is always appreciated.

@chipmuenk
Copy link
Owner

Thank you for your patience and your encouraging words - I'm very interested in feedback (and in getting colleagues to try python ;-) ! Currently, I'm finishing several fixes for the input widgets in a separate branch that I'm going to merge over the weekend. I'll try fix the bugs concerning the frequency specs then as well. The major suspects are the input_target_specs widgets, the calculation of design frequency specs from the target specs in the filter design routines and the spaghetti code of signals and slots that I'm currently untangling. Hopefully, things look better on Monday!

@chipmuenk
Copy link
Owner

Should be fixed in latest (pre-)release - please give it a try. Further feedback is most welcome!

@josef-dunbar
Copy link
Author

Looks great! Thank you for the update. I'm noticing some issues with numerical precision with tight filter constraints due to the use of the transfer function polynomial in the calculation of Group Delay and Frequency Response. I was able to get the Group Delay to behave better using ZPK in the calculation (code below). It seems that the Frequency Response can be tamed by using the coefficients from an analog filter though these coefficients then must be transformed for the phase and group delay plots.... If you're interested it might be worth wile to hold both the analog and digital filter coefficients in the dictionary.

'''
add to pyfda/plot_widgets/plot_tau_g.py (line 82) 
remove/comment out currently defined w and tau_g variables
'''
        zz = fb.fil[0]['zpk'][0]
        pp = fb.fil[0]['zpk'][1]

        G = np.zeros(rc.params['N_FFT'])
        w = np.arange(0,1, 1/rc.params['N_FFT']) * np.pi
        for i in range(zz.shape[0]):
            rz = np.abs(zz[i])
            az = np.angle(zz[i])
            G += (-rz*np.cos(w-az) + rz**2) / (rz**2 - 2*rz*np.cos(w-az) + 1)
        for i in range(pp.shape[0]):
            rp = np.abs(pp[i])
            ap = np.angle(pp[i])
            G -= (-rp*np.cos(w-ap) + rp**2) / (rp**2 - 2*rp*np.cos(w-ap) + 1)
        tau_g = G

@chipmuenk
Copy link
Owner

Thank you for the input - could you be so kind to file this as separate issue? And could you give an example which filter design method you mean? I've noticed precision issues as well when the magnitude response is less than ~ -250 dB .
I'll look at the difference between the algorithm in pyfda_lib.group_delay (where we should implement any changes) and yours. And I'd also like to try endolith's enhancements in scipy 0.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants