from __future__ import division
from math import sqrt, pi, log10
# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.
#Given data
P1=60*10**-6# # Power launched in port 1
P2=0.004*10**-6# # Power launched in port 2
P3=26*10**-6# # Power launched in port 3
P4=27.5*10**-6# # Power launched in port 4
# a)Excess loss
E=10*log10(P1/(P3+P4))#
#b)Insertion loss
I1=10*log10(P1/P3)#
I2=10*log10(P1/P4)#
#c)Crosstalk
C=10*log10(P2/P1)#
#d)Split ratio
S=(P3/(P3+P4))*100#
print"Excess loss = %0.1f dB "%(E)#
print"Insertion loss = %0.2f dB "%(I1)#
print"Insertion loss = %0.2f dB "%(I2)#
print"Crosstalk = %0.1f dB "%(C)#
print"Split ratio = %0.1f %% "%(S)#
# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.
#Given data
P1=100*10**-6# # Power launched in port 1
P2=0.005*10**-6# # Power launched in port 2
P3=30*10**-6# # Power launched in port 3
P4=35*10**-6# # Power launched in port 4
# a)Excess loss
E=10*log10(P1/(P3+P4))#
# b)Insertion loss
I1=10*log10(P1/P3)#
I2=10*log10(P1/P4)#
#c)Crosstalk
C=10*log10(P2/P1)#
#d)Split ratio
S=(P3/(P3+P4))*100#
print"Excess loss = %0.2f dB "%(E)#
print"Insertion loss = %0.3f dB "%(I1)#
print"Insertion loss = %0.2f dB "%(I2)#
print"Crosstalk = %0.1f dB "%(C)#
print"Split ratio = %0.2f %% "%(S)#
# The cross talk answer computation is wrong in the book
# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.
#Given data
P1=116.3*10**-6# # Power launched in port 1
P2=0.082*10**-6# # Power launched in port 2
P3=47*10**-6# # Power launched in port 3
P4=52*10**-6# # Power launched in port 4
# a)Excess loss
E=10*log10(P1/(P3+P4))#
#b)Insertion loss
I1=10*log10(P1/P3)#
I2=10*log10(P1/P4)#
#c)Crosstalk
C=10*log10(P2/P1)#
#d)Split ratio
S=(P3/(P3+P4))*100#
print"Excess loss = %0.1f dB "%(E)#
print"Insertion loss = %0.3f dB "%(I1)#
print"Insertion loss = %0.2f dB "%(I2)#
print"Crosstalk = %0.2f "%(C)#
print"Split ratio = %0.2f %% "%(S)#
# The answers vary due to round off error