In [1]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [10]:
hp = 1.94
lam = 3e8/20e9
d = 1e3
h = sqrt(lam*d/4)
print h
1.9364916731
In [22]:
hp = h + 1
print hp
F = abs(1 - exp(-1j*4*pi*hp**2/(lam*d)))
print 20*log10(F/2)
2.9364916731
-6.87347995085
In [23]:
hp = h+1
print hp
h2p = lam*d/(4*hp)
print h2p
2.9364916731
1.27703409969
In [67]:
lam = 0.25
z = 32
h = 4
x = 0
nu = sqrt(2/(lam*z)) * (h-x)
print nu
print 20*log10(1.2/10.8)
2.0
-19.0848501888
In [71]:
h = 4.
z = 32.
lam = 0.25
r = sqrt(h**2 + z**2)
G = sqrt(lam/r)*1/(2*pi*h/z)
print G
print 20*log10(G)
print abs(sqrt(lam/1j) * 1/(2*pi*h/z))
0.112104175307
-19.0075642371
0.636619772368

Problem 3

In [76]:
y = linspace(-2,2,1000)
g = y/sqrt(1-y**2)
g[abs(y) >= 1] = 0.0
plot(y,g,'k')
xlabel('y')
ylabel('g(y)')
grid()
/usr/local/lib/python2.7/dist-packages/ipython-3.0.0_b1-py2.7.egg/IPython/kernel/__main__.py:2: RuntimeWarning: invalid value encountered in sqrt
  from IPython.kernel.zmq import kernelapp as app

Problem 4

In [33]:
data = load('/home/bhardin2/ece458/2015.01.08.14.02.24.MST_10min.npz.npz')
print data.keys()
['timezone_hr', 'heights', 'epochtime', 'MSTdata']
In [35]:
E = data['MSTdata']
t = data['epochtime']
h = data['heights']
print shape(E)
(4800, 1287)
In [36]:
P = zeros(len(h))
for j in range(len(h)):
    Ej = E[:,j]
    P[j] = mean(abs(Ej)**2)
logP = log10(P)
figure(figsize=(2,6))
plot(logP,h,'k-')
xlabel('log10(power)')
ylabel('height [km]')
Out[36]:
<matplotlib.text.Text at 0x7f21ad87e6d0>

Secondary peak is around 150 km. Calculated below:

In [38]:
P2 = P.copy()
P2[h < 120] = 0.0
jmax = argmax(P2)
print 'Secondary peak at %.2f km' % h[jmax]
Secondary peak at 146.25 km
In [42]:
Ej = E[:,jmax]

n = 64
M = int(len(Ej)/n)

F2 = zeros(n)
for j in range(M):
    Estub = Ej[n*j:n*(j+1)]
    F = fft.fft(Estub)/n
    F2 += abs(F)**2
F2 = F2/M
F2s = fft.fftshift(F2)
x = arange(n)
xs = fftshift(x)
xs[xs>=n/2] = xs[xs>=n/2] - n
plot(xs,F2s,'k')
xlabel('FFT bin')
ylabel('Power')
Out[42]:
<matplotlib.text.Text at 0x7f21ad6cd190>
In [55]:
imax = argmax(F2s)
fftbin = xs[imax]
print 'FFT bin at maximum is %i' % fftbin
T = t[1]-t[0]
df = 1/(T*n)
ds = fftbin*df
print 'Doppler shift is %.3f Hz' % ds
v = ds*lam/2
print 'Doppler velocity is %.3f m/s' % v
FFT bin at maximum is -8
Doppler shift is -0.926 Hz
Doppler velocity is -0.116 m/s

Maximum peak is around 100 km

In [56]:
P2 = P.copy()
P2[h < 50] = 0.0
jmax = argmax(P2)
print 'Primary peak at %.2f km' % h[jmax]
Primary peak at 100.95 km
In [66]:
Ej = E[:,jmax]

n = 64
M = int(len(Ej)/n)

F2 = zeros(n)
for j in range(M):
    Estub = Ej[n*j:n*(j+1)]
    F = fft.fft(Estub)/n
    F2 += abs(F)**2
F2 = F2/M
F2s = fft.fftshift(F2)
x = arange(n)
xs = fftshift(x)
xs[xs>=n/2] = xs[xs>=n/2] - n
plot(xs,F2s,'k')
xlabel('FFT bin')
ylabel('Power')
Out[66]:
<matplotlib.text.Text at 0x7f21acfbfa90>
In [64]:
idx = logical_and(h > 90, h < 110)
figure(figsize=(2,3))
plot(P[idx],h[idx],'k-')
xlabel('Power')
ylabel('height [km]')
Out[64]:
<matplotlib.text.Text at 0x7f21ad0f5390>

This spectrum is much more wide-band than the spectrum at 150 km. This is likely because the physics of the two scattering processes are much different. The 150 km echoes are apparently caused by a coherent source with a rather constant velocity. However, the 100 km echoes are much more diffuse and have a large range of Doppler velocities, many of which are apparently aliased.

In [ ]:
import subprocess
import shutil
nb_name = 'ECE458_Exam1.ipynb' # There's probably a way to get this programmatically
cmd = ['ipython', 'nbconvert', '--to', 'slides', nb_name, \
       '--reveal-prefix', '"http://cdn.jsdelivr.net/reveal.js/2.6.2"',]
#      '--template','output_toggle']
# The --template command points to a custom template which opens and closes the input code cells with a click
subprocess.call(cmd)
html_name = '%s.slides.html' % (nb_name.split('.')[0])
shutil.copy(html_name, '/home/bhardin2/public_html/slideshows/')
In [ ]: