import scipy
import cmath
from numpy import *
#Variable Declaration
S11=0.85*scipy.e**(-30j*scipy.pi/180)
S12=0.07*scipy.e**(56j*scipy.pi/180)
S21=1.68*scipy.e**(120j*scipy.pi/180)
S22=0.85*scipy.e**(-40j*scipy.pi/180)
Zl=75
Zo=75
#Calculations
Tl=(Zl-Zo)/(Zl+Zo)
Ti=S11+(S12*S21*Tl)/(1-S22*Tl) #reflection coefficient
Timod=abs(Ti) #mod of Ti
Tiang=scipy.arctan(Ti.imag/Ti.real)*180/scipy.pi #argument of Ti in degrees
#Results
print 'input reflection coefficient =',Timod,'/',Tiang,'degrees'
import scipy
#Variable Declaration
d=80*(10)**-6 #diameter in m
n1=1.62 #core refractive index
NA=0.21 #numerical aperture
L=8*(10)**-7 #wavelength in m
#Calculations
P=scipy.arcsin(NA)*180/scipy.pi #acceptance angle
n2=scipy.sqrt(n1**2-NA**2) #refractive index
V=(scipy.pi*d/L)*scipy.sqrt(n1**2-n2**2)
N=V**2/2 #number of modes
#Results
print 'Acceptance angle =',round(P,2),'degrees'
print 'Refractive index =',round(n2,3)
print 'No. of modes =',round(N,0)
import scipy
#Variable Declaration
a=0.25 #in dB/km
P=1-0.4 #strength of pulse im %
#Calculation
l=(10/a)*scipy.log(1/P)/scipy.log(10) #distance in km
#Result
print 'distance through which the power is reduced by 40% =',round(l,3),'km'