## Using Jupyter/IPython for Teaching¶

<p xmlns:dct="http://purl.org/dc/terms/"> </p>

### What is Jupyter?¶

• formerly known as IPython ("interactive Python")
• an interactive terminal and a browser-based notebook
• https://jupyter.org/

### What's so great about the Jupyter notebook?¶

• mix of text, code and results

• media

• images, audio, video

• anything a web browser can display

• equations

### HTML5 <audio> tag¶

singing.wav by www.openairlib.net; CC BY-SA.

In [1]:
import soundfile as sf


### Plotting¶

In [2]:
%matplotlib inline
import matplotlib.pyplot as plt

In [3]:
import numpy as np

In [4]:
t = np.arange(len(sig)) / fs
plt.plot(t, sig)
plt.xlabel('time / seconds')
plt.grid()


### Spectrogram¶

Squared magnitude of the Short Time Fourier Transform (STFT)

$$|\text{STFT}\{x[n]\}(m, \omega)|^2 = \left| \sum_{n=-\infty}^\infty x[n]w[n-m] \text{e}^{-j \omega n}\right|^2$$
In [5]:
plt.specgram(sig, Fs=fs)
plt.ylabel('frequency / Hz')
plt.xlabel('time / seconds')
plt.ylim(0, 10000);


## Symbolic Math¶

In [6]:
%matplotlib inline
import sympy as sp

sp.init_printing()

t, sigma, omega = sp.symbols(('t', 'sigma', 'omega'))

sigma = -2
omega = 10
s = sigma + sp.I * omega
x = sp.exp(s * t)
x

Out[6]:
$$e^{t \left(-2 + 10 i\right)}$$
In [7]:
sp.plotting.plot(sp.re(x),(t, 0, 2 * sp.pi), ylim=[-2, 2], ylabel='Re{$e^{st}$}')
sp.plotting.plot(sp.im(x),(t, 0, 2 * sp.pi), ylim=[-2, 2], ylabel='Im{$e^{st}$}');


## Example notebooks¶

exercises for the lecture "communication acoustics"

That's it for now!