예제 #1
0
def main():
    # initialize input/ouput objects
    ts=time_series()
    kw=k_omega()
    for i in range(averages):
	# initialize time series        
	ts.reset()
	# Simulate narrow band acoustic data        
	ts.nb_sim()
	# Simulate colored gaussian noise
        ts.noise_sim()
	# Perform k-omega beamforming
        kw(ts())
    
    # Obtain the result of beamforming	
    gram=kw.get()    
    
    # rearrange to bring zero-frequency component at the center of spectrum 
    for i in range(gram.size(1)):
        gram[:,i] = freqswap(gram[:,i])
    
    # Post-process the beamformer output to make it suitable for charting
    max, idx = reduce.maxval(gram)
    avg = reduce.meanval(gram)
    gram = clip(gram,0.0,max,avg/100000.0,max)
    # plot log-magnitude of beamformed power spectrum
    gram = elm.log10(gram)
    min, idx = reduce.minval(gram)
    gram -= min
    # Normalize the log-magnitude plot
    max, idx = reduce.maxval(gram)
    gram *= 1.0/max
    fig = pyplot.figure(1,figsize=(10,4))
    ax = fig.add_axes([0.10,0.10,0.85,0.80])
    ax.set_yticklabels(['0','0','30','60','90','120','150','180'])
    ax.yaxis.set_ticks_position('right')
    pyplot.imshow(gram)
    # Labeling plot axis appropriately
    pyplot.title(u'K-Ω Beamformer Output')
    pyplot.xlabel('Frequency')
    pyplot.ylabel(r'$\frac{cos(\theta)}{\lambda}$',fontsize=16,rotation='horizontal')
    pyplot.colorbar()
    # Display the plot
    pyplot.show()
예제 #2
0
#
# Copyright (c) 2014 Stefan Seefeld
# All rights reserved.
#
# This file is part of OpenVSIP. It is made available under the
# license contained in the accompanying LICENSE.BSD file.

import numpy as np
from numpy import array
from vsip import vector, matrix
from vsip.math import reductions as red

a = np.arange(16, dtype=float)
v = vector(array=a)

assert array(red.meanval(v) == np.mean(a)).all()
assert array(red.maxval(v)[0] == np.max(a)).all()
assert array(red.minval(v)[0] == np.min(a)).all()
assert array(red.sumval(v) == np.sum(a)).all()
예제 #3
0
from vsip.math import reductions as red
from vsip.math.solvers import llsqsol
#import matplotlib.pyplot as plt


# Define 'A' to be a two-column matrix containing Y[X] and X
A = matrix(float, 10, 2)
X = gen.ramp(float, 0.1, 0.1, 10)
A[:,0] = elm.exp(-X)
A[:,1] = X

c1,c2= 5.0,2.0
Y = c1*elm.exp(-X) + c2*X

Z = matrix(float, 10, 1)
Z[:,0] = Y + 0.05*red.maxval(Y)[0]*random.rand(float).randn(Y.length())

R = llsqsol(A, Z)
c,resid,rank,sigma = linalg.lstsq(A, Z)

# Compare results of llsqsol with results from linalg.lstsq
assert np.isclose(R, c).all()


#X2 = gen.ramp(float, 0.1, 0.9/100, 100) 
#Y2 = c[0]*elm.exp(-X2) + c[1]*X2
#R2 = elm.exp(-X2)*R[0,0] + X2*R[1,0]

#plt.plot(X, Z, 'x', X2, R2)
#plt.plot(X, Z,'x', X2, Y2)
#plt.axis([0,1.1,3.0,5.5])
예제 #4
0
#
# Copyright (c) 2014 Stefan Seefeld
# All rights reserved.
#
# This file is part of OpenVSIP. It is made available under the
# license contained in the accompanying LICENSE.BSD file.

import numpy as np
from numpy import array
from vsip import vector, matrix
from vsip.math import reductions as red

a = np.arange(16, dtype=float)
v = vector(array=a)


assert array(red.meanval(v) == np.mean(a)).all()
assert array(red.maxval(v)[0] == np.max(a)).all()
assert array(red.minval(v)[0] == np.min(a)).all()
assert array(red.sumval(v) == np.sum(a)).all()