# -*- coding: utf-8 -*-
"""
Created on Sat Dec 09 13:11:31 2017

@author: Monstein
"""
# See: http://docs.astropy.org/en/stable/units/index.html#module-astropy.units
from astropy import units as u

print ('\nSolution based on units from astropy:\n')
# Given:
S1 = 1.0 * u.Jy        # 1 Jansky source flux density
T1 = 1.0 * u.min       # observation time
Ae = 3927.0 * u.m**2   # effective ara of a 100 m parabolic dish 
bw = 500.0e6 * u.Hz    # band width expressed in Hz

S2 = 40.0 * u.Jy       # 40 Jansky source flux density
T2 = 40 * u.yr         # one year
g  = 9.80665 * u.m / u.s**2 # gravitational acceleration on earth
m  = 10 * u.g          # mass of a pencil expressd in g

# Solutions:
Pfd = S1 * bw
print ('(1) Power flux density = {:.1e}'.format(Pfd.to(u.W/u.m**2)))

P = Pfd * Ae
print ('\n(2) Power received = {:.1e}'.format(P.to(u.W)))

W1 = P*T1
print ('\n(3) Energy received in 1 minute= {:.1e}'.format(W1.to(u.J)))

W2 = S2*bw*Ae*T2
print ('\n(4) Energy received in 40 years= {:.1e}'.format(W2.to(u.J)))

h = W2/(m*g)
print ('\n(5) Lifting height of a 10g pencil= {:.1f}'.format(h.to(u.cm)))
