-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
13,609 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
Hann = True | ||
|
||
#- Create a time vector | ||
N = 2**13 | ||
t = np.linspace(0,N,N) | ||
|
||
#- Create the "continuous time" signal with multiple sinusoidal signals and some noise | ||
f1 = 233/N | ||
fd = 1/N*119 | ||
x_s = np.sin(2*np.pi*f1*t) + 1/1024*np.random.randn(N) + 0.5*np.sin(2*np.pi*(f1-fd)*t) + 0.5*np.sin(2*np.pi*(f1+fd)*t) | ||
|
||
#- Create the sampling vector, and the sampled signal | ||
t_s_unit = [1,1,0,0,0,0,0,0] | ||
t_s = np.tile(t_s_unit,int(N/len(t_s_unit))) | ||
x_sn = x_s*t_s | ||
|
||
#- Convert to frequency domain with a hanning window to avoid FFT bin | ||
#- energy spread | ||
if(Hann): | ||
w = np.hanning(N+1) | ||
else: | ||
w = np.ones(N+1) | ||
X_s = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_s))) | ||
X_sn = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_sn))) | ||
|
||
|
||
|
||
plt.subplot(2,2,1) | ||
plt.ylabel("Time Domain") | ||
plt.plot(x_s) | ||
plt.xlabel("Continuous time, continuous value") | ||
plt.subplot(2,2,2) | ||
plt.plot(x_sn) | ||
plt.ylabel("Frequency Domain") | ||
plt.xlabel("Discrete time, continuous value") | ||
plt.subplot(2,2,3) | ||
plt.plot(20*np.log10(np.abs(X_s))) | ||
plt.subplot(2,2,4) | ||
plt.plot(20*np.log10(np.abs(X_sn))) | ||
|
||
fig = plt.gcf() | ||
fig.set_size_inches(12, 7) | ||
plt.tight_layout() | ||
plt.savefig(f"l5_dt.pdf") | ||
plt.show() |
Oops, something went wrong.