import math
#Initialisation
h=200 #height in m
d=30*10**3 #distance in km
R=40*10**-6 #height in km
#Calculation
phi=math.atan(h*d**-1) # in radian
phi1=phi*180/math.pi # in degree
n=math.cos(phi1)
r=round(n)/R #radius
#Results
print'Radius = %.1f km'%r
import math
#Initialisation
h=500 #height in m
a=0.000315
b=0.0001361
Re=6370000 #radius of earth in m
#Calculation
n=1+(a*math.exp(-b*h))
n1=(n-1)*10**6 #Refraction index
c=(a*b*math.exp(-b*h))
R=1/c #Radius of path curvature in km
d=1-(Re/R)
K=1/d #K-factor
#Results
print'(1) Refraction index = %d '%n1
print'(2) Radius of path curvature = %d kM'%(R/10**3)
print'(3) K-factor = %.3f'%K
import math
#Initialisation
k1=1.3 #K-factor
k2=0.7 #K-factor
H1=1200 #sea level in m
H2=1400 #sea level in m
re=6370*10**3 #radius of earth in m
f=15*10**9 #frequency in Hz
a1=0.6
d1=15*10**3 #distance in m
d2=20*10**3 #distance in m
c=3*10**8 #speed of light
d=30*10**3 #distance in m
h2=25.24
r2=11.55
a2=0.3
#Calculation
h1=500*d1*d2/(k1*re)
h=c*f**-1
r1=math.sqrt((d1*d2*h)/d)
H11=H1+h1+a1*r1 #in meter
H22=H2+h2+a2*r2 #in meter
#Results
print'(1) H1 = %d m'%H11 #wrong calculation in textbook
print'(2) H2 = %d m'%H22
import math
#Initialisation
hr=-1 #obstacle height and fresnel radius ratio
#Calculation
Ad=-20*hr+10 #Diffraction loss in dB
Ad2=16 #from fig 7.8
Ad3=43
#Results
print'(1) Obstacle loss = %.1f dB'%Ad
print'(2) Knife edge obstacle = %.1f dB'%Ad2
print'(3) Rounded obstacle = %.1f dB'%Ad3
import math
#Initialisation
d1=10 #distance in km
d2=25 #distance in km
re=6370 #earth radius in km
k=0.5 #climatic factor
f=4*10**9 #frequency in Hz
c=3*10**8 #speed of light
d=35 #distance in km
h3=400 #height in m
#Calculation
ho=(500*d1*d2)/(k*re) #Earth buldge in m
h=c*f**-1 #wavelength in m
r1=math.sqrt(d1*10**3*d2*10**3*h*(d*10**3)**-1) #fresnel radius
amsl=h3+ho+13.9 #AMSL
#Results
print'(1) Earth buldge = %.2f m'%ho
print'(2) Fresnel radius = %.1f m'%r1
print'(3) AMSL = %.1f m '%amsl
import math
#Initialisation
pt=500 #Transmitter power in mW
gt=42 #transmitter antenna gain in dB
gr=44 #receiver antenna gain in dB
lbt=2.6 #transmitter branching loss in dB
lbr=3 #receiver branching loss in dB
flt=45 #transmitter feeder length
flr=35 #receiver feeder length
fls=6.5 #feeder loss
prx=-72 #Receiver sensitivity
d=30 #path distance in km
f=8.4 #frequency in ghz
#Calculation
ptx=10*math.log10(pt) #transmitter threshold level
lft=flt*fls/100
lfr=flr*fls/100
eirp=ptx+gt-lbt-lft #Transmitter effective power
sg=ptx-prx
fsl=92.4+20*math.log10(f)+20*math.log10(d)
rsl=ptx+gt+gr-fsl-lft-lfr-lbt-lbr
fm=rsl-prx
#Results
print'EIRP = %.2f dBm'%eirp
print'SG = %.2f dBm'%sg
print'FSL = %.2f dB'%fsl
print'RSL = %.2f dBm'%rsl
print'FM = %.2f dB'%fm
import math
#Initialisation
f=15 #frequency in GHz
f1=18 #frequency in GHz
R=50 #rain intensity
ah=1.154
kh=0.0367
d=20 #distance in kM
#Calculation
yr=kh*R**ah
do=35*math.exp(-0.015*R) #distance in kM
de=d/(1+(d/do)) #distance in kM
Ao=yr*de #Rain Loss in dB
phi=(f**2)/(1+10**-4*f**2)
phi1=(f1**2)/(1+10**-4*f1**2)
H=1.12*10**-3*((phi1/phi)**0.5)*(phi*Ao)**0.55
Ah=Ao*(phi1/phi)**(1-H)
Av=(300*Ah)/(335+Ah) #Rain Loss in dB
#Results
print'(1) Rain Loss, A = %.2f dB'%Ao
print'(2) rain loss for vertical polarization, Av = %.2f dB'%Av
import math
#Initialisation
A=99.8 #in percent
l=1250 #radio link in km
C=155*10**6 #in bps
T=24*60*60 #Total measurement time
#Calculation
U=100-A
u=U/100
ue=u*l/2500
uep=ue*0.3 #propagation unavailability value
M=C*uep*T*10**-3 #number of errored bits due to propagation
#Results
print'Maximum delay bit error per day = %d bits per day'%M
import math
#Initialisation
h=24 #hours
m=60 #minutes
s=60 #seconds
#Calculation
dm=0.004*h*m*(1250*2500**-1) #Maximum degraded minutes
ses=0.00054*h*m*s*(1250*2500**-1) #Severely errored seconds
#Results
print'(1) Maximum degraded minutes per day = %.2f min'%dm
print'(2) Severely errored seconds per day = %.2f s'%ses
import math
#Initialisation
Aa=15 #Transmitter antenna discrimination
Ab=25 #Receiver antenna discrimination
AD=110 #path in km
s=35 #fading in dB
#Calculation
Ad=20*math.log10(AD*CD**-1) #Distance discrimination
CD=30 #path in km
si=Aa+Ab+Ad #in dB
si2=si-s #in dB
#Results
print'(1) S/I = %.1f dB'%si
print'(2) S/I = %.1f dB'%si2
import math
#Initialisation
kq=2.6*10**-6 #geoclimatic coefficient
f=6 #frequency in GHz
d=45 #distance in Km
gc=0.098 #GC factor
ab=0.25 #geoclimatic factor
#Calculation
po=kq*f*gc*d**3 #In country
po1=0.3*ab*(f*4**-1)*(d*50**-1)**3 #In mountainous area
#Results
print'Fading occurrence probability'
print'(1) In country = %.2f'%po
print'(2) In mountainous area = %.3f'%po1
import math
#Initialisation
dn=70 #dN = 70
d1=1000 #height from sea level in m
d2=1400 #height from sea level in m
d=45 #radio link distance in km
#Calculation
K=10**(-4.2-0.0029*-dn) #Climate factor
ep=(d2-d1)/d #magnitude of the path inclination
po=K*d**3*(1+ep)**(-1.2)*10**(0.033*6-1) #Fading occurrence probability
#Results
print'(1) Climate factor K = %.4f = 10^-4'%K
print'(2) Fading occurrence probability Po = %.2f percent'%po
import math
#Initialisation
fm=35 #fade margin
po=0.092 #fading occurrence probability
#Calculation
pw=po*10**(-fm*10**-1) #deep fading occurrence
#Results
print'Deep fading occurrence probability, Pw = %.1f x 10^-5'%(pw*10**5)
import math
#Initialisation
d=20 #distance in kM
po=0.02 #fading occurrence probability at 20 Km
d1=25 #distance in kM
d2=40 #distance in kM
fm1=30 #link in kM
fm2=35 #link in kM
fm3=40 #link in kM
tr=30*24*60
#Calculation
po1=po*(d1*d**-1)**3 #fading occurrence probability at 25 Km
po2=po*(d2/d)**3 #fading occurrence probability at 40 Km
pw=po*10**(-fm1*10**-1) #fade margin at 30
pw1=po1*10**(-fm2*10**-1) #fade margin at 35
pw2=po2*10**(-fm3/10) #fade margin at 40
u=pw+pw1+pw2 #total fade margin
to=u*tr #network outage time
#Results
print'(1) Fading occurrence probability at 20 = %.2f'%po
print' Fading occurrence probability at 25 = %.3f'%po1
print' Fading occurrence probability at 40 = %.2f'%po2
print'(2) Fade margin at 30 = %.1f x 10^-5'%(pw*10**5)
print' Fade margin at 35 = %.2f x 10^-5'%(pw1*10**5)
print' Fade margin at 40 = %.2f x 10^-5'%(pw2*10**5)
print' Total fade margin = %.2f x 10**-5'%(u*10**5)
print'(3) Network outage time , To = %.3f min per month'%(to)
import math
#Initialisation
ur=0.001 #unavailability budget for hypothetical circuit
d=50 #path-length in km
A=0.25 #area conditions
B=1 #area conditions
f=8 #frequency in GHz
#Calculation
pw=ur*(d*(d*d)**-1) #deep fading occurrence probability
po=6*10**-7*A*B*f*(d**3) #fading occurrence probability of desirable link
FM=-math.log10(pw/po)*10 #fade margin
#Results
print'Fade margin = %.1f dB'%FM