-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Dinh Anh Vu edited this page Apr 16, 2020
·
8 revisions
import dsp_py as dp # DSP-py-lib of course
import numpy as np # A free-matlab-like package
import matplotlib.pyplot as plt # Use plt.stem() to plot signals in discrete domain
# Tip: use type() to check the output
x, n = dp.Delta(n0, lb, rb)
# n0 is where Delta == 1
# from left bound (lb) to right bound (rb)
x, n = dp.UnitStep(n0, lb, rb)
# n0 is where UnitStep starting == 1
# from left bound (lb) to right bound (rb)
x, n = dp.Rectangle(n0, n1, lb, rb)
# n0 is where UnitStep starting == 1
# n1 is where UnitStep ending == 1
# from left bound (lb) to right bound (rb)
x, n = dp.Exp(a, b, c, lb, rb) # Should not be confused with numpy.exp()
# a.b^(c.t)
# from left bound (lb) to right bound (rb)
x, n = dp.ComplexExp(a, phi, omega, lb, rb) # You can use dsp_py.Exp() instead but this is pure and better if you need complex exponential signal
# a.e^((phi + j.omega).t)
# from left bound (lb) to right bound (rb)
x, n = dp.Sin(A, w, p, lb, rb)
# A is amplitude
# w is omega
# p is phase
x, n = dp.Cos(A, w, p, lb, rb)
# A is amplitude
# w is omega
# p is phase
x, n = dp.Add(x1, n1, x2, n2)
# x(n) = x1(n) + x2(n)
# x1 and n1 are illumination of first signal
# x2 and n2 are illumination of second signal
x, n = dp.Mul(x1, n1, x2, n2)
# x(n) = x1(n)x2(n)
# x1 and n1 are illumination of first signal
# x2 and n2 are illumination of second signal
x, n = dp.Shift(x1, n1, k)
# x1 and n1 are illumination of first signal
# y(n) = x(n-k)
x, n = dp.Fold(x1, n1)
# y(n) = x(-n)
x, n = dp.Convole(x1, n1, x2, n2)
# x(n) = x1(n) * x2(n)
# x1 and n1 are illumination of first signal
# x2 and n2 are illumination of second signal
x, n = dp.Correlate(x1, n1, x2, n2)
# https://en.wikipedia.org/wiki/Cross-correlation
# x1 and n1 are illumination of first signal
# x2 and n2 are illumination of second signal
x_odd, x_even = dp.OddEvenSyn(x)
# x is illumination of a signal
# The output's n is same with the input's
X, w = dp.DTFT(x, n, interval, num)
# x and n are representation of signal in time domain
# interval = [lbw, rbw] of w (omega)
# num is number of equispaced points from lbw to rbw
H, w = dp.FreqRespDE(x_coeff, y_coeff, interval, num)
# Frequency Response from Difference Equation
# interval = [lbw, rbw] of w (omega)
# num is number of equispaced points from lbw to rbw
# x_coeff is numpy array of coefficients of x(n)
# y_coeff is numpy array of coefficients of y(n)
X, w, r = dp.DTZT(x, n, intervalW, numW, intervalR, numR)
# x and n are representation of signal in time domain
# intervalW = [lbw, rbw] of w (omega)
# numW is number of equispaced points from lbw to rbw
# intervalR = [lbr, rbr] of r (radius)
# numR is number of equispaced points from lbr to rbr
# DTZT is more general than DTFT
H, w, r = dp.ZRespDE(x_coeff, y_coeff, intervalW, numW, intervalR, numR)
# Z Respone from Difference Equation
# intervalW = [lbw, rbw] of w (omega)
# numW is number of equispaced points from lbw to rbw
# intervalR = [lbr, rbr] of r (radius)
# numR is number of equispaced points from lbr to rbr
# x_coeff is numpy array of coefficients of x(n)
# y_coeff is numpy array of coefficients of y(n)
from dsp_py.Utilisation import Fill
x, n = Fill(x, n)
# Add meaningful zeros to x
# Also expand n till n == 0
from dsp_py.Utilisation import PrintSignal
PrintSignal(x, n):
# Print x and x(0) is colored green