Exemple #1
0
def madd(A,B,C):
    assert 'pyJvsip' in repr(A) and '__View' in repr(A),'Input parameters must be views of type pyJvsip.__View.'
    assert type(A) == type(B) and type(A) == type(C),'Input paramteters must be the same type'
    assert 'mview' in A.type,'Only matrix views are supported for madd.'
    L = A.rowlength
    a = A.colview
    b = B.colview
    c = C.colview
    for i in range(L):
        pjv.add(a(i),b(i),c(i))
    return C
Exemple #2
0
def noiseGen(t,alpha,Mp,Nn,Ns):
    """
    Usage:
        data = noiseGen(t,alpha,Mp,Nn,Ns)
    where:
        data is a matrix of type t and size Mp by Ns)
        alpha is a linear array constant
        Mp is the number of sensors in the linear array
        Nn is the size of the simulated noise vector
        Ns is the size of the output noise field for each sensor
    Note the noise field is returned in data
    """
    # program parameters
    from math import pi as M_PI
    kaiser=9
    Nfilter=10   # Kernel length for noise filter
    Nnoise=64    # number of Simulated Noise Directions
    cnst1 = M_PI/Nnoise
    offset0 = int(alpha * Mp + 1)
    nv = pv.create('vview_d',2 * Nn)
    noise=pv.create('mview_d',Mp,Nn)
    kernel = pv.create('vview_d',Nfilter).kaiser(kaiser)
    fir = pv.FIR('fir_d',kernel,'NONE',2 * Nn,2,'YES')
    data = pv.create('mview_d',Mp,Ns).fill(0.0)
    state = pv.Rand('PRNG',15)
    for j in range(Nnoise):
        noise_j=noise.rowview(j)
        state.randn(nv)
        fir.flt(nv,noise_j)
        noise_j *= 12.0/float(Nnoise)
    #view_store(noise,'noiseData');
    noise.putrowlength(Ns)
    for i in range(Mp):
        data_v = data.rowview(i)
        for j in range(Nnoise):
            noise_j=noise.rowview(j)
            noise_j.putoffset(offset0 +(int)( i * alpha * cos(j * cnst1)))
            pv.add(noise_j,data_v,data_v)
    #view_store(data,'Data');
    return data
Exemple #3
0
def noiseGen(t, alpha, Mp, Nn, Ns):
    """
    Usage:
        data = noiseGen(t,alpha,Mp,Nn,Ns)
    where:
        data is a matrix of type t and size Mp by Ns)
        alpha is a linear array constant
        Mp is the number of sensors in the linear array
        Nn is the size of the simulated noise vector
        Ns is the size of the output noise field for each sensor
    Note the noise field is returned in data
    """
    # program parameters
    from math import pi as M_PI
    kaiser = 9
    Nfilter = 10  # Kernel length for noise filter
    Nnoise = 64  # number of Simulated Noise Directions
    cnst1 = M_PI / Nnoise
    offset0 = int(alpha * Mp + 1)
    nv = pv.create('vview_d', 2 * Nn)
    noise = pv.create('mview_d', Mp, Nn)
    kernel = pv.create('vview_d', Nfilter).kaiser(kaiser)
    fir = pv.FIR('fir_d', kernel, 'NONE', 2 * Nn, 2, 'YES')
    data = pv.create('mview_d', Mp, Ns).fill(0.0)
    state = pv.Rand('PRNG', 15)
    for j in range(Nnoise):
        noise_j = noise.rowview(j)
        state.randn(nv)
        fir.flt(nv, noise_j)
        noise_j *= 12.0 / float(Nnoise)
    #view_store(noise,'noiseData');
    noise.putrowlength(Ns)
    for i in range(Mp):
        data_v = data.rowview(i)
        for j in range(Nnoise):
            noise_j = noise.rowview(j)
            noise_j.putoffset(offset0 + (int)(i * alpha * cos(j * cnst1)))
            pv.add(noise_j, data_v, data_v)
    #view_store(data,'Data');
    return data
Exemple #4
0
dataOut  = pv.create('vview_f',N)
spect_avg = pv.create('vview_f',int(N/2) + 1)
spect_new = pv.create('vview_f',int(N/2) + 1)
state = pv.Rand('NPRNG',N)
fft=pv.FFT('rcfftop_f',(N,1,0,0))
b = [0.0234, -0.0094, -0.0180, -0.0129,  0.0037, 
    0.0110, -0.0026, -0.0195, -0.0136,  0.0122,
    0.0232, -0.0007, -0.0314, -0.0223,  0.0250,
    0.0483, -0.0002, -0.0746, -0.0619,  0.0930,
    0.3023,  0.3999,  0.3023,  0.0930, -0.0619,
    -0.0746, -0.0002,  0.0483,  0.0250, -0.0223,
    -0.0314, -0.0007,  0.0232,  0.0122, -0.0136,
    -0.0195, -0.0026,  0.0110,  0.0037, -0.0129,
    -0.0180 ,-0.0094,  0.0234]
fir = pv.FIR('fir_f',pv.listToJv('vview_f',b),'NONE',D*N,D,'NO')
spect_avg.fill(0.0)
for i in range(avg):
    state.randu(dataIn)
    pv.add(-.5,dataIn,dataIn)
    fir.flt(dataIn,dataOut)
    fft.dft(dataOut,dataFFT)
    pv.cmagsq(dataFFT,spect_new)
    pv.add(spect_new,spect_avg,spect_avg)
pv.mul(1.0/avg,spect_avg,spect_avg);
#print("spect_avg =");spect_avg.mprint('%.4f')
x=spect_avg.empty.ramp(0,1.0/(spect_avg.length-1))
pyplot.plot(x.list,spect_avg.list)
pyplot.title('Decimation 2')
pyplot.ylabel('Not Normalized')
pyplot.show()
Exemple #5
0
import pyJvsip as pv
N=6
A = pv.create('cvview_d',N).randn(7)
B = A.empty.fill(5.0)
C = A.empty.fill(0.0)
print('A = '+A.mstring('%+.2f'))
print('B = '+B.mstring('%+.2f'))
pv.add(A,B,C)
print('C = A+B') 
print('C = '+C.mstring('%+.2f'))
""" OUTPUT
A = [+0.16+0.50i -0.21-0.75i -0.56-0.09i \
     +1.15+0.45i +0.10+0.43i +0.63-1.05i]

B = [+5.00+0.00i +5.00+0.00i +5.00+0.00i \
     +5.00+0.00i +5.00+0.00i +5.00+0.00i]

C = A+B
C = [+5.16+0.50i +4.79-0.75i +4.44-0.09i \
     +6.15+0.45i +5.10+0.43i +5.63-1.05i]
"""
Exemple #6
0
#* Created RJudd */
#* pyJvsip version of c_VSIP_example example1

import pyJvsip as pv
N = 8
A = pv.create('vview_f', N).ramp(0, 1)
B = A.empty.fill(5.0)
C = A.empty.fill(0.0)
print('A = ')
A.mprint('%2.0f')
print('B = ')
B.mprint('%2.0f')
pv.add(A, B, C)
print('C = A+B')
print('C = ')
C.mprint('%2.0f')