<jupyter_start><jupyter_text>[<NAME>](https://orcid.org/0000-0001-7225-9992),Professorship Signal Theory and Digital Signal Processing,[Institute of Communications Engineering (INT)](https://www.int.uni-rostock.de/),Faculty of Computer Science and Electrical Engineering (IEF),[University of Rostock, Germany](https://www.uni-rostock.de/en/) Tutorial Signals and Systems (Signal- und Systemtheorie)Summer Semester 2021 (Bachelor Course 24015)- lecture: https://github.com/spatialaudio/signals-and-systems-lecture- tutorial: https://github.com/spatialaudio/signals-and-systems-exercisesWIP...The project is currently under heavy development while adding new material for the summer semester 2021Feel free to contact lecturer [<EMAIL>](https://orcid.org/0000-0002-3010-0294) Übung / Exercise 7 Ideal Dirac Comb Sampling and Ideal Lowpass Reconstruction for Frequency Domain Signals<jupyter_code>import numpy as np
import matplotlib.pyplot as plt


def my_sinc(x):  # we rather use definition sinc(x) = sin(x)/x, thus:
    return np.sinc(x/np.pi)
A = 2
Ts = 1
ws = 2*np.pi/Ts
def sinc_sampling_sinc_interpolation():
    print('Ts=%3.2f s, ws=%3.2f rad/s, Th=%3.2f s, Th/2=%3.2f s' %
          (Ts, ws, Th, Th/2))
    print('ws*Th/2=%5.4f' % (ws*Th/2))
    plt.figure(figsize=(6, 4.5))

    M = 15
    nu = np.arange(-M, M+1)
    w = np.arange(-M*ws, (M+1)*ws, ws / 2**6)

    # fourier transform
    XFT = A*Th * my_sinc(w * Th/2)

    # fourier series
    XFS = A*Th/Ts * my_sinc((ws*nu) * Th/2)

    # fourier transform as sinc-interpolation from fourier series
    Xr = np.zeros_like(w)
    for nui in nu:
        XFSnui = A*Th/Ts * my_sinc((ws*nui) * Th/2)
        Xrnui = (Ts*XFSnui) * my_sinc(np.pi*(w-nui*ws)/ws)
        plt.plot(w, Xrnui, 'C7', lw=1)
        Xr += Xrnui
    # plot last Xrnui to get label
    plt.plot(w, Xrnui, 'C7', lw=1,
             label=r'$X_\mathrm{r}(\mathrm{j}\omega)[\nu]$')
    # plot fourier transform
    plt.plot(w, XFT, 'C0', lw=3, label=r'$X(\mathrm{j}\omega)$')
    # plot reconstructed fourier transform, note that we only use finite sum
    plt.plot(w, Xr, 'C3--', lw=2,
             label=r'$X_\mathrm{r}(\mathrm{j}\omega)$')
    # plot fourier series, here notmalized to match amplitude with fourier transform
    plt.stem(nu*ws, XFS*Ts,
             use_line_collection=True,
             linefmt='C1:',
             markerfmt='C1o',
             basefmt='C1:', label=r'$X[\nu \omega_s] \cdot T_s$')
    plt.xticks(np.arange(-7*2*np.pi, 8*2*np.pi, 2*np.pi),
               [r'$-14\pi$', '', r'$-10\pi$', '', r'$-6\pi$', '', r'$-2\pi$', '', r'$2\pi$', '', r'$6\pi$', '', r'$10\pi$', '', r'$14\pi$'])
    plt.xlim(-7*2*np.pi, +7*2*np.pi)
    plt.xlabel(r'$\omega$ / rad/s')
    plt.title('Ts=%4.3f s, ws=%4.3f rad/s, Th=%4.3f s, Th/2=%4.3f s' %
              (Ts, ws, Th, Th/2))
    plt.legend()
    plt.grid(True)
# chosen parameters for task 45C76AFB33
Th = Ts/2  # Th<Ts, Th/2<Ts/2 for perfect reconstruction
sinc_sampling_sinc_interpolation()
plt.savefig('SpectrumSampling_Th_Ts1_2_45C76AFB33.pdf')
# suitable for perfect reconstruction
Th = Ts*3/4  # Th<Ts, Th/2<Ts/2 for perfect reconstruction
sinc_sampling_sinc_interpolation()
plt.savefig('SpectrumSampling_Th_Ts3_4_45C76AFB33.pdf')
# critical sampling and reconstruction
# this leads to Dirac Impulse at w=0 with weight 2, i.e. a DC of 2, as expected
Th = Ts  # Th<Ts, Th/2<Ts/2 for perfect reconstruction
sinc_sampling_sinc_interpolation()
plt.savefig('SpectrumSampling_Th_Ts1_1_45C76AFB33.pdf')
# undersampling case and thus reconstruction fail
Th = 4/3*Ts  # Th<Ts, Th/2<Ts/2 for perfect reconstruction
sinc_sampling_sinc_interpolation()
plt.savefig('SpectrumSampling_Th_Ts4_3_45C76AFB33.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16174892703862662, 'fraction_numerical': 0.04586909871244635, 'mean_word_length': 3.6265508684863526, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '148973', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1449, 'n_words': 319, 'path': 'sampling/IdealSamplingReconstruction_45C76AFB33.ipynb', 'repo_name': 'spatialaudio/signals-and-systems-exercises', 'size': '3755'}