Package plot_widgets

Package providing widgets for plotting various time and frequency dependent filter properties

plot_tab_widgets

Create a tabbed widget for all plot subwidgets in the list fb.plot_widgets_list. This list is compiled at startup in pyfda.tree_builder.Tree_Builder, it is kept as a module variable in pyfda.filterbroker.

class pyfda.plot_widgets.plot_tab_widgets.PlotTabWidgets(parent)[source]
eventFilter(source, event)[source]

Filter all events generated by the QTabWidget. Source and type of all events generated by monitored objects are passed to this eventFilter, evaluated and passed on to the next hierarchy level.

This filter stops and restarts a one-shot timer for every resize event. When the timer generates a timeout after 500 ms, current_tab_redraw() is called by the timer.

log_rx(dict_sig=None)[source]

Enable self.sig_rx.connect(self.log_rx) above for debugging.

plot_hf

The Plot_Hf class constructs the widget to plot the magnitude frequency response |H(f)| of the filter either in linear or logarithmic scale. Optionally, the magnitude specifications and the phase can be overlayed.

class pyfda.plot_widgets.plot_hf.Plot_Hf(parent)[source]

Widget for plotting |H(f)|, frequency specs and the phase

calc_hf()[source]

(Re-)Calculate the complex frequency response H(f)

draw()[source]

Re-calculate |H(f)| and draw the figure

draw_inset()[source]

Construct / destruct second axes for an inset second plot

draw_phase(ax)[source]

Draw phase on second y-axis in the axes system passed as the argument

init_axes()[source]

Initialize and clear the axes (this is run only once)

plot_spec_limits(ax)[source]

Plot the specifications limits (F_SB, A_SB, …) as hatched areas with borders.

process_sig_rx(dict_sig=None)[source]

Process signals coming from the navigation toolbar and from sig_rx

redraw()[source]

Redraw the canvas when e.g. the canvas size has changed

update_view()[source]

Draw the figure with new limits, scale etc without recalculating H(f)

pyfda.plot_widgets.plot_hf.classes = {'Plot_Hf': '|H(f)|'}

display name

Type:Dict containing class name

plot_phi

Widget for plotting phase frequency response phi(f)

class pyfda.plot_widgets.plot_phi.Plot_Phi(parent)[source]
calc_resp()[source]

(Re-)Calculate the complex frequency response H(f)

draw()[source]

Main entry point: Re-calculate |H(f)| and draw the figure

init_axes()[source]

Initialize and clear the axes - this is only called once

process_sig_rx(dict_sig=None)[source]

Process signals coming from the navigation toolbar and from sig_rx

redraw()[source]

Redraw the canvas when e.g. the canvas size has changed

update_view()[source]

Draw the figure with new limits, scale etc without recalculating H(f)

pyfda.plot_widgets.plot_phi.classes = {'Plot_Phi': 'φ(f)'}

display name

Type:Dict containing class name

plot_tau_g

Widget for plotting the group delay

class pyfda.plot_widgets.plot_tau_g.Plot_tau_g(parent)[source]

Widget for plotting the group delay

calc_tau_g()[source]

(Re-)Calculate the complex frequency response H(f)

init_axes()[source]

Initialize and clear the axes

process_signals(dict_sig=None)[source]

Process signals coming from the navigation toolbar and from sig_rx

redraw()[source]

Redraw the canvas when e.g. the canvas size has changed

update_view()[source]

Draw the figure with new limits, scale etc without recalculating H(f)

pyfda.plot_widgets.plot_tau_g.classes = {'Plot_tau_g': 'tau_g'}

display name

Type:Dict containing class name

plot_pz

Widget for plotting poles and zeros

class pyfda.plot_widgets.plot_pz.Plot_PZ(parent)[source]
draw_Hf(r=2)[source]

Draw the magnitude frequency response around the UC

draw_pz()[source]

(re)draw P/Z plot

init_axes()[source]

Initialize and clear the axes (this is only run once)

process_sig_rx(dict_sig=None)[source]

Process signals coming from the navigation toolbar and from sig_rx

redraw()[source]

Redraw the canvas when e.g. the canvas size has changed

update_view()[source]

Draw the figure with new limits, scale etcs without recalculating H(f) – not yet implemented, just use draw() for the moment

zplane(b=None, a=1, z=None, p=None, k=1, pn_eps=0.001, analog=False, plt_ax=None, plt_poles=True, style='square', anaCircleRad=0, lw=2, mps=10, mzs=10, mpc='r', mzc='b', plabel='', zlabel='')[source]

Plot the poles and zeros in the complex z-plane either from the coefficients (b,`a) of a discrete transfer function `H`(`z) (zpk = False) or directly from the zeros and poles (z,p) (zpk = True).

When only b is given, an FIR filter with all poles at the origin is assumed.

Parameters:
  • b (array_like) – Numerator coefficients (transversal part of filter) When b is not None, poles and zeros are determined from the coefficients b and a
  • a (array_like (optional, default = 1 for FIR-filter)) – Denominator coefficients (recursive part of filter)
  • z (array_like, default = None) – Zeros When b is None, poles and zeros are taken directly from z and p
  • p (array_like, default = None) – Poles
  • analog (boolean (default: False)) – When True, create a P/Z plot suitable for the s-plane, i.e. suppress the unit circle (unless anaCircleRad > 0) and scale the plot for a good display of all poles and zeros.
  • pn_eps (float (default : 1e-2)) – Tolerance for separating close poles or zeros
  • plt_ax (handle to axes for plotting (default: None)) – When no axes is specified, the current axes is determined via plt.gca()
  • plt_poles (Boolean (default : True)) – Plot poles. This can be used to suppress poles for FIR systems where all poles are at the origin.
  • style (string (default: 'square')) – Style of the plot, for style == ‘square’ make scale of x- and y- axis equal.
  • mps (integer (default: 10)) – Size for pole marker
  • mzs (integer (default: 10)) – Size for zero marker
  • mpc (char (default: 'r')) – Pole marker colour
  • mzc (char (default: 'b')) – Zero marker colour
  • lw (integer (default: 2)) – Linewidth for unit circle
  • zlabel (plabel,) – This string is passed to the plot command for poles and zeros and can be displayed by legend()
Returns:

z, p, k

Return type:

ndarray

Notes

pyfda.plot_widgets.plot_pz.classes = {'Plot_PZ': 'P / Z'}

display name

Type:Dict containing class name

plot_impz

Widget for plotting impulse and general transient responses

class pyfda.plot_widgets.plot_impz.Plot_Impz(parent)[source]

Construct a widget for plotting impulse and general transient responses

calc_auto(autorun=None)[source]

Triggered when checkbox “Autorun” is clicked. Enable or disable the “Run” button depending on the setting of the checkbox. When checkbox is checked (autorun == True passed via signal- slot connection), automatically run impz().

calc_fft()[source]

(Re-)calculate FFTs of stimulus self.X, quantized stimulus self.X_q and response self.Y using the window function self.ui.win.

calc_response(y_fx=None)[source]

(Re-)calculate filter response self.y from either stimulus self.x or from the passed array (e.g. fixpoint response).

Split response into imag. and real components self.y_i and self.y_r and set the flag self.cmplx.

calc_stimulus()[source]

(Re-)calculate stimulus self.x

draw(arg=None)[source]

(Re-)draw the figure without recalculation. When triggered by a signal- slot connection from a button, combobox etc., arg is a boolean or an integer representing the state of the widget. In this case, needs_redraw is set to True.

draw_freq()[source]

(Re-)draw the frequency domain mplwidget

draw_time()[source]

(Re-)draw the time domain mplwidget

fx_run(phase, dict_sig=None)[source]

Run the fixpoint simulation

fx_select(fx=None)[source]

Select between fixpoint and floating point simulation.

parameter fx can be:

  • str “Fixpoint” or “Float” when called directly
  • int 0 or 1 when triggered by changing the index of combobox self.ui.cmb_sim_select (signal-slot-connection)

In both cases, the index of the combobox is updated according to the passed argument. If the index has been changed since last time, self.needs_calc is set to True and the run button is set to “changed”.

impz(arg=None)[source]

Calculate response and redraw it automatically if checkbox “Auto Run” is selected or if called directly by pressing the “Run” button. In the latter case, the signal-slot connection passes the state of button (?) as a boolean.

Stimulus and response are only calculated if self.needs_calc == True.

plot_fnc(plt_style, ax, plt_dict=None, bottom=0)[source]

Return a plot method depending on the parameter plt_style (str) and the axis instance ax. An optional plt_dict is modified in place.

process_sig_rx(dict_sig=None, propagate=False)[source]

Process signals coming from the navigation toolbar, local widgets and collected from input_tab_widgets

All signals terminate here unless the flag propagate=True.

process_sig_rx_local(dict_sig=None)[source]

Flag signals coming in from local subwidgets with propagate=True before proceeding with processing in process_sig_rx.

TODO: not used at the moment

redraw()[source]

Redraw the currently visible canvas when e.g. the canvas size has changed

show_fft_win()[source]

Pop-up FFT window

pyfda.plot_widgets.plot_impz.classes = {'Plot_Impz': 'h[n]'}

display name

Type:Dict containing class name

plot_3d

Widget for plotting |H(z)| in 3D

class pyfda.plot_widgets.plot_3d.Plot_3D(parent)[source]

Class for various 3D-plots: - lin / log line plot of H(f) - lin / log surf plot of H(z) - optional display of poles / zeros

draw()[source]

Main drawing entry point: perform the actual plot

draw_3d()[source]

Draw various 3D plots

init_axes()[source]

Initialize and clear the axes to get rid of colorbar The azimuth / elevation / distance settings of the camera are restored after clearing the axes. See http://stackoverflow.com/questions/4575588/matplotlib-3d-plot-with-pyqt4-in-qtabwidget-mplwidget

process_signals(dict_sig=None)[source]

Process signals coming from the navigation toolbar and from sig_rx

redraw()[source]

Redraw the canvas when e.g. the canvas size has changed

pyfda.plot_widgets.plot_3d.classes = {'Plot_3D': '3D'}

display name

Type:Dict containing class name