From db279fe182e46b10d9ba7e7ea89b85b54048e2c3 Mon Sep 17 00:00:00 2001 From: Frank Schultz Date: Tue, 16 Jul 2024 12:50:38 +0200 Subject: [PATCH] Delete MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb needs bugfix with new sympy / matplotlib plotting-> created dedicated fix branch --- .../MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb | 246 ------------------ 1 file changed, 246 deletions(-) delete mode 100644 system_properties_ct/MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb diff --git a/system_properties_ct/MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb b/system_properties_ct/MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb deleted file mode 100644 index 967c4fb..0000000 --- a/system_properties_ct/MaxMinPhaseAllpass_sympy_E1E7E53CFF.ipynb +++ /dev/null @@ -1,246 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "[Sascha Spors](https://orcid.org/0000-0001-7225-9992),\n", - "Professorship Signal Theory and Digital Signal Processing,\n", - "[Institute of Communications Engineering (INT)](https://www.int.uni-rostock.de/),\n", - "Faculty of Computer Science and Electrical Engineering (IEF),\n", - "[University of Rostock, Germany](https://www.uni-rostock.de/en/)\n", - "\n", - "# Tutorial Signals and Systems (Signal- und Systemtheorie)\n", - "\n", - "Summer Semester 2023 (Bachelor Course #24015)\n", - "\n", - "- lecture: https://github.com/spatialaudio/signals-and-systems-lecture\n", - "- tutorial: https://github.com/spatialaudio/signals-and-systems-exercises\n", - "\n", - "Feel free to contact lecturer [frank.schultz@uni-rostock.de](https://orcid.org/0000-0002-3010-0294)\n", - "\n", - "## Übung / Exercise 6" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import sympy as sp\n", - "import matplotlib.pyplot as plt\n", - "from sympy.plotting.plot import MatplotlibBackend\n", - "sp.init_printing()\n", - "\n", - "\n", - "def logx_plot(Hw, wrange, **kwargs):\n", - " # modified function from original at\n", - " # Sascha Spors, 2020, Continuous- and Discrete-Time Signals and Systems - Theory and Computational Examples.\n", - " # https://github.com/spatialaudio/signals-and-systems-lecture/blob/master/systems_spectral_domain/bode_plot.ipynb\n", - " # 7d1df23\n", - " 'create plot with logarithmic x-axis'\n", - " p = sp.plot(Hw, wrange, show=False, **kwargs)\n", - " backend = MatplotlibBackend(p)\n", - " backend.process_series()\n", - " backend.ax[0].spines['left'].set_position(('axes', 0))\n", - " backend.ax[0].spines['bottom'].set_position(('axes', 0))\n", - " plt.xscale('log')\n", - " plt.grid(True, which='both')\n", - "\n", - "\n", - "def db(x):\n", - " 'compute dB value'\n", - " return 20 * sp.log(sp.Abs(x), 10)\n", - "\n", - "\n", - "def plot_bode(H):\n", - " logx_plot(db(H.subs(s, sp.I * w)),\n", - " (w, wl, wh),\n", - " xlabel=r'$\\omega$',\n", - " ylabel=r'Level $20 \\log_{10} | H(j \\omega) |$ in dB',\n", - " adaptive=False, nb_of_points=Nw)\n", - " logx_plot(sp.arg(H.subs(s, sp.I * w))*180/sp.pi,\n", - " (w, wl, wh),\n", - " xlabel=r'$\\omega$',\n", - " ylabel=r'Phase $\\angle H(j \\omega)$ in deg',\n", - " adaptive=False, nb_of_points=Nw)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = sp.symbols('s')\n", - "w = sp.symbols('omega', real=True)\n", - "wl, wh, Nw = 0.01, 100, 2**12" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Maximum Phase System" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Max Phase\n", - "Hmax = 2*(s-2)/(s+1/2)\n", - "Hmax" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sp.apart(Hmax)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot_bode(Hmax)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Minimum Phase System" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Min Phase\n", - "Hmin = 2*(s+2)/(s+1/2)\n", - "Hmin" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sp.apart(Hmin)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot_bode(Hmin)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Allpass System" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Allpass\n", - "Hall = (s-2)/(s+2)\n", - "Hall" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sp.apart(Hall)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# plot_bode(Hall) # not working->TBD" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "check if $H(s)_\\mathrm{max} = H(s)_\\mathrm{min} \\cdot H(s)_\\mathrm{all}$ by typical sympy $a-b=0$ check routine" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sp.apart(Hall * Hmin) - sp.apart(Hmax))\n", - "print(sp.simplify(Hall * Hmin - Hmax))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Copyright\n", - "\n", - "This tutorial is provided as Open Educational Resource (OER), to be found at\n", - "https://github.com/spatialaudio/signals-and-systems-exercises\n", - "accompanying the OER lecture\n", - "https://github.com/spatialaudio/signals-and-systems-lecture.\n", - "Both are licensed under a) the Creative Commons Attribution 4.0 International\n", - "License for text and graphics and b) the MIT License for source code.\n", - "Please attribute material from the tutorial as *Frank Schultz,\n", - "Continuous- and Discrete-Time Signals and Systems - A Tutorial Featuring\n", - "Computational Examples, University of Rostock* with\n", - "``github URL, commit number and/or version tag, year, (file name and/or content)``." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "mydsp", - "language": "python", - "name": "mydsp" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.6" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}