from __future__ import division
from sympy import Symbol
L = Symbol('L') #Defining L as lambda
l = 10*L
N = 20 # number of elements
d = l/N
BW1 = (2*(L/d)*1/N) #bandwidth
print "Null-to-null BW of broadside array in radians when l = 10*L,N = 20:",round(BW1,2)
l = 50*L
N = 100 # number of elements
d = l/N
BW2 = (2*(L/d)*1/N) #bandwidth
print "Null-to-null BW of broadside array in radians when l = 50*L,N = 100:",round(BW2,2)
l = 20*L
N = 50 # number of elements
d = l/N
BW3 = (2*(L/d)*1/N) #bandwidth
print "Null-to-null BW of broadside array in radians when l = 20*L,N = 50:",round(BW3,2)
from __future__ import division
from sympy import Symbol
from math import sqrt
L = Symbol('L') #Defining L as lambda
l = 10*L
N = 20 # number of elements
d = l/N
BW1 = 2*sqrt((2*(L/d)*1/N)) #bandwidth
print "Null-to-null BW of end-fire array in radians when l = 10*L,N = 20:",round(BW1,3)
l = 50*L
N = 100 # number of elements
d = l/N
BW2 = 2*sqrt((2*(L/d)*1/N)) #bandwidth
print "Null-to-null BW of end-fire array in radians when l = 50*L,N = 100:",round(BW2,3)
l = 20*L
N = 50 # number of elements
d = l/N
BW3 = 2*sqrt((2*(L/d)*1/N)) #bandwidth
print "Null-to-null BW of end-fire array in radians when l = 20*L,N = 50:",round(BW3,3)
from __future__ import division
from math import sqrt
#variable declaration
f = 6 #frequency in GHz
f = 6*10**9 #frequency in Hz
c = 3*10**8 #speed of light in m/s
l = 10 # array length in meter
#calculations
lamda = c/f #wavelength in meter
# formula : BWFN = 2*lambda/l
BWFN = 2*(lamda/l) # band width in radians
D = 2*(l/lamda) # directivity
#result
print "null-to-null Beamwidth of broad side array in radians:",round(BWFN,2)
print "Directivity:",round(D,3)
from __future__ import division
from math import pi
#variable declaration
f = 10 #frequency in Ghz
f = 10*10**9 #frequency in hertz
c = 3*10**8 #speed of light in m/s
lamda = c/f #wavelength in meter
N = 50 # number of elements
#calculations
d = 0.5*lamda # element spacing in meter
Beta = 2*(pi)/lamda # phase shift
alpha = Beta*d # progressive phase shift in radians
l = N*d # Array length in meter
#result
print "progressive phase shift in radians:",round(alpha,3)
print "Array length in meter",round(l,3)
from __future__ import division
from math import pi
from sympy import Symbol
#variable declaration
N = 100 # no. of elements
Lm = Symbol('Lm') # defining Lm as lambda
#calculations
d = 0.5*Lm
l = N*d # array length
BWFN = 114.6 /(l/Lm) # beam width in degrees
HPBW = BWFN/2 # half power beam width in degrees
D1 = 2*(l/Lm) # directivity of broad side array
D2 = 4*(l/Lm) # directivity of end fire array
#result
print "half power beamwidth in degrees:",round(HPBW,3)
print "null-to-null beamwidth in degrees:",round(BWFN,3)
print "directivity of broad side array:",round(D1,1)
print "directivity of end fire array:",round(D2,1)
# note : answer in the book is mis-printed,the HPBW is not 11.46 it should be 1.146 degrees.
# note: misprint in second step of part a in book correct is l = N*d = 100*0.5*lamda = 50*lamda
from __future__ import division
import numpy as np
from math import factorial
# formula :combination(n,r)=(factorial(n))/(factorial(r)*factorial(n-r))
print("when n=2")
n=2
a_0=factorial(1)/factorial(0)*factorial(1) #relative excitation level 1
a_1=factorial(1)/factorial(1)*factorial(0) #relative excitation level 2
print "relative excitation levels of binomial array at n=2:",np.array([a_0,a_1])
print("when n=3")
n=3
a_1=factorial(1)/factorial(1)*factorial(0) #relative excitation level 2
a_0=2*a_1 # relative excitation level 1
print "relative excitation levels of binomial array at n=3:",np.array([a_1,a_0,a_1])
from __future__ import division
from math import log10,pi
#variable declaration
d = 30 #separation distance in meter
f = 10 #frequency in mega hertz
f = 10*10**6 #frequency in hertz
c = 3*10**8 #speed of light in m/s
lamda = c/f #wavelength in meter
Gt = 1.65 #transmitting gain in dB
Gr = 1.65 #receiving gain in dB
#calculations
# basic transmission loss :
# formula : Lb = 10*log(((4*(pi)*d)**2/(lamda)**2))
Lb = 10*log10((4*(pi)*d)**2/(lamda)**2) # basic transmmision loss in dB
# actual transmission loss :
La = Lb-Gt-Gr # actual transmisson loss in dB
#result
print "basic transmmision loss in dB:",round(Lb,3)
print "actual transmisson loss in dB:",round(La,3)
from __future__ import division
from math import log10,pi
f = 0.3 #frequency in Ghz
f = 0.3*10**9 #frequency in hertz
c = 3*10**8 #speed of light in m/s
lamda = c/f #wavelength in meter
d1 = 1.6 # in Km
d1 = 1.6*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb1 = 20*log10(4*pi*d1/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 1.6Km,f = 0.3GHz:",round(Lb1,3)
d2 = 16 # in Km
d2 = 16*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb2 = 20*log10(4*pi*d2/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 16Km,f = 0.3GHz:",round(Lb2,3)
d3 = 160 # in Km
d3 = 160*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb3 = 20*log10(4*pi*d3/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 160Km,f = 0.3GHz:",round(Lb3,3)
d4 = 320 # in Km
d4 = 320*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb4 = 20*log10(4*pi*d4/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 320Km,f = 0.3GHz:",round(Lb4,3)
# when frequency is 3Ghz
# given :
f = 3 #frequency in Ghz
f = 3*10**9 #frequency in hertz
c = 3*10**8 #speed of light in m/s
lamda = c/f #wavelength in meter
d1 = 1.6 # in Km
d1 = 1.6*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb1 = 20*log10(4*pi*d1/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 1.6Km,f = 3GHz:",round(Lb1,3)
d2 = 16 # in Km
d2 = 16*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb2 = 20*log10(4*pi*d2/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 16Km,f = 3GHz:",round(Lb2,3)
d3 = 160 # in Km
d3 = 160*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb3 = 20*log10(4*pi*d3/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 160Km,f = 3GHz:",round(Lb3,3)
d4 = 320 # in Km
d4 = 320*10**3 # in meter
# formula : Lb = 20*log10((4*(pi)*d)/(lamda))
Lb4 = 20*log10(4*pi*d4/lamda) # basic transmission loss in dB
print "basic transmission loss in dB when d = 320Km,f = 3GHz:",round(Lb4,3)
from __future__ import division
from math import log10,pi
Gt=10 # transmission gain in dB
Gr=10 # receiving gain in dB
#when frequency=0.3GHz
# given :
f=0.3 #frequency in Ghz
f=0.3*10**9 #frequency in hertz
c=3*10**8 #speed of light in m/s
lamda=c/f #wavelength in meter
d1=1.6 # in Km
d1=1.6*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb1=20*log10(4*pi*d1/lamda) # basic transmission loss in dB
La1=Lb1-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=1.6Km,f=0.3GHz:",round(La1,2)
d2=16 # in Km
d2=16*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb2=20*log10(4*pi*d2/lamda) # basic transmission loss in dB
La2=Lb2-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=16Km,f=0.3GHz:",round(La2,2)
d3=160 # in Km
d3=160*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb3=20*log10(4*pi*d3/lamda) # basic transmission loss in dB
La3=Lb3-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=160Km,f=0.3GHz:",round(La3,2)
d4=320 # in Km
d4=320*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb4=20*log10(4*pi*d4/lamda) # basic transmission loss in dB
La4=Lb4-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=320Km,f=0.3GHz:",round(La4,2)
# when frequency is 3Ghz
# given :
f=3 #frequency in Ghz
f=3*10**9 #frequency in hertz
c=3*10**8 #speed of light in m/s
lamda=c/f #wavelength in meter
d1=1.6 # in Km
d1=1.6*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb1=20*log10(4*pi*d1/lamda) # basic transmission loss in dB
La1=Lb1-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=1.6Km,f=3GHz:",round(La1,2)
d2=16 # in Km
d2=16*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb2=20*log10(4*pi*d2/lamda) # basic transmission loss in dB
La2=Lb2-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=16Km,f=3GHz:",round(La2,2)
d3=160 # in Km
d3=160*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb3=20*log10(4*pi*d3/lamda) # basic transmission loss in dB
La3=Lb3-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=160Km,f=3GHz:",round(La3,2)
d4=320 # in Km
d4=320*10**3 # in meter
# formula : Lb=20*log10((4*(pi)*d)/(lamda))
Lb4=20*log10(4*pi*d4/lamda) # basic transmission loss in dB
La4=Lb4-Gt-Gr # Actual transmission loss in dB
print "Actual transmission loss in dB when d=320Km,f=3GHz:",round(La4,2)
from __future__ import division
from math import pi
#variable declaration
Wt = 15 # radaited power in watt
f = 60 # in MHz
f = 60*10**6 # in Hz
d = 10 # in m
c = 3*10**8 # in m/s
lamda = c/f # in meter
Gt = 1.64 # transmitting gain in dB
Gr = 1.64 # receiving gain in dB
#calculations
Wr = (Wt*Gt*Gr*(lamda)**2/(4*(pi)*d)**2) # receiving power in watt
#result
print "receiving power in mW:",round(Wr*1000,3)