Example #1
0
 def plot_group_delay(self, a, b):
     w, gd = signal.group_delay((b, a))
     plt.plot(w, numpy.round(gd, 5))
     plt.ylabel('Retardo de grupo [muestras]')
     plt.xlabel('Frecuencia [rad/muestra]')
     plt.title('Retardo de grupo')
     plt.show()
Example #2
0
 def zplane(self, a, b):
     # Fix axes
     ax = plt.gca()
     ax.spines['left'].set_position('zero')
     ax.spines['bottom'].set_position('zero')
     ax.spines['right'].set_visible(False)
     ax.spines['top'].set_visible(False)
     # Draw circle
     circle = patches.Circle((0, 0),
                             radius=1,
                             color='black',
                             ls='dashed',
                             fill=False)
     ax.add_patch(circle)
     # Make a and b of equal length
     a = numpy.append(a, numpy.repeat(0, max(len(a), len(b)) - len(a)))
     b = numpy.append(b, numpy.repeat(0, max(len(a), len(b)) - len(b)))
     # Plot poles
     p = numpy.roots(a)
     plt.plot(p.real, p.imag, 'kx', ms=7)
     # Plot zeros
     z = numpy.roots(b)
     plt.plot(z.real, z.imag, 'ko', ms=7)
     plt.axis('scaled')
     plt.show()
Example #3
0
 def plot_freq_resp(self, a, b, worN=None):
     w, h = signal.freqz(b, a, worN)
     plt.plot(w, 20 * numpy.log10(abs(h)), 'b')
     plt.ylabel('Amplitud [dB]', color='b')
     plt.xlabel('Frecuencia [rad/muestra]')
     plt.gca().twinx()
     angles = numpy.unwrap(numpy.angle(h))
     plt.plot(w, angles, 'g')
     plt.ylabel('Fase (rad)', color='g')
     plt.grid()
     plt.show()