<jupyter_start><jupyter_text>Para generar slides:```python3 -m nbconvert --to slides --TagRemovePreprocessor.remove_input_tags={\"to_remove\"} Ejercicio\ pasaaltos\ de\ clase.ipynb```  Ejemplo filtro Chebyshev pasaaltos Plantilla|  $\alpha$               |  $f$  ||-------------------------|-------||  $\alpha_{max}$ = 1dB   | 45Hz  ||  $\alpha_{min}$ = 20dB  | 10Hz  |<jupyter_code>%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

w_banda_paso = np.linspace(45, 100)
w_banda_att = np.linspace(0, 10)
att_min = 20  # dB
att_max = 1  # dB

# Lineas verticales para mejor visualizacion
vertical_banda_paso = np.linspace(0, att_max)
vertical_banda_att = np.linspace(0, att_min)

# Ploteo
fig, ax = plt.subplots()
ax.ticklabel_format(useOffset=False)
ax.set_ylabel('Att [db]')
ax.set_xlabel('f [Hz]')
ax.grid(True)
ticks = range(0, 101,10)
ax.set_xticks(ticks)
ax.plot(w_banda_paso, [att_max] * len(w_banda_paso), '-b')
ax.plot(w_banda_att, [att_min] * len(w_banda_att), '-b')
ax.plot([45] * len(vertical_banda_paso), vertical_banda_paso, '-b')
ax.plot([10] * len(vertical_banda_att), vertical_banda_att, '-b')

plt.show()<jupyter_output><empty_output><jupyter_text>Plantilla normalizada<jupyter_code>import math as m

w_p = 2 * m.pi * 45
w_s = 2 * m.pi * 10

w_p_n = 1
w_s_n = w_s / w_p

print(f'w_p_n = {w_p_n}, w_s_n = {w_s_n}')<jupyter_output>w_p_n = 1, w_s_n = 0.2222222222222222<jupyter_text>Plantilla pasabajos prototipo<jupyter_code>w_p_lp = 1 / w_p_n
w_s_lp = 1 / w_s_n

print(f'w_p_lp = {w_p_lp}, w_s_lp = {w_s_lp}')<jupyter_output>w_p_lp = 1.0, w_s_lp = 4.5<jupyter_text>Orden del filtro<jupyter_code>alpha_max = 1    # dB
alpha_min = 20   # dB

epsilon = m.sqrt(m.pow(10, 0.1 * alpha_max) - 1)
N = m.acosh((m.pow(10, alpha_min * 0.1) - 1) / (m.pow(10, alpha_max * 0.1) - 1)) / (2 * m.acosh(w_s_lp))
N = m.ceil(N)

print(f'epsilon: {epsilon}, N: {N}')<jupyter_output>epsilon: 0.5088471399095875, N: 2<jupyter_text>Obtención transferencia pasabajos Formula recurrencia:$c_n(\omega) = 2 * \omega * c_{n-1}(\omega) - c_{n-2}(\omega)$| n   | $c_n$($\omega$) ||:---:|:---:|| 0 | 1 || 1 | $\omega$ || 2 | 2*$\omega^2$-1|$\epsilon \simeq 0.51$Módulo:$H(j\omega)*H(-j\omega) = \frac{1}{1 + \epsilon^2 * c^2_2(w)} = \frac{1}{4* \epsilon^2 * \omega^4 - 4 * \epsilon^2 * \omega^2 + 1 + \epsilon^2}$ Factorizamos para obtener $H(s)$:$H(s)*H(-s) = \frac{1}{1.04 * s^4 + 1.04 * s^2 + 1.26} = \frac{1}{a* s^2 + b * s + c}\frac{1}{a* s^2 - b * s + c}$$c^2 = 1.26$$a^2 = 1.04$$2*a*c - b^2 = 1.04$Resolviendo:$a = 1.02$$c = 1.12$$b = \sqrt{2 * 1.02 * 1.12 - 1.04} = 1.12$$H(s) = \frac{1}{a* s^2 + b * s + c} = \frac{1}{1.02* s^2 + 2.23 * s + 1.12}$  Verificación prototipo pasabajos<jupyter_code>from scipy import signal

num = [1]
den = [1.02, 1.12, 1.12]
filtro = signal.TransferFunction(num, den)

w = np.logspace(np.log10(0.1), np.log10(10), num=1000)
w, mag, _ = filtro.bode(w=w)
vertical = np.linspace(min(mag), max(mag))

plt.figure()
plt.semilogx(w, mag, '-b')    # Bode magnitude plot
plt.grid(True)
plt.xlabel('Angular frequency [rad/sec]')
plt.ylabel('Magnitude response [dB]')
plt.title('Frequency response')

plt.semilogx(w, [-alpha_max] * len(w), '-r')
plt.semilogx(w, [-alpha_min] * len(w), '-r')
plt.semilogx([1] * len(vertical), vertical, '-r')
plt.semilogx([4.5] * len(vertical), vertical, '-r')

plt.plot()
import splane

splane.pzmap(filtro)<jupyter_output>0 zeros: []
2 poles: [-0.54901961+0.89253386j -0.54901961-0.89253386j]
gain: 0.9803921568627451<jupyter_text>Obtención transferencia pasaaltos normalizada Kernel transformación:$K(s) = \frac{1}{s}$Obtengo $H(s)$ del pasaaltos:$H(s) = \frac{1}{1.02 * s^2 + 2.23 * s + 1.12} |_{s -> 1/s}$$H(s) = \frac{1}{1.02 * (1/s)^2 + 2.23 * (1/s) + 1.12}$$H(s) = \frac{s^2}{1.12 * s^2 + 2.23 * s + 1.02}$  Verificacion filtro pasaaltos normalizado<jupyter_code>from scipy import signal

num = [1, 0, 0]
den = [1.12, 1.12, 1.02]
filtro = signal.TransferFunction(num, den)

w = np.logspace(np.log10(0.1), np.log10(10), num=1000)
w, mag, _ = filtro.bode(w=w)
vertical = np.linspace(min(mag), max(mag))

plt.figure()
plt.semilogx(w, mag, '-b')    # Bode magnitude plot
plt.grid(True)
plt.xlabel('Angular frequency [rad/sec]')
plt.ylabel('Magnitude response [dB]')
plt.title('Frequency response')

plt.semilogx(w, [-alpha_max] * len(w), '-r')
plt.semilogx(w, [-alpha_min] * len(w), '-r')
plt.semilogx([1] * len(vertical), vertical, '-r')
plt.semilogx([1/4.5] * len(vertical), vertical, '-r')

plt.plot()
import splane

splane.pzmap(filtro)<jupyter_output>2 zeros: [0. 0.]
2 poles: [-0.5+0.81284333j -0.5-0.81284333j]
gain: 0.8928571428571428
{'fraction_non_alphanumeric': 0.21496746203904554, 'fraction_numerical': 0.08134490238611713, 'mean_word_length': 4.374125874125874, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '194180', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2168, 'n_words': 394, 'path': 'notebooks/cheby_pasaaltos_slides.ipynb', 'repo_name': 'ivanpauno/tc2', 'size': '4610'}