import math
#Variable declaration
# diameter of dish (m)
d=30.;
#frequency of radiation (Hz)
f=4.*10**9;
# speed of light(m/s)
c=3.*10**8;
# efficiency of aperture
e=0.6;
#Calculations&Results
wavelength=c/f
print "wavelength of radiating signal=%.3f m"%wavelength
A=math.pi*d**2/4
print "area of aperture A=%.4f m**2"%A
G=4*math.pi*A*e/wavelength**2
print "antenna gain G=%.3f or %.0f dB"%(G,10*math.log10(G))
BW=65*wavelength/d
print "half power beam width = %.4f degree"%BW
import math
import scipy
#Variable declaration
#impedance of transmission line
Za=73.
#impedance of antenna
Zo=50.
#radiation efficiency
ecd=1.
#Calculations&Results
from scipy import integrate
x = lambda x:math.sin(x)**4
I,err=integrate.quad(x,0,math.pi)
Do=(4*math.pi)/(I*2*math.pi)
print "Do=%.4f=%.4f dB"%(Do,10*math.log10(Do))
#voltage reflection coefficient
F=(Za-Zo)/(Za+Zo)
print "voltage reflection coefficient =%f"%F
#mismatch efficiency of antenna
er=1-F**2
print "mismatch efficiency of antenna =%.4f=%.4f dB"%(er,10*math.log10(er))
#overall gain
Go=10*math.log10(Do)+10*math.log10(er)+10*math.log10(ecd)
print "overall gain = %.4f dB"%Go
import math
import numpy
#Variable declaration
print "unit vector along the polarization of incident wave is ui=[1 0 0]"
ui=[1, 0, 0];
print "unit vector along the antenna polarization ua=[1 1 0]*(1/sqrt(2))\n"
q = (1/math.sqrt(2));
#Calculations
ua = [x * q for x in [1,1,0]]
d=[a*b for a,b in zip(ui,ua)]
#Result
print "polarization loss factor |ui*ua|**2=%.2f or = %.2f dB"%(d[0]**2,10*math.log10(d[0]**2))
import math
#Variable declaration
# output of high power amplifier(W)
Pt=500;
#efficiency
e=0.8;
#gain of transmitting antenna(60dB=10**6)
G=10**6;
#Calculations&Results
Pant=e*Pt
print "output power of antenna Pant=%.f W"%Pant
L=Pt/Pant
print "input/output power ratio =%.2f=%.4f dB"%(L,10*math.log10(L))
EIRP=Pt*G/L
print "EIRP =%.4f dBw"%(10*math.log10(Pt)+10*math.log10(G)-10*math.log10(L))
print "EIRP=%.2e W"%EIRP
import math
#Variable declaration
R = 35860000. #m
F = 4.*10**9 #operating frequency,Hz
c = 3.*10**8 #m/s
#Calculations
lamda = c/f #m
spl = ((4*math.pi*R)/lamda)**2
#Result
print "Space loss ratio = %.2e"%spl
#incorrect answer in textbook
import math
#Variable declaration
#transmitting antenna gain (dB)
Gt=37
# ground station antenna gain (dB)
Gr=45.8
#frequency of signal
f=20*10**3
#distance from ground station
R=36941.031
#Calculations&Results
Pt=10*math.log10(2000)
print "power transmitted\n\tPt = %.4f dB\n"%Pt
Pr=Pt+Gt+Gr-20*math.log10(f*R)-32.4418 #Pt,Pr in dBm and Gt,Gr in dB f in MHz and R in km
print "power received at earth station\n\t = %.4f dBm"%Pr
Gt=0 #Gt in dB
Gr=0 #Gr in dB
Pr=Pt+Gt+Gr-20*math.log10(f*R)-32.4418
print "if two antennas are isotropic \n\t = %.4fdB, or %.4emW"%(Pr,10**(Pr/10))
import math
#Variable declaration
# input power to the antenna(W)
Ps=2;
#reflection coefficient of transmitting antenna
Yt=0.1
#reflection coefficient of receiving antenna
Yr=0.2
#distance between two antennas
#consider
A=10**(-5)
R=100*(A)
#maximum directivity of receiving antenna(20 dB = 10**(20/10))
Gr=10**(20./10)
#maximum directivity of transmitting antenna(16dB=10**(16/10))
Gt=10**(16./10)
#Calculations&Results
# power transmitted in the forward direction
Pt = (1-Yt**2)*Ps
print "power transmitted in the forward direction\n\t = %.2f W"%Pt
#Friis transmission equation
Pr=Pt*(A/(4*math.pi*R))**2*Gr*Gt
print "Friis equation \n\t = %fW or %.f mW"%(Pr,Pr*1000)
#power delivered to receiver
Pd=(1-Yr**2)*Pr
print "power delivered to receiver\n\t = %.1f mW"%(Pd*1000)
import math
#Variable declaration
#power transmission(W)
Pt=25000
#operating frequency(Hz)
f=12*10**9
#gain of transmitter antenna(25dB)
Gt=10**(25./10)
#gain of receiver antenna(25dB)
Gr=10**(25./10)
#distance between two radars(m)
R=10000
#surface area of target radar(m**2)
A=8
c=3.*10**8
#Calculations&Results
#wavelength L
L=c/f
print "wavelength of signal = %.3f m"%L
Pr=Gr*Gt*Pt*A*L**2/(4*math.pi*(4*math.pi*R**2)**2)
print "received power = %.2eW or %.2f pW"%(Pr,Pr*10**12)
import math
#Variable declaration
#noise power at Th=290 K(dBm)
P1=-70.
Th=290.
#noise power at Tc=77 K(dBm)
P2=-75.
Tc=77.
#given noise temperature(K)
Ts=450
#frequency band B
B=1.5*10**9-500*10**6
#power gain of amplifier(10dB=10)
G=10
#boltzamn constant
k=1.38*10**(-23)
#Calculations&Results
#Y-factor(Y=P1/P2 = (P1-P2)dBm)
Y=10**((P1-P2)/10)
print " Y-factor = %.4f"%Y
#equivalent noise temperature
Te=(Th-Y*Tc)/(Y-1)
print "equivalent noise temperature = %.2f K"%Te
#noise power output of amplifier
Po=G*k*Ts*B+G*k*Te*B
print "noise power output = %.4e W or %.4f dBm"%(Po,10*math.log10(Po*1000))
import math
#Variable declaration
#noise figure(dB)
NF=3.5
#band width(Hz)
B=(12-10)*10**9
#amplifier gain
G=10**(20./10)
To=290
k=1.38*10**-23
#Calculations&Results
#noise factor
F=10**(NF/10)
print "noise factor = %.4f"%F
No=F*k*To*B*G
print "output noise power = %.4e W or %.1f dBm"%(No,10*math.log10(No*1000))
import math
#Variable declaration
#ambient temperature(K)
Te=300.
To=290.
#noise temperature of amplifier(K)
Ta=150.
k=1.38*10**-23
#band width(Hz)
B=100.*10**6
#gain of amplifier
Gamp=10**(15./10)
# for transmission lines
Gline=1./10**0.2
#Calculations&Results
#noise factor for amplifier
Famp=1+Ta/To
print "Famp=1+Ta/To"
#noise for transmission lines
Fline=1+(1./Gline-1)*Te/To
print "Fline=1+(1/Gline-1)*Te/To"
Fcascaded=Fline+(Famp-1)/Gline
print "(a)noise figure of cascaded system\n\t = %.4f or %.4f dB"%(Fcascaded,10*math.log10(Fcascaded))
Fcascaded=Famp+(Fline-1)/Gamp
print "(b)if the amplifier is connected before the line\n\t = %.4f or %.4f dB"%(Fcascaded,10*math.log10(Fcascaded))
import math
#Variable declaration
#noise factor of A1
F1=10**(3./10)
#noise factor of A2
F2=10**(5./10)
#gain of amplifier A1
G1=10**(20./10)
#gain of amplifier A2
G2=10**(20./10)
#Calculations&Results
#overall gain of cascaded system
G=G1*G2
print "overall gain of cascaded system = %.2f or %.f dB"%(G,10*math.log10(G))
#overall noise figure of cascaded system
F=F1+(F2-1)/G1
print "overall noise of cascaded system = %.6f or %.3f dB"%(F,10*math.log10(F)) #some difference in result is due to approx in calculation
F=F2+(F1-1)/G2
print "overall noise of cascaded system when order of amplifiers is changed = %.6f or %.6f dB"%(F,10*math.log10(F))
import math
#Variable declaration
#noise factor
F=10**(10/10)
#Calculations&Results
print "(a)B=1MHz"
B=1
Pimds=-111+F+10*math.log10(B) #F in dB, B in MHz, Pidms in dBm
print "\tPimds = %.1f dBm or %.2e mW"%(Pimds,10**(Pimds/10))
print "(b)B=1GHz"
B=1000
Pimds=-111+F+10*math.log10(B) #F in dB, B in MHz, Pidms in dBm
print "\tPimds = %.1f dBm or %.2e mW"%(Pimds,10**(Pimds/10))
print "(c)B=10GHz"
B=10000
Pimds=-111+F+10*math.log10(B) #F in dB, B in MHz, Pidms in dBm
print "\tPimds = %.1f dBm or %.2e mW"%(Pimds,10**(Pimds/10))
print "(d)B=1kHz"
B=0.001
Pimds=-111+F+10*math.log10(B) #F in dB, B in MHz, Pidms in dBm
print "\tPimds = %.1f dBm or %.2e mW"%(Pimds,10**(Pimds/10))
#Variable declaration
#input signal(dBm)
Pin=-15
#intercept point of characteristic curve(dBm)
Pip=25
#Calculations
Pimr=(Pin-Pip)*2 #Pimr in dB; Pin,Pip in dBm
#Result
print "intermodulation ratio = %.1f dB"%Pimr
import math
#Variable declaration
To=290
#bandwidth(Hz)
B=500*10**3
k=1.38*10**-23
#noise factor
F=10**(8./10)
#input power at IP
Pip=10
#Calculations&Results
Nf=k*To*B*F
print "Nf = %.4e or %.2f dBm"%(Nf,10*math.log10(Nf*1000))
Nf=10*math.log10(Nf*1000) #Nf in dBm
DR=2./3*(Pip-Nf) #DR in dB; Pip,Nf in dBm
print "dynamic range = %.2f dB"%DR