Commit 0dac22b0 authored by hm-striegle's avatar hm-striegle

Version 0.500

parents
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_cwlaser import pypho_cwlaser
from pypho_optfi import pypho_optfi
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*128, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig_f0 = pypho_cwlaser(glova = gp, power = 3, Df = 0, teta = 1*np.pi/4.0)
sig_f1 = pypho_lasmod(glova = gp, power = 0, Df = 500, teta = 1*np.pi/1.0)
filter_f0 = pypho_optfi(glova = gp, Df = 0, B = 50)
SSMF = pypho_fiber(glova = gp, l = 80, D = 9.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .1)
# Simulation
# Define wavelength channel
E_f0 = sig_f0()
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E_f1 = sig_f1(esig = esig)
E = copy.deepcopy(E_f1)
E[0]['E'][0] = E_f0[0]['E'][0] + E_f1[0]['E'][0] # Multiplex all signals X-Pol
E[0]['E'][1] = E_f0[0]['E'][1] + E_f1[0]['E'][1] # Multiplex all signals Y-Pol
E_Tx = copy.deepcopy(E)
# Plot Spectrum Input signals
plt.figure(1)
plt.subplot(2, 1, 1)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.title("Input spectrum", loc='left')
plt.ylabel('Spec. density');
plt.grid(True)
# Fiber transmission
E = SSMF(E = E)
# Plot Spectrum Output signals
plt.subplot(2, 1, 2)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.title("Output spectrum", loc='left')
plt.ylabel('Spec. density'); plt.xlabel('Frequency deviation [GHz]');
plt.grid(True)
# Calculate phase shift
L_eff = (1-np.exp(-SSMF.l*SSMF.alpha))/(SSMF.alpha)
phi_x_max = - (np.max(np.abs(E_Tx[0]['E'][0])**2) + 2.0/3.0* np.max(np.abs(E_Tx[0]['E'][1])**2))* L_eff * SSMF.gamma *1e-3
phi_y_max = - (np.max(np.abs(E_Tx[0]['E'][1])**2) + 2.0/3.0* np.max(np.abs(E_Tx[0]['E'][0])**2))* L_eff * SSMF.gamma *1e-3
print 'L_eff = ', L_eff
print 'phi_x_max = ', phi_x_max
print 'phi_y_max = ', phi_y_max
# Plot power of both pol axis as function of transmission distance
plt.figure(2)
plt.subplot(2, 1, 2)
plt.ylabel('$10log |E_y|^2$'); plt.xlabel('Transmission distance [m]');
plt.ylim((-120, 10))
plt.grid(True)
plt.subplot(2, 1, 1)
plt.ylabel('$10log |E_y|^2$');
plt.ylim((-120, 10))
plt.grid(True)
plt.legend()
plt.show()
\ No newline at end of file
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_functions import *
import numpy as np
import copy
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
# Define network elements
gp = pypho_setup(nos = 16, sps = 256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.85)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
SSMF = pypho_fiber(glova = gp, l = 80.0e3, D = 17, S = 0, alpha = 0.2e-12, gamma = 0, phi_max=10.0)
# Simulation
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E_Tx = sig_1550(esig = esig)
# Define your parameters here
T_0 = 25.0e-12
z = 100.0e3
D = 17.0
beta_2, beta_3 = DS2beta(17.0, 0, gp.lambda0)
# Create a single pulse with gaussian shape (not power!)
E_Tx[0]['E'][0] = E_Tx[0]['E'][0]*0 + np.exp(-(gp.timeax-gp.timeax[-1]/2)**2 / (2.0*T_0**2) )
E = copy.deepcopy(E_Tx)
# Fiber trannsmission
E = SSMF(E = E, D = D, l = z)
# Plot Input and Output signal
plt.figure(1)
plt.plot(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0]), 'r', label='$E(0, t)$')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0]), 'g', label='$E(z=100$km$, t)$')
# Get FWHM of the input signal E_Tx
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0])-1*np.max(np.abs(E_Tx[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E_Tx[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E_Tx[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, 0.01 +np.max(np.abs(E_Tx[0]['E'][0]))/2, '$T_{FWHM,0}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
T_FWHM_0 = (r2-r1) * 1e-12
T_0_plot = T_FWHM_0 / 2.35482
# Get FWHM of the output signal E
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E[0]['E'][0])-1*np.max(np.abs(E[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, 0.01 + np.max(np.abs(E[0]['E'][0]))/2, '$T_{FWHM,1}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
T_FWHM_1 = (r2-r1) * 1e-12
plt.ylabel('$|E|$ a.u.'); plt.xlabel('Time $t$ [ps]'); legend = plt.legend(loc='upper right')
L_D = (T_0_plot)**2 / np.abs(beta_2)
# Print the results
print 'Input signal 1/e-pulse width by definition : T_0 = ' , T_0*1e12, ' ps'
print 'Input signal 1/e-pulse width from plot : T_0 = ' , T_0_plot*1e12, ' ps'
print 'Input signal FWHM-pulse width from plot : T_FWHM,0 = ' , T_FWHM_0*1e12, ' ps'
print 'Output signal FWHM-pulse width from plot : T_FWHM,1 = ' , T_FWHM_1*1e12, ' ps'
print 'Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM_0 * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps'
\ No newline at end of file
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_eye import pypho_eye
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
# Define some parameter
T_FWHM = 50e-12 # FWHM-pulsewidth of the optical power
T_e = T_FWHM / 1.66510 # 1/e-pulsewidth of the electrical field
z = 29.756e3 # Fiber length
D = 16.8 # Dispersion coefficient
T_FWHM_norm_max = 0.75 # Maximum FWHM pulseiwdth of the
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = T_FWHM*gp.symbolrate)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
SSMF = pypho_fiber(glova = gp, l = z, D = D, S = 0, alpha = 0.2e-12, gamma = 0, phi_max = 10.0)
eye = pypho_eye(glova = gp, polarisation = 'x,y')
# Simulation
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E_Tx = sig_1550(esig = esig)
E = copy.deepcopy(E_Tx)
# Fiber trannsmission
E = SSMF(E = E)
E[0]['E'][0] = E[0]['E'][0] /np.max(np.abs(E[0]['E'][0]))*1e-3
E_Tx[0]['E'][0] = E_Tx[0]['E'][0] /np.max(np.abs(E_Tx[0]['E'][0]))*1e-3
# Plot Input and Output signal
beta_2, beta_3 = DS2beta(D, 0, gp.lambda0)
L_D = (T_e)**2 / np.abs(beta_2) # Pulse width T_e here of the electrical field
plt.figure(1)
eye(E = E_Tx[0]['E'], polarisation = 'x', style="r")
eye(E = E[0]['E'], polarisation = 'x', style="g")
red_patch = mpatches.Patch(color='red', label='Input signal')
green_patch = mpatches.Patch(color='green', label='Output signal')
plt.legend(handles=[red_patch, green_patch], loc=1)
print 'Calculated output FWHM-pulse width : T_FWHM,1 = ' , T_FWHM * np.sqrt(1 + (z/L_D)**2)*1e12, ' ps'
T_FWHM_norm_0 = T_FWHM*1e12 / 100.0
print ( 'Calculated max reach : ' , 100e-12**2 *(1/1.665095)**2 * 2.0*np.pi * 299792458 * T_FWHM_norm_0*np.sqrt( T_FWHM_norm_max**2 - T_FWHM_norm_0**2) / (16.8e-6 * 1550e-9**2 ) *1e-3 )
\ No newline at end of file
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_eye import pypho_eye
from pypho_optfi import pypho_optfi
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*256, symbolrate = 40e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'random') # Set pattern = "singlepulse"
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
sig_1546 = pypho_lasmod(glova = gp, power = 0, Df = +500, teta = 0)
sig_1554 = pypho_lasmod(glova = gp, power = 0, Df = -500, teta = 0)
filter_1550 = pypho_optfi(glova = gp, Df = 0, B = 100)
filter_1546 = pypho_optfi(glova = gp, Df = +500, B = 100)
filter_1554 = pypho_optfi(glova = gp, Df = -500, B = 100)
SSMF = pypho_fiber(glova = gp, l = 100e3, D = 16.8, S = 0.058, alpha = 0.2e-12, gamma = 0, phi_max = 10.0)
DCF = pypho_fiber(glova = gp, l = 16.8e3, D = -100.0, S = -0.058/16.8 * 100.0, alpha = 0.2e-12, gamma = 0, phi_max = 10.0)
eye = pypho_eye(glova = gp, polarisation = 'x,y')
# Simulation
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E_1550 = sig_1550(esig = esig)
E_1546 = sig_1546(esig = esig)
E_1554 = sig_1554(esig = esig)
# Plot Input signals
plt.figure(1)
plt.subplot(3, 1, 1)
plt.title("$\lambda$=1546nm", loc='left')
eye(E = E_1546[0]['E'], polarisation = 'x', style="0.5")
plt.subplot(3, 1, 2)
plt.title("$\lambda$=1550nm", loc='left')
eye(E = E_1550[0]['E'], polarisation = 'x', style="0.5")
plt.subplot(3, 1, 3)
plt.title("$\lambda$=1554nm", loc='left')
eye(E = E_1554[0]['E'], polarisation = 'x', style="0.5")
E_Tx = copy.deepcopy(E_1550)
E_Tx[0]['E'][0] = E_1550[0]['E'][0] + E_1546[0]['E'][0] + E_1554[0]['E'][0] # Multiplex all signals
E = copy.deepcopy(E_Tx)
# Fiber trannsmission
E = SSMF(E = E,l = 100e3, D = 16.8, S = 0.058)
E = DCF(E = E,l = 16.8e3, D = -100, S = -0.058/16.8 * 100) # For full dispersion compenstion set S = -0.058/16.8 * 100
# Filter out the channels
E_1550 = filter_1550(E = copy.deepcopy(E))
E_1546 = filter_1546(E = copy.deepcopy(E))
E_1554 = filter_1554(E = copy.deepcopy(E))
# Plot Output signals
#plt.figure(2)
plt.subplot(3, 1, 1)
eye(E = E_1546[0]['E'], polarisation = 'x', style="r")
red_patch = mpatches.Patch(color='0.5', label='Input signal')
green_patch = mpatches.Patch(color='red', label='Output signal')
plt.legend(handles=[red_patch, green_patch], loc=1)
plt.subplot(3, 1, 2)
eye(E = E_1550[0]['E'], polarisation = 'x', style="r")
plt.subplot(3, 1, 3)
eye(E = E_1554[0]['E'], polarisation = 'x', style="r")
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_fiber import pypho_fiber
from pypho_cwlaser import pypho_cwlaser
from pypho_optfi import pypho_optfi
from pypho_functions import *
import numpy as np
import copy
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
# Define some paramaters
delta_f = 25 # Frequency difference of the two cw-signals
L = 20e3 # Fiber length in m
l = 0.1e3 # Step fiber length in m
k = 7 # Defines how man channels left and right will be analyzed
chut = np.arange(-k*delta_f, k*delta_f+delta_f, delta_f) # Channels under test
P_FWM_x = np.zeros((chut.size, int(L/l)))
P_FWM_y = np.zeros((chut.size, int(L/l)))
# Define network elements
gp = pypho_setup(nos = 4*16, sps = 1*128, symbolrate = 10e9)
sig_f0 = pypho_cwlaser(glova = gp, power = 3, Df = 0, teta = 1*np.pi/4.0)
sig_f = pypho_cwlaser(glova = gp, power = 3, Df = delta_f, teta = 1*np.pi/2.0)
filter_df = pypho_optfi(glova = gp, Df = 0, B = 10)
SSMF = pypho_fiber(glova = gp, l = l, D = 5.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .1)
# Simulation
# Define wavelength channel
E_f0 = sig_f0()
E_fm1 = sig_f(Df = +delta_f, teta = np.pi/2)
E_fp1 = sig_f(Df = -delta_f, teta = np.pi/2)
E_fm2 = sig_f(Df = -2*delta_f, teta = np.pi/2)
E_fp2 = sig_f(Df = +2*delta_f, teta = np.pi/2)
E = copy.deepcopy(E_fm1)
E[0]['E'][0] = E_f0[0]['E'][0] + E_fp1[0]['E'][0] + E_fm1[0]['E'][0] + E_fp2[0]['E'][0] + E_fm2[0]['E'][0] # Multiplex all signals X-Pol
E[0]['E'][1] = E_f0[0]['E'][1] + E_fp1[0]['E'][1] + E_fm1[0]['E'][1] + E_fp2[0]['E'][1] + E_fm2[0]['E'][1] # Multiplex all signals Y-Pol
E_Tx = copy.deepcopy(E)
# Plot Spectrum Input signals
plt.figure(1)
plt.subplot(2, 1, 1)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.title("Input spectrum", loc='left')
plt.ylabel('Spec. density');
plt.grid(True)
# Fiber transmission
c1 = 0
for z in np.arange(0,L,l):
print(z)
c2 = 0
for ch in chut: # Loop through wavelengths and save mean power value of both pol axis
E_filtered = filter_df(copy.deepcopy(E), Df = ch)
P_FWM_x[c2][c1] = np.mean( np.abs(E_filtered[0]['E'][0])**2 )
P_FWM_y[c2][c1] = np.mean( np.abs(E_filtered[0]['E'][1])**2 )
c2 = c2 + 1
c1 = c1 + 1
E = SSMF(E = E)
# Plot Spectrum Output signals
plt.subplot(2, 1, 2)
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][0] )**2))), 'r')
plt.plot((gp.freqax-gp.f0)*1e-9, np.log10(abs(fftshift(fft(E[0]['E'][1] )**2))), 'g:')
plt.title("Output spectrum", loc='left')
plt.ylabel('Spec. density'); plt.xlabel('Frequency deviation [GHz]');
plt.grid(True)
# Plot power of both pol axis as function of transmission distance
plt.figure(2)
for i in np.arange(0,chut.size):
plt.subplot(2, 1, 1)
plt.plot(np.arange(0,L,l), 10*np.log10(P_FWM_x[i]*1e3), label=str(chut[i]) + ' GHz')
plt.subplot(2, 1, 2)
plt.plot(np.arange(0,L,l), 10*np.log10(P_FWM_y[i]*1e3))
plt.subplot(2, 1, 2)
plt.ylabel('$10log |E_y|^2$'); plt.xlabel('Transmission distance [m]');
plt.ylim((-120, 10))
plt.grid(True)
plt.subplot(2, 1, 1)
plt.ylabel('$10log |E_y|^2$');
plt.ylim((-120, 10))
plt.grid(True)
plt.legend()
plt.show()
\ No newline at end of file
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber import pypho_fiber
from pypho_functions import *
import numpy as np
import copy
import matplotlib.pyplot as plt
# Define network elements
gp = pypho_setup(nos = 16, sps = 1*128, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'ones')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.33)
sig = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = np.pi/8)
SSMF = pypho_fiber(glova = gp, l = 80e3, D = 0.0, S = 0.0, alpha = 0.2, gamma = 1.4, phi_max = .1)
# Simulation
# Define wavelength channel
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E = sig(esig = esig)
E_Tx = copy.deepcopy(E)
# Fiber transmission
E = SSMF(E = E)
# Plot power and phase of both pol axis
plt.figure(1)
plt.subplot(2, 1, 1)
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0])**2, 'r', label='$E_x(0, t)$')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][1])**2, 'g', label='$E_y(0, t)$')
plt.ylabel('$10log |E_{x,y}|^2$'); plt.xlabel('Time [ps]');
plt.grid(True)
plt.legend()
plt.subplot(2, 1, 2)
plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][0]), 'r', label='$E_x(0, t)$')
plt.plot(gp.timeax*1.0e12, np.angle(E[0]['E'][1]), 'g', label='$E_y(0, t)$')
plt.ylabel('$ \phi_{x,y} $'); plt.xlabel('Time [ps]');
plt.grid(True)
plt.legend()
plt.show()
# Calculate phase shift
L_eff = (1-np.exp(-SSMF.l*SSMF.alpha))/(SSMF.alpha)
phi_x_max = - (np.max(np.abs(E_Tx[0]['E'][0])**2) + 2.0/3.0* np.max(np.abs(E_Tx[0]['E'][1])**2))* L_eff * SSMF.gamma *1e-3
phi_y_max = - (np.max(np.abs(E_Tx[0]['E'][1])**2) + 2.0/3.0* np.max(np.abs(E_Tx[0]['E'][0])**2))* L_eff * SSMF.gamma *1e-3
print 'L_eff = ', L_eff
print 'phi_x_max = ', phi_x_max
print 'phi_y_max = ', phi_y_max
\ No newline at end of file
##!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Import functions and libraries
# Relase 0.5
# arne.striegler@hm.edu
import sys
sys.path.append('../')
from pypho_setup import pypho_setup
from pypho_bits import pypho_bits
from pypho_signalsrc import pypho_signalsrc
from pypho_lasmod import pypho_lasmod
from pypho_fiber_mod import pypho_fiber
from pypho_functions import *
import numpy as np
import copy
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
# Define network elements
gp = pypho_setup(nos = 16, sps = 256, symbolrate = 10e9)
bitsrc = pypho_bits(glova = gp, nob = gp.nos, pattern = 'singlepulse')
esigsrc = pypho_signalsrc(glova = gp, pulseshape = 'gauss_rz' , fwhm = 0.85)
sig_1550 = pypho_lasmod(glova = gp, power = 0, Df = 0, teta = 0)
SSMF = pypho_fiber(glova = gp, l = 80.0e3, D = 17, S = 0, alpha = 0.2e-12, gamma = 0, phi_max=10.0)
# Simulation
bits = bitsrc()
esig = esigsrc(bitsequence = bits)
E_Tx = sig_1550(esig = esig)
# Define your parameters here
T_0 = 25.0e-12
z = 50.0e3
D = 17.0
beta_2, beta_3 = DS2beta(17.0, 0, gp.lambda0)
# Create a single pulse with gaussian shape (not power!)
E_Tx[0]['E'][0] = E_Tx[0]['E'][0]*0 + np.exp(-(gp.timeax-gp.timeax[-1]/2)**2 / (2.0*T_0**2) )
E = copy.deepcopy(E_Tx)
E[0]['E'][0] = E[0]['E'][0]*0 + np.sqrt(np.exp(-(gp.timeax-gp.timeax[-1]/2)**2 / (2.0*T_0**2) ) )
Eq = copy.deepcopy(E_Tx)
Eq[0]['E'][0] = Eq[0]['E'][0]*0 + (np.exp(-(gp.timeax-gp.timeax[-1]/2)**2 / (2.0*T_0**2) ) )**2
# Plot Input and Output signal
plt.figure(1)
plt.plot(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0]), 'r', label='Power: Gauss')
plt.plot(gp.timeax*1.0e12, np.abs(E[0]['E'][0]), 'g', label='Power: sqrt.Gauss')
plt.plot(gp.timeax*1.0e12, np.abs(Eq[0]['E'][0]), 'b', label='Power: Gauss**2')
# Get FWHM of the input signal E_Tx
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E_Tx[0]['E'][0])-1*np.max(np.abs(E_Tx[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E_Tx[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E_Tx[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, 0.04 +np.max(np.abs(E_Tx[0]['E'][0]))/2, '$T_{FWHM_0}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
T_FWHM_0 = (r2-r1) * 1e-12
T_e_0 = T_FWHM_0 / 2.35482
# Get FWHM of the output signal E
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(E[0]['E'][0])-1*np.max(np.abs(E[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(E[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(E[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, -0.04 + np.max(np.abs(E[0]['E'][0]))/2, '$T_{FWHM_1}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
T_FWHM_1 = (r2-r1) * 1e-12
T_e_1 = T_FWHM_1 / 2.35482
# Get FWHM of the output signal E
spline = UnivariateSpline(gp.timeax*1.0e12, np.abs(Eq[0]['E'][0])-1*np.max(np.abs(Eq[0]['E'][0]))/2, s=0)
r1, r2 = spline.roots() # find the roots
plt.annotate(s='', xy=(r1,np.max(np.abs(Eq[0]['E'][0]))/2), xytext=(r2,np.max(np.abs(Eq[0]['E'][0]))/2), arrowprops=dict(arrowstyle='<->'))
plt.text(r1+(r2-r1)/2.0, -0.1 + np.max(np.abs(Eq[0]['E'][0]))/2, '$T_{FWHM_q}$ = ' + str(np.round(r2-r1,2)) + ' ps', fontsize=12, horizontalalignment='center')
T_FWHM_q = (r2-r1) * 1e-12
T_e_q = T_FWHM_q / 2.35482
plt.ylabel('$|E|$ a.u.'); plt.xlabel('Time $t$ [ps]'); legend = plt.legend(loc='upper right')
# Print the results
print 'Power: Gauss : T_FWHM_0 = ' , T_FWHM_0*1e12, ' ps'
print 'Power: Gauss : T_e_0 = ' , T_e_0*1e12, ' ps'
print 'Power: sqrt.Gauss : T_FWHM_1,0 = ' , T_FWHM_1*1e12, ' ps'
print 'Power: sqrt.Gauss : T_e_0,1 = ' , T_e_1*1e12, ' ps'
print 'Power: Gauss**2 : T_FWHM_0 = ' , T_FWHM_q*1e12, ' ps'
print 'Power: Gauss**2 : T_e_0 = ' , T_e_q*1e12, ' ps'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# pypho.py
#
# Copyright 2014 Arne Striegler (arne.striegler@hm.edu)
#
#
#
# Create Bitpattern
#
########################################################################
import numpy as np
import sys
import random
from pypho_functions import *
########################################################################
class pypho_bits(object):
def __init__(self, glova = None, nob = None, pattern = None):
if glova == None:
print ("ERROR: You must define the global variables")
sys.exit("PyPho stopped!")
self.glova = glova
self.nob = None
self.pattern = None
self.set(nob,pattern)
########################################################################
def __call__(self, nob = None, pattern = None):
self.set(nob, pattern)
return self.out(self.nob, self.pattern)
########################################################################
def out(self, nob = None, pattern = None):
self.set(nob, pattern)
if self.pattern == "singlepulse":
self.bits = np.zeros(self.nob, dtype=np.int)
self.bits[self.glova.nos/2] = 1
elif self.pattern == "ones":
self.bits = np.ones(self.nob, dtype=np.int)
elif self.pattern == "random":
self.bits = self.rndm()
else:
print ("ERROR: No valid pattern specified!")
sys.exit("PyPho stopped!")
return self.bits
### Create Random Bit Sequence #########################################
def rndm(self):
self.value_rndn = np.ones(self.nob)
self.value_rndn[self.nob/2:] = 0
random.shuffle(self.value_rndn)
self.value_rndn[0] = 1
self.value_rndn[-1] = 0
self.bits = np.array(self.value_rndn)
return self.value_rndn
### Get and set parameters #############################################
# nos: Number of Bits
@property
def nos(self):
"""Get number of bits"""
return self.bits.size
########################################################################