Commit d49280f9 authored by Hafiz Emin Kosar's avatar Hafiz Emin Kosar
Browse files

- updated interactions with butterworth filter

parent 8f15ac15
......@@ -41,6 +41,8 @@ class pzPlot():
H = None
Hlog = None
P = 1 # no of poles for butterworth filter
def __init__(self, pp=np.array([0]), pz=np.array([]), ord_p=np.array([1]), ord_z=np.array([])):
self.H0 = 1
......@@ -135,9 +137,14 @@ class pzPlot():
self.w_action_type = interactive(self.update_action,action=widgets.Dropdown(options=list(self.action_types.keys()),value="Hinzufügen", description='Modus', disabled=True))
self.w_point_type = interactive(self.update_mode,mode=widgets.Dropdown(options=list(self.mode_types.keys()), value="Polstelle", description='Typ', disabled=True))
self.w_amp_type = interactive(self.update_amp, H0=widgets.IntSlider(min=1,max=10,step=1,value=1), description="H0")
self.w_no_of_poles = interactive(self.update_no_of_poles, P=widgets.IntSlider(min=1,max=7,step=1,value=1), description="P")
self.VBox_AMP = VBox([self.w_filter_type, self.w_amp_type]) # vertical box for displaying H0
self.VBox_Butter = VBox([self.w_filter_type, self.w_no_of_poles]) # vertical box for displaying no. of poles (only for butterworth)
self.VBox_mode_type = VBox([self.w_action_type, self.w_point_type]) # vertical box action type and point type
self.w_hbox = HBox([self.VBox_AMP, self.VBox_mode_type])
self.w_hbox = HBox([VBox([self.w_filter_type, self.w_amp_type]),
VBox([self.w_action_type, self.w_point_type])])
display(self.w_hbox)
def find_closest_point(self, p, mode='n'):
......@@ -307,6 +314,11 @@ class pzPlot():
self.update_plot()
def update_no_of_poles(self, P):
self.P = P
if self.w_filter_type.kwargs['filtr'] == 'Butterworth': # skip execution on startup
self.update_filter('Butterworth')
def update_filter(self, filtr):
self.filter = self.filter_types[filtr]
......@@ -314,17 +326,23 @@ class pzPlot():
ord_poles_butr = np.array([])
# calculate butterworth poles and orders
if filtr == 'Butterworth' :
# TODO - Filtergrad und -grenzfrequenz anpassen
filtergrad = 2
filtergrenzfrequenz = 1
# TODO - self.H0 je nach Filtergrad und -grenzfrequenz ändern
if filtr == 'Butterworth':
# show slider for no of poles (filtergrad)
self.w_hbox.children = [self.VBox_Butter, self.VBox_mode_type]
filtergrad = self.P
filtergrenzfrequenz = 1 # omega_g = 1
tmp = (np.linspace(0, filtergrad - 1, num=filtergrad) + 0.5) / filtergrad * np.pi + np.pi / 2
tmp = tmp[np.where(tmp <= np.pi)[0]]
poles_butr = np.array(filtergrenzfrequenz * np.exp(1j * tmp))
ord_poles_butr = np.array(np.ones(poles_butr.shape), dtype=int)
else:
# show slider for H0
self.w_hbox.children = [self.VBox_AMP, self.VBox_mode_type]
# clear plot
def clear_all_points():
tmp = list(self.pp) + list(self.pz)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment