-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,11 +154,11 @@ | |
| σ2_s = 2*q*(Ip + Id)*B # variância | ||
| μ = 0 # média | ||
|
|
||
| σ = np.sqrt(σ2_s) | ||
| σ = np.sqrt(σ2_s) | ||
| Is = normal(μ, σ, Namostras) | ||
|
|
||
| # plotas as primeiras 1000 amostras | ||
| plt.plot(Is[0:1000],linewidth = 0.8); | ||
| plt.plot(Is[:1000], linewidth = 0.8); | ||
|
Comment on lines
-157
to
+161
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| plt.xlim(0,1000) | ||
| plt.ylabel('Is') | ||
| plt.xlabel('amostra') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,17 +298,15 @@ def hybrid_2x4_90(E1, E2): | |
|
|
||
| M = Matrix([[C_3dB, zeros(2)], | ||
| [zeros(2), C_3dB]]) | ||
|
|
||
| U = Matrix([[1, 0, 0, 0], | ||
| [0, 0, 1, 0], | ||
| [0, 1, 0, 0], | ||
| [0, 0, 0, j]]) | ||
|
|
||
| Ei = Matrix([[E1],[0],[0],[E2]]) # vetor 4x1 | ||
|
|
||
| Eo = M*U*M*Ei | ||
|
|
||
| return Eo | ||
|
|
||
| return M*U*M*Ei | ||
|
Comment on lines
-301
to
+309
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| # fotodetector balanceado | ||
| def bpd(E1, E2, R=1): | ||
|
|
@@ -406,19 +404,17 @@ def hybrid_2x4_90deg(E1, E2): | |
| :return: hybrid outputs | ||
| ''' | ||
| assert E1.size == E2.size, 'E1 and E2 need to have the same size' | ||
|
|
||
| # optical hybrid transfer matrix | ||
| T = np.array([[ 1/2, 1j/2, 1j/2, -1/2], | ||
| [ 1j/2, -1/2, 1/2, 1j/2], | ||
| [ 1j/2, 1/2, -1j/2, -1/2], | ||
| [-1/2, 1j/2, -1/2, 1j/2]]) | ||
|
|
||
| Ei = np.array([E1, np.zeros((E1.size,)), | ||
| np.zeros((E1.size,)), E2]) | ||
|
|
||
| Eo = T@Ei | ||
|
|
||
| return Eo | ||
|
|
||
| return T@Ei | ||
|
Comment on lines
-409
to
+417
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def coherentReceiver(Es, Elo, Rd=1): | ||
| ''' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,52 +70,51 @@ def manakovSSF(Ei, hz, Lspan, Ltotal, alpha, gamma, D, Fc, Fs): | |
|
|
||
| Ex = Ei[:,0] | ||
| Ey = Ei[:,1] | ||
|
|
||
| c = 299792458 # speed of light (vacuum) | ||
| c_kms = c/1e3 | ||
| λ = c_kms/Fc | ||
| α = alpha/(10*np.log10(np.exp(1))) | ||
| β2 = -(D*λ**2)/(2*np.pi*c_kms) | ||
| γ = gamma | ||
|
|
||
| Nfft = len(Ex) | ||
|
|
||
| ω = 2*np.pi*Fs*fftfreq(Nfft) | ||
|
|
||
| Nspans = int(np.floor(Ltotal/Lspan)) | ||
| Nsteps = int(np.floor(Lspan/hz)) | ||
|
|
||
| Ex = fft(Ex) #Pol. X | ||
| Ey = fft(Ey) #Pol. Y | ||
|
|
||
| linOperator = np.exp(-(α/2)*(hz/2) + 1j*(β2/2)*(ω**2)*(hz/2)) | ||
|
|
||
| for spanN in tqdm(range(1, Nspans+1)): | ||
| for stepN in range(1, Nsteps+1): | ||
|
|
||
|
|
||
| for _ in tqdm(range(1, Nspans+1)): | ||
| for _ in range(1, Nsteps+1): | ||
|
Comment on lines
-73
to
+94
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| # First linear step (frequency domain) | ||
| Ex = Ex*linOperator | ||
| Ey = Ey*linOperator | ||
|
|
||
| # Nonlinear step (time domain) | ||
| Ex = ifft(Ex); | ||
| Ey = ifft(Ey); | ||
|
|
||
| Ex = Ex*np.exp(1j*γ*8/9*(Ex*np.conj(Ex) + Ey*np.conj(Ey))*hz) | ||
| Ey = Ey*np.exp(1j*γ*8/9*(Ex*np.conj(Ex) + Ey*np.conj(Ey))*hz) | ||
|
|
||
| # Second linear step (frequency domain) | ||
| Ex = fft(Ex); | ||
| Ey = fft(Ey); | ||
| Ex = Ex*linOperator | ||
| Ey = Ey*linOperator | ||
|
|
||
| Ex = Ex*np.exp(α*Nsteps*hz) | ||
| Ey = Ey*np.exp(α*Nsteps*hz) | ||
|
|
||
| Ex = ifft(Ex) | ||
| Ey = ifft(Ey) | ||
|
|
||
| return Ex, Ey | ||
|
|
||
| def edfa_lin(signal, gain, nf, fc, fs): | ||
|
|
@@ -207,7 +206,7 @@ def filterNoDelay(h, x): | |
|
|
||
| # generate random bits | ||
| np.random.seed(33) | ||
| bits_x = np.random.randint(2, size=3*2**14) | ||
| bits_x = np.random.randint(2, size=3*2**14) | ||
|
Comment on lines
-210
to
+209
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| np.random.seed(23) | ||
| bits_y = np.random.randint(2, size=3*2**14) | ||
|
|
||
|
|
@@ -228,7 +227,7 @@ def filterNoDelay(h, x): | |
|
|
||
| # pulse shaping | ||
| tindex, rrcFilter = rrcosfilter(N, alphaRRC, Ts, Fa) | ||
| sig_x = filterNoDelay(rrcFilter, symbolsUp_x) | ||
| sig_x = filterNoDelay(rrcFilter, symbolsUp_x) | ||
| sig_y = filterNoDelay(rrcFilter, symbolsUp_y) | ||
|
|
||
| sig_x = np.sqrt(P0/2)*sig_x/np.sqrt(signal_power(sig_x)) | ||
|
|
@@ -259,7 +258,7 @@ def filterNoDelay(h, x): | |
| sigRx = sigRx/np.sqrt(signal_power(sigRx)) | ||
|
|
||
| # matched filter | ||
| sigRx = filterNoDelay(rrcFilter, sigRx) | ||
| sigRx = filterNoDelay(rrcFilter, sigRx) | ||
| sigRx = sigRx/SpS | ||
|
|
||
| # downsampling to one sample per symbol | ||
|
|
@@ -290,7 +289,7 @@ def filterNoDelay(h, x): | |
| BERtheory = theoryBER(M, EbN0dB,'qam') | ||
|
|
||
| # print results | ||
| print('EbN0: %3.2f dB, EbN0_est: %3.2f dB,\nBERtheory: %3.1e, BER: %3.1e ' %(EbN0dB, EbN0dB_est, BERtheory, BER)) | ||
| print('EbN0: %3.2f dB, EbN0_est: %3.2f dB,\nBERtheory: %3.1e, BER: %3.1e ' %(EbN0dB, EbN0dB_est, BERtheory, BER)) | ||
| print('Total of bits counted: ', ERR.size) | ||
|
|
||
| # plot constellations | ||
|
|
@@ -306,7 +305,7 @@ def filterNoDelay(h, x): | |
| # + | ||
| from scipy.stats.kde import gaussian_kde | ||
|
|
||
| y = (sigRx[0:30000]).real | ||
| y = sigRx[:30000].real | ||
| x = np.arange(0,y.size,1) % 24 | ||
|
|
||
| k = gaussian_kde(np.vstack([x, y])) | ||
|
|
@@ -319,8 +318,8 @@ def filterNoDelay(h, x): | |
| # + | ||
| from scipy.stats.kde import gaussian_kde | ||
|
|
||
| y = (symbRx[0:30000]).real | ||
| x = (symbRx[0:30000]).imag | ||
| y = symbRx[:30000].real | ||
| x = symbRx[:30000].imag | ||
|
|
||
| k = gaussian_kde(np.vstack([x, y])) | ||
| k.set_bandwidth(bw_method=k.factor/2) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
genConstrefactored with the following changes:use-fstring-for-concatenation)assign-if-exp)