Skip to content

Commit

Permalink
prep for summer term 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
fs446 committed Apr 4, 2022
1 parent fe8f47c commit 09ef68a
Show file tree
Hide file tree
Showing 59 changed files with 1,022 additions and 1,084 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ series_vs_parallel_bode_level_081294E23C.png
convolution_ct_example3_C964DD7400 copy 2.ipynb
convolution_ct_example3_C964DD7400 copy.ipynb

z_transform_CEF5164788.pdf

klausur.tex

## ipynb stuff
Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

**Continuous- and Discrete-Time Signals and Systems - A Tutorial with Computational Examples**

This tutorial accompanies the lecture [Continuous-Time and Discrete-Time Signals and Systems - Theory and Computational Examples](https://github.com/spatialaudio/signals-and-systems-lecture). The lecture and the tutorial are designed for International Standard Classification of Education (ISCED) level 6.
This tutorial accompanies the lecture [Continuous-Time and Discrete-Time Signals and Systems - Theory and Computational Examples](https://github.com/spatialaudio/signals-and-systems-lecture). The lecture and the tutorial are designed for International Standard Classification of Education (ISCED) level 6 being held at University of Rostock, Germany.

Juypter notebooks can be accessed with the webserver services

- **dynamic** version using **mybinder**: https://mybinder.org/v2/gh/spatialaudio/signals-and-systems-exercises/output?filepath=index.ipynb
- **static** version using **nbviewer**: https://nbviewer.jupyter.org/github/spatialaudio/signals-and-systems-exercises/blob/output/index.ipynb

Sources (tex, ipynb) can be found at github
All sources (tex, ipynb, ...) can be found at github
- https://github.com/spatialaudio/signals-and-systems-exercises

## Anaconda Environment

The [Anaconda distribution](https://www.anaconda.com/distribution/) is a very convenient solution to install a required environment, i.e. to have access to the Jupyter Notebook renderer with a Python compiler on a personal computer. It is very likely that a very recent installation of Anaconda already delivers all required packages just using the `root` environment. We actually do not need very special packages. However, if `root` is not working immediately, creating and activating a dedicated environment `mydsp` might be useful. Do the following steps
The [Anaconda distribution](https://www.anaconda.com/distribution/) is a very convenient solution to install a required environment, i.e. to have access to the Jupyter Notebook renderer with a Python interpreter on a personal computer. It is very likely that a very recent installation of Anaconda already delivers all required packages just using the `base` environment. We actually do not need very special packages. However, if `base` is not working immediately, creating and activating a dedicated environment `mydsp` might be useful. Do the following steps

- get at least python 3.8x, numpy, sympy, scipy, matplotlib, notebook, jupyterlab, ipykernel, the other packages are very useful tools for convenience
- get at least python 3.9x, numpy, sympy, scipy, matplotlib, notebook, jupyterlab, ipykernel, the other packages are very useful tools for convenience

`conda create -n mydsp python=3.8 pip numpy scipy matplotlib notebook jupyterlab pydocstyle pycodestyle autopep8 flake8 ipykernel nb_conda jupyter_nbextensions_configurator jupyter_contrib_nbextensions`
`conda create -n mydsp python=3.9 pip numpy sympy scipy matplotlib notebook ipykernel jupyterlab pydocstyle pycodestyle autopep8 flake8 nb_conda jupyter_nbextensions_configurator jupyter_contrib_nbextensions`

- activate this environment with

Expand All @@ -28,22 +28,22 @@ The [Anaconda distribution](https://www.anaconda.com/distribution/) is a very co

`python -m ipykernel install --user --name mydsp --display-name "mydsp"`

- get into the folder where the DSP exercises are located, e.g.
- get into the folder where the exercises are located, e.g.

`cd my_signals_and_systems_exercises_folder`

- start either a Jupyter notebook or Jupyter lab working environment via a local server instance by either

`jupyter notebook` or `jupyter lab`

If the above steps still lead to problems, the following lines created the environment `mydsp`
- using `conda 4.9.2`
- `conda create -n mydsp python=3.8.6 pip=20.2.4 numpy=1.19.4 sympy=1.7.1 scipy=1.5.3 matplotlib=3.3.3 jupyter=1.0.0 notebook=6.1.5 jupyterlab=2.2.9 pydocstyle=5.1.1 pycodestyle=2.6.0 autopep8=1.5.4 flake8=3.8.4 ipykernel=5.3.4 nb_conda=2.2.1 jupyter_nbextensions_configurator=0.4.1 jupyter_contrib_nbextensions=0.5.1`
If the above steps still lead to problems, the following lines created the working environment `mydsp`
- using `conda 4.12.0`, `conda-build 3.21.8`
- `conda create -n mydsp python=3.9.12 pip=22.0.4 numpy=1.22.3 sympy=1.10.1 scipy=1.8.0 matplotlib=3.5.1 notebook=6.4.10 ipykernel=6.11.0 jupyterlab=3.3.2 pydocstyle=6.1.1 pycodestyle=2.8.0 autopep8=1.6.0 flake8=4.0.1 nb_conda=2.2.1 jupyter_nbextensions_configurator=0.4.1 jupyter_contrib_nbextensions=0.5.1`
- `pip install soundfile`

## German Version

We are in the design process of a very detailed 12 units tutorial to support remote learning for our students within COVID-19 era, thus the initial version is in German. Translations to English are scheduled ASAP. Please see the LaTex main file `tutorial_latex_deu/sig_sys_ex.tex`. There are several graphics included, which are created by the provided Jupyter notebooks. These have an ID with hex numbers in file name so that notebooks can be linked to the exercises within the tex project. We might wish to compile all notebooks at once, then we can use
We are still in the design and polishing process of a very detailed 12 units tutorial to support remote learning for our students within COVID-19 era, thus the initial version is in German. Translations to English are scheduled ASAP. Please see the LaTex main file `tutorial_latex_deu/sig_sys_ex.tex`. There are several graphics included, which are created by the provided Jupyter notebooks. These have an ID with hex numbers in file name, so that notebooks can be linked to the exercises within the tex project. We might wish to compile all notebooks at once, then we can use
`python3 -m nbconvert --ExecutePreprocessor.kernel_name="mydsp" --execute --inplace *.ipynb **/*.ipynb **/**/*.ipynb`

## License
Expand All @@ -53,20 +53,22 @@ We are in the design process of a very detailed 12 units tutorial to support rem

## Versions / Tags / Branches

- summer term 2021 version: https://github.com/spatialaudio/signals-and-systems-exercises/releases/tag/v0.2
- summer term 2020 version: https://github.com/spatialaudio/signals-and-systems-exercises/releases/tag/v0.1
- we use the branch `master` for developing
- we use the branch `output` to provide notebooks with rendered output. **Note**, that we will hard-reset this branch from time to time when updates are being made. So, please don't rely on commits from this branch!
- we use the branch `output` to provide notebooks with rendered output. **Note**, that we will hard-reset this branch from time to time when updates are being made. So, please do not rely on commits from this branch!

## Referencing

Please cite this open educational resource (OER) project as
*Frank Schultz, Continuous- and Discrete-Time Signals and Systems - A Tutorial Featuring Computational Examples, University of Rostock* with ``main file, github URL, commit number and/or version tag, year``.
*Frank Schultz, Continuous- and Discrete-Time Signals and Systems - A Tutorial Featuring Computational Examples, University of Rostock* with ``github URL, commit number and/or version tag, year, (dedicated files and/or content)``.

## Authorship

University of Rostock:

- Frank Schultz (concept, design, main author)
- Robert Hauser (proof reading, concept, author)
- Sascha Spors (proof reading, concept)
- Till Rettberg (concept, design)
- Matthias Geier (proof reading, technical advisor)
Expand Down
47 changes: 25 additions & 22 deletions convolution_ct/convolution_ct_example1_1D3D68B312.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
"\n",
"# Tutorial Signals and Systems (Signal- und Systemtheorie)\n",
"\n",
"Summer Semester 2021 (Bachelor Course #24015)\n",
"Summer Semester 2022 (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",
"WIP...\n",
"The project is currently under heavy development while adding new material for the summer semester 2021\n",
"\n",
"Feel free to contact lecturer [frank.schultz@uni-rostock.de](https://orcid.org/0000-0002-3010-0294)"
]
},
Expand Down Expand Up @@ -73,11 +70,14 @@
"def heaviside(x):\n",
" return np.heaviside(x, .5)\n",
"\n",
"\n",
"def animate_convolution(x, h, y, td, taud, xlim):\n",
"\n",
" # add numerical evaluation to symbolic functions\n",
" x_eval = sp.lambdify((tau), x.subs(t, tau), modules=['numpy', {'Heaviside': heaviside}])\n",
" h_eval = sp.lambdify((t, tau), h.subs(t, t - tau), modules=['numpy', {'Heaviside': heaviside}])\n",
" x_eval = sp.lambdify((tau), x.subs(t, tau), modules=[\n",
" 'numpy', {'Heaviside': heaviside}])\n",
" h_eval = sp.lambdify((t, tau), h.subs(t, t - tau),\n",
" modules=['numpy', {'Heaviside': heaviside}])\n",
" y_eval = sp.lambdify((t), y, modules=['numpy', {'Heaviside': heaviside}])\n",
"\n",
" # setup plot and line styles\n",
Expand All @@ -87,7 +87,8 @@
"\n",
" lines = [ax[0].plot([], [], lw=2, label=r'$x_B(t-\\tau)$')[0]]\n",
" lines.append(ax[0].plot([], [], lw=2, label=r'$x_A(\\tau)$')[0])\n",
" lines.append(ax[1].plot([], [], 'g-', lw=2, label=r'$y(t) = x_A(t) * x_B(t)$')[0])\n",
" lines.append(ax[1].plot([], [], 'g-', lw=2,\n",
" label=r'$y(t) = x_A(t) * x_B(t)$')[0])\n",
" lines.append(ax[1].plot([], [], 'ro', lw=2)[0])\n",
"\n",
" ax[0].set_xlim(xlim)\n",
Expand All @@ -103,22 +104,23 @@
" ax[1].grid(True)\n",
"\n",
" if False: # check manual calc\n",
" t1 = np.linspace(1,3/2,100)\n",
" t1 = np.linspace(1, 3/2, 100)\n",
" x1 = -2*t1**2 + 6*t1 - 4\n",
" ax[1].plot(t1,x1, 'C3')\n",
" ax[1].plot(t1, x1, 'C3')\n",
"\n",
" t2 = np.linspace(3/2,3,100)\n",
" t2 = np.linspace(3/2, 3, 100)\n",
" x2 = t2*0+1/2\n",
" ax[1].plot(t2,x2, 'C3')\n",
" ax[1].plot(t2, x2, 'C3')\n",
"\n",
" t3 = np.linspace(3, 7/2, 100)\n",
" x3 = +2*t3**2 - 14*t3 + 49/2\n",
" ax[1].plot(t3, x3, 'C3')\n",
"\n",
" t3 = np.linspace(3,7/2,100)\n",
" x3 = +2*t3**2 -14*t3 +49/2\n",
" ax[1].plot(t3,x3, 'C3')\n",
" \n",
" def animate(ti):\n",
" ax[0].collections.clear()\n",
" ax[0].fill_between(taud, 0, h_eval(ti, taud)*x_eval(taud), facecolor='gray', alpha=0.3)\n",
" \n",
" ax[0].fill_between(taud, 0, h_eval(ti, taud) *\n",
" x_eval(taud), facecolor='gray', alpha=0.3)\n",
"\n",
" lines[0].set_data(taud, h_eval(ti, taud))\n",
" lines[1].set_data(taud, x_eval(taud))\n",
"\n",
Expand Down Expand Up @@ -149,6 +151,7 @@
" def eval(cls, arg):\n",
" return sp.Heaviside(arg + sp.S.Half) - sp.Heaviside(arg - sp.S.Half)\n",
"\n",
"\n",
"t, tau = sp.symbols('t tau', real=True)"
]
},
Expand Down Expand Up @@ -226,7 +229,7 @@
"xA = x\n",
"xB = h\n",
"y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),\n",
" (tau, 0, t)) # for causal signals\n",
" (tau, 0, t)) # for causal signals\n",
"\n",
"anim = animate_convolution(\n",
" x=xA,\n",
Expand All @@ -235,7 +238,7 @@
" td=np.arange(-2, 10, .1),\n",
" taud=np.arange(-10, 10, 0.01),\n",
" xlim=(-2, 5))\n",
"anim\n"
"anim"
]
},
{
Expand Down Expand Up @@ -263,7 +266,7 @@
"xA = h\n",
"xB = x\n",
"y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),\n",
" (tau, 0, t)) # for causal signals\n",
" (tau, 0, t)) # for causal signals\n",
"\n",
"anim = animate_convolution(\n",
" x=xA,\n",
Expand Down Expand Up @@ -299,7 +302,7 @@
"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",
"``main file, github URL, commit number and/or version tag, year``."
"``github URL, commit number and/or version tag, year, (file name and/or content)``."
]
}
],
Expand All @@ -319,7 +322,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
54 changes: 29 additions & 25 deletions convolution_ct/convolution_ct_example2_AF3B15E0D3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
"\n",
"# Tutorial Signals and Systems (Signal- und Systemtheorie)\n",
"\n",
"Summer Semester 2021 (Bachelor Course #24015)\n",
"Summer Semester 2022 (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",
"WIP...\n",
"The project is currently under heavy development while adding new material for the summer semester 2021\n",
"\n",
"Feel free to contact lecturer [frank.schultz@uni-rostock.de](https://orcid.org/0000-0002-3010-0294)"
]
},
Expand Down Expand Up @@ -73,11 +70,14 @@
"def heaviside(x):\n",
" return np.heaviside(x, .5)\n",
"\n",
"\n",
"def animate_convolution(x, h, y, td, taud, xlim):\n",
"\n",
" # add numerical evaluation to symbolic functions\n",
" x_eval = sp.lambdify((tau), x.subs(t, tau), modules=['numpy', {'Heaviside': heaviside}])\n",
" h_eval = sp.lambdify((t, tau), h.subs(t, t - tau), modules=['numpy', {'Heaviside': heaviside}])\n",
" x_eval = sp.lambdify((tau), x.subs(t, tau), modules=[\n",
" 'numpy', {'Heaviside': heaviside}])\n",
" h_eval = sp.lambdify((t, tau), h.subs(t, t - tau),\n",
" modules=['numpy', {'Heaviside': heaviside}])\n",
" y_eval = sp.lambdify((t), y, modules=['numpy', {'Heaviside': heaviside}])\n",
"\n",
" # setup plot and line styles\n",
Expand All @@ -87,40 +87,42 @@
"\n",
" lines = [ax[0].plot([], [], lw=2, label=r'$x_B(t-\\tau)$')[0]]\n",
" lines.append(ax[0].plot([], [], lw=2, label=r'$x_A(\\tau)$')[0])\n",
" lines.append(ax[1].plot([], [], 'g-', lw=2, label=r'$y(t) = x_A(t) * x_B(t)$')[0])\n",
" lines.append(ax[1].plot([], [], 'g-', lw=2,\n",
" label=r'$y(t) = x_A(t) * x_B(t)$')[0])\n",
" lines.append(ax[1].plot([], [], 'ro', lw=2)[0])\n",
"\n",
" ax[0].set_xticks(np.arange(-2,6,1/2))\n",
" ax[0].set_xticks(np.arange(-2, 6, 1/2))\n",
" ax[0].set_xlim(xlim)\n",
" ax[0].set_ylim((-0.1, 2.1))\n",
" ax[0].set_xlabel(r'$\\tau$')\n",
" ax[0].legend(loc='upper right')\n",
" ax[0].grid(True)\n",
"\n",
" ax[1].set_xticks(np.arange(-2,6,1/2))\n",
" ax[1].set_xticks(np.arange(-2, 6, 1/2))\n",
" ax[1].set_xlim(xlim)\n",
" ax[1].set_ylim((-0.01, 0.4))\n",
" ax[1].set_xlabel(r'$t$')\n",
" ax[1].legend(loc='lower left')\n",
" ax[1].grid(True)\n",
"\n",
" if False: # check manual calc\n",
" t1 = np.linspace(1,3/2,100)\n",
" t1 = np.linspace(1, 3/2, 100)\n",
" x1 = -2*t1**2 + 6*t1 - 4\n",
" ax[1].plot(t1,x1, 'C3')\n",
" ax[1].plot(t1, x1, 'C3')\n",
"\n",
" t2 = np.linspace(3/2,3,100)\n",
" t2 = np.linspace(3/2, 3, 100)\n",
" x2 = t2*0+1/2\n",
" ax[1].plot(t2,x2, 'C3')\n",
" ax[1].plot(t2, x2, 'C3')\n",
"\n",
" t3 = np.linspace(3, 7/2, 100)\n",
" x3 = +2*t3**2 - 14*t3 + 49/2\n",
" ax[1].plot(t3, x3, 'C3')\n",
"\n",
" t3 = np.linspace(3,7/2,100)\n",
" x3 = +2*t3**2 -14*t3 +49/2\n",
" ax[1].plot(t3,x3, 'C3')\n",
" \n",
" def animate(ti):\n",
" ax[0].collections.clear()\n",
" ax[0].fill_between(taud, 0, h_eval(ti, taud)*x_eval(taud), facecolor='gray', alpha=0.3)\n",
" \n",
" ax[0].fill_between(taud, 0, h_eval(ti, taud) *\n",
" x_eval(taud), facecolor='gray', alpha=0.3)\n",
"\n",
" lines[0].set_data(taud, h_eval(ti, taud))\n",
" lines[1].set_data(taud, x_eval(taud))\n",
"\n",
Expand Down Expand Up @@ -151,6 +153,7 @@
" def eval(cls, arg):\n",
" return sp.Heaviside(arg + sp.S.Half) - sp.Heaviside(arg - sp.S.Half)\n",
"\n",
"\n",
"t, tau = sp.symbols('t tau', real=True)"
]
},
Expand Down Expand Up @@ -215,7 +218,8 @@
"area_under_exp = 1/3 - 1 / (3 * np.exp(1)**3)\n",
"\n",
"x = 2 * rect((t-1)*1/2)\n",
"h = (sp.exp(-(t-1)/time_constant_RC)) * rect((t-5/4)*2) # note: cut exp function"
"h = (sp.exp(-(t-1)/time_constant_RC)) * \\\n",
" rect((t-5/4)*2) # note: cut exp function"
]
},
{
Expand All @@ -234,7 +238,7 @@
"xA = x\n",
"xB = h\n",
"y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),\n",
" (tau, 0, t)) # for causal signals\n",
" (tau, 0, t)) # for causal signals\n",
"\n",
"anim = animate_convolution(\n",
" x=xA,\n",
Expand All @@ -243,7 +247,7 @@
" td=np.arange(-2, 10, .1),\n",
" taud=np.arange(-10, 10, 0.01),\n",
" xlim=(-2, 5))\n",
"anim\n"
"anim"
]
},
{
Expand Down Expand Up @@ -271,7 +275,7 @@
"xA = h\n",
"xB = x\n",
"y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),\n",
" (tau, 0, t)) # for causal signals\n",
" (tau, 0, t)) # for causal signals\n",
"\n",
"anim = animate_convolution(\n",
" x=xA,\n",
Expand Down Expand Up @@ -307,7 +311,7 @@
"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",
"``main file, github URL, commit number and/or version tag, year``."
"``github URL, commit number and/or version tag, year, (file name and/or content)``."
]
}
],
Expand All @@ -327,7 +331,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 09ef68a

Please sign in to comment.