pyfda package

Subpackages

Submodules

pyfda.filter_factory module

Dynamic parameters and settings are exchanged via the dictionaries in this file. Importing filterbroker.py runs the module once, defining all module variables which have a global scope like class variables and can be imported like

>>> import filter_factory as ff
>>> myfil = ff.fil_factory
class pyfda.filter_factory.FilterFactory[source]

Bases: object

This class implements a filter factory that (re)creates the globally accessible filter instance fil_inst from module path and class name, passed as strings.

call_fil_method(method, fil_dict, fc=None)[source]

Instantiate the filter design class passed as string fc with the globally accessible handle fil_inst. If fc = None, use the previously instantiated filter design class.

Next, call the design method passed as string method of the instantiated filter design class.

Parameters:
  • method (string) – The name of the design method to be called (e.g. ‘LPmin’)

  • fil_dict (dictionary) – A dictionary with all the filter specs that is passed to the actual filter design routine. This is usually a copy of fb.fil[0] The results of the filter design routine are written back to the same dict.

  • fc (string (optional, default: None)) – The name of the filter design class to be instantiated. When nothing is specified, the last filter selection is used.

Returns:

err_code

one of the following error codes:
-1:

filter design operation has been cancelled by user

0:

filter design method exists and is callable

16:

passed method name is not a string

17:

filter design method does not exist in class

18:

filter design error containing “order is too high”

19:

filter design error containing “failure to converge”

99:

unknown error

Return type:

int

Examples

>>> call_fil_method("LPmin", fil[0], fc="cheby1")

The example first creates an instance of the filter class ‘cheby1’ and then performs the actual filter design by calling the method ‘LPmin’, passing the global filter dictionary fil[0] as the parameter.

create_fil_inst(fc, mod=None)[source]

Create an instance of the filter design class passed as a string fc from the module found in fb.filter_classes[fc]. This dictionary has been collected by tree_builder.py.

The instance can afterwards be globally referenced as fil_inst.

Parameters:
  • fc (str) – The name of the filter design class to be instantiated (e.g. ‘cheby1’ or ‘equiripple’)

  • mod (str (optional, default = None)) – Fully qualified name of the filter module. When not specified, it is read from the global dict fb.filter_classes[fc]['mod']

Returns:

err_code

one of the following error codes:
-1:

filter design class was instantiated successfully

0:

filter instance exists, no re-instantiation necessary

1:

filter module not found by FilterTreeBuilder

2:

filter module found by FilterTreeBuilder but could not be imported

3:

filter class could not be instantiated

4:

unknown error during instantiation

Return type:

int

Examples

>>> create_fil_instance('cheby1')
>>> fil_inst.LPmin(fil[0])

The example first creates an instance of the filter class ‘cheby1’ and then performs the actual filter design by calling the method ‘LPmin’, passing the global filter dictionary fil[0] as the parameter.

pyfda.filter_factory.fil_factory = <pyfda.filter_factory.FilterFactory object>

Class instance of FilterFactory that can be accessed in other modules

pyfda.filter_factory.fil_inst = None

Instance of current filter design class (e.g. “cheby1”), globally accessible

>>> import filter_factory as ff
>>> ff.fil_factory.create_fil_instance('cheby1') # create instance of dynamic class
>>> ff.fil_inst.LPmin(fil[0]) # design a filter

pyfda.filterbroker module

Dynamic parameters and settings are exchanged via the dictionaries in this file. Importing filterbroker.py runs the module once, defining all module variables which have a global scope like class variables and can be imported like

>>> import filterbroker as fb
>>> myfil = fb.fil[0]

The entries in this file are only used as initial / default entries and to demonstrate the structure of the global dicts and lists. These initial values are also handy for module-level testing where some useful settings of the variables is required.

Notes

Alternative approaches for data persistence could be the packages shelve or pickleshare More info on data persistence and storing / accessing global variables:

pyfda.filterbroker.base_dir = ''

Project base directory

pyfda.filterbroker.clipboard = None

Handle to central clipboard instance

pyfda.filterbroker.filter_classes = {'Bessel': {'mod': 'pyfda.filter_widgets.bessel', 'name': 'Bessel'}, 'Butter': {'mod': 'pyfda.filter_widgets.butter', 'name': 'Butterworth'}, 'Cheby1': {'mod': 'pyfda.filter_widgets.cheby1', 'name': 'Chebyshev 1'}, 'Cheby2': {'mod': 'pyfda.filter_widgets.cheby2', 'name': 'Chebyshev 2'}, 'Ellip': {'mod': 'pyfda.filter_widgets.ellip', 'name': 'Elliptic'}, 'EllipZeroPhz': {'mod': 'pyfda.filter_widgets.ellip_zero', 'name': 'EllipZeroPhz'}, 'Equiripple': {'mod': 'pyfda.filter_widgets.equiripple', 'name': 'Equiripple'}, 'Firwin': {'mod': 'pyfda.filter_widgets.firwin', 'name': 'Windowed FIR'}, 'MA': {'mod': 'pyfda.filter_widgets.ma', 'name': 'Moving Average'}, 'Manual_FIR': {'mod': 'pyfda.filter_widgets.manual', 'name': 'Manual'}, 'Manual_IIR': {'mod': 'pyfda.filter_widgets.manual', 'name': 'Manual'}}

The keys of this dictionary are the names of all found filter classes, the values are the name to be displayed e.g. in the comboboxes and the fully qualified name of the module containing the class.

pyfda.filterbroker.get_fil_dict(keys: list)[source]

Get the value of fb.fil[0][“key_0”][“key_1”]…[“key_n], nested keys are passed as a list of strings keys, e.g. keys=[‘fxq’, ‘QACC’] accesses fb.fil[0][‘fxq’][‘QACC’].

pyfda.filterbroker.key_list_to_dict(keys: list) dict[source]

Convert a list of keys (str) to access a nested dict that can be read or written to and return that dict.

The nested dict is always based on fb.fil[0]. In order to set or get the value of the nested dict, use the key for the lowest nesting level on the returned dict d, i.e. d[keys[-1]] = arg resp. arg = d[keys[-1]].

pyfda.filterbroker.restore_fil()[source]

Restore current global dict fb.fil[0] from undo memory fil_undo

pyfda.filterbroker.set_fil_dict(keys: list, arg, backup: bool = True) None[source]
  • Set the value of fb.fil[0][“key_0”][“key_1”]…[“key_n] to arg, nested keys are passed as a list of strings, e.g. keys=[‘fxq’, ‘QACC’] accesses fb.fil[0][‘fxq’][‘QACC’].

  • Store the old state of fb.fil[0] before making any changes when backup == True.

pyfda.filterbroker.store_fil()[source]

Store current global dict fb.fil[0] to undo memory fil_undo

pyfda.pyfda_class module

pyfda.pyfda_rc module

pyfda.pyfdax module

pyfda.qrc_resources module

pyfda.qrc_resources.qCleanupResources()[source]
pyfda.qrc_resources.qInitResources()[source]

pyfda.version module

Store the version number here for setup.py and pyfdax.py

Module contents