.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/creating_and_transforming_sfgs/connect_multiple_sfgs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_creating_and_transforming_sfgs_connect_multiple_sfgs.py: ======================== Connecting multiple SFGs ======================== It is sometimes useful to create several SFGs and later on connect them. One reason is using the SFG generators. The resulting SFG can also be flattened, replacing nested SFGs with their internal operations using :meth:`~b_asic.sfg.SFG.flatten`. This example illustrates how it can be done. .. GENERATED FROM PYTHON SOURCE LINES 14-31 .. code-block:: Python from b_asic.sfg_generators import wdf_allpass from b_asic.sfg import SFG from b_asic.special_operations import Input, Output # Generate allpass branches for fifth-order LWDF filter allpass1 = wdf_allpass([0.2, 0.5]) allpass2 = wdf_allpass([-0.5, 0.2, 0.5]) in_lwdf = Input() out_lwdf = Output((allpass1(in_lwdf) + allpass2(in_lwdf)) * 0.5) # Create SFG of LWDF with two internal SFGs sfg_with_sfgs = SFG( in_lwdf, out_lwdf, name="LWDF with separate internals SFGs for allpass branches" ) .. GENERATED FROM PYTHON SOURCE LINES 32-33 The resulting SFG looks like: .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: Python sfg_with_sfgs .. image-sg:: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_001.png :alt: connect multiple sfgs :srcset: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Create a flattened LWDF without modifying the original SFGs. .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python flattened_sfg = sfg_with_sfgs.flatten() .. image-sg:: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_002.png :alt: connect multiple sfgs :srcset: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 42-43 Resulting in: .. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: Python flattened_sfg .. image-sg:: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_003.png :alt: connect multiple sfgs :srcset: /examples/creating_and_transforming_sfgs/images/sphx_glr_connect_multiple_sfgs_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.078 seconds) .. _sphx_glr_download_examples_creating_and_transforming_sfgs_connect_multiple_sfgs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: connect_multiple_sfgs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: connect_multiple_sfgs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: connect_multiple_sfgs.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_