from math import sin, pi
#Variable declaration
gal_ext = 400000 #Extent of galaxy (light-years)
alpha = 0.032 #Extent of galaxy (degrees)
f = 5e9 #Frequency (Hz)
a = 36e3 #Maximum VLA Spacing (m)
c = 3e8 #Speed of light (m/s)
wid = 0.03 #Width of image (degrees)
hei = 0.008 #Height of image (degrees)
flux_den = 2.5e-23 #Average flux density (W/m^2)
bw = 1e9 #Bandwidth (Hz)
#Calculations
dist = gal_ext/sin(alpha*pi/180) #Distance to the galaxy (light-years)
dist_m = dist*(365*24*3600*c)
wave_lt = c/f #Wavelength (m)
a_lambda = a/wave_lt #Spacing in wavelength (unitless)
pix_size = 51/a_lambda #Resolution or Pixel size (degrees)
pix_size_arc = pix_size*3600 #Pixel size (arc seconds)
area = wid*hei #Area of image (square degrees)
area_arc = area*(3600**2) #Area of image (arc seconds)
num_pix = area_arc/pix_size_arc**2 #Number of pixels
rad_pow = flux_den*4*pi*(dist_m**2)*bw
#Result
print "The distance to the galaxy is", round(dist,-8), "light years"
print "The resolution or pixel size is", round(pix_size_arc,2), "arc seconds"
print "The number of pixels is", round(num_pix)
print "The radio power of the galaxy is %.1e W" % rad_pow
from math import pi, log10
#Variable declaration
f = 10e9 #Frequency (Hz)
c = 3e8 #Speed of light (m/s)
dia = 100 #Dish diameter (m)
aper_eff = 0.725 #Aperture efficiency (unitless)
#Calculation
wave_lt = c/f #Wavelength (m)
hpbw = 66/(dia/wave_lt) #Half power beam width (degrees)
gain = 41000/(hpbw**2) #Gain from beamwidth (unitless)
gain_db = 10*log10(gain) #Gain from beamwidth (dBi)
gain_ap = 4*(pi**2)*(dia/2)**2*(aper_eff)/(wave_lt**2)
#Gain from effective aperture(unitless)
gain_ap_db = 10*log10(gain_ap) #Gain from effective aperture (dBi)
side_lobe = -23 #First side lobe level from table (dB)
#Result
print "The Half Power Beamwidth is", round(hpbw,3), "degrees"
print "The gain from beamwidth is", round(gain_db), "dBi"
print "The gain from effective aperture is", round(gain_ap_db), "dBi"
print "The first side-lobe level is", side_lobe,"dB"