예제 #1
0
"""

from os import path
from numpy import array,arange
import acoular
from pylab import figure, plot, imshow, colorbar, show,xlim, ylim,legend,cm
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon,Rectangle

#fft block size
block = 128

#example data 
micgeofile = path.join( path.split(acoular.__file__)[0],'xml','array_56.xml')
mg = acoular.MicGeom( from_file=micgeofile )
ts = acoular.TimeSamples( name='example_data.h5' )
ps = acoular.PowerSpectra( time_data=ts, block_size=128, window='Hanning' )
rg = acoular.RectGrid(x_min=-0.6, x_max=-0.0, y_min=-0.3, y_max=0.3, z=0.68,
             increment=0.02)
st = acoular.SteeringVector( grid = rg, mics=mg )
f = acoular.PowerSpectra(time_data=ts,block_size=block)
bf  = acoular.BeamformerBase(freq_data = f,steer= st)


#Integrate function can deal with multiple methods for integration:

#1. a circle containing of three values: x-center, y-center and radius
circle = array([-0.3,-0.1, 0.05])

#2. a rektange containing of 4 values: lower corner(x1, y1) and upper corner(x2, y2).
rect  =  array([-0.5,   -0.15, -0.4 , 0.15])
예제 #2
0
#------------------------------------------------------------------------------
"""

Loads the three sources test data set, analyzes them and generates a
map of the three sources. 

"""

from os import path
import acoular
from pylab import figure, plot, axis, imshow, colorbar, show

micgeofile = path.join(path.split(acoular.__file__)[0], 'xml', 'array_64.xml')
datafile = 'three_sources.h5'

mg = acoular.MicGeom(from_file=micgeofile)
ts = acoular.TimeSamples(name='three_sources.h5')
ps = acoular.PowerSpectra(time_data=ts, block_size=128, window='Hanning')
rg = acoular.RectGrid( x_min=-0.2, x_max=0.2, y_min=-0.2, y_max=0.2, z=0.3, \
increment=0.01 )
bb = acoular.BeamformerBase(freq_data=ps, grid=rg, mpos=mg)
pm = bb.synthetic(8000, 3)
Lm = acoular.L_p(pm)
imshow( Lm.T, origin='lower', vmin=Lm.max()-10, extent=rg.extend(), \
interpolation='bicubic')
colorbar()
figure(2)
plot(mg.mpos[0], mg.mpos[1], 'o')
axis('equal')
show()
예제 #3
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 24 15:59:53 2020

@author: Lucas Muller Gomes 
Acoustic Engineegiring - UFSM

"""
import tables
import numpy


N_channels = # Number of channels
fs = # Sample rate
data = # data to save in the hdf5 - the shape must be (num_samples, number of channels)
data = numpy.array(data)
savename = "DataToAcoular.h5"

acoularh5 = tables.open_file(savename, mode = "w", title = savename)
acoularh5.create_earray('/','time_data', atom=None, title='', filters=None, expectedrows=100000, chunkshape=[256,N_channels], \
                         byteorder=None, createparents=False, obj=data)
acoularh5.set_node_attr('/time_data','sample_freq', fs)
acoularh5.close()

import acoular
# Acoular data

ts=acoular.TimeSamples(name= savename)

예제 #4
0
import matplotlib.pyplot as plt
import acoular as ac
from os import path
import matplotlib.image as mpimg
import numpy as np

sol = "4mic_solalt.h5"
sag = "4mic_sagust.h5"
orta = "4mic_orta.h5"
sol2 = "sol_ust_ses_20_01.h5"
sag2 = "sag_alt_ses_20_01.h5"

micgeofile = path.join(path.split(ac.__file__)[0], 'xml', 'array_4_2.xml')
m = ac.MicGeom(from_file=micgeofile)
g = ac.RectGrid(x_min=-4, x_max=4, y_min=-2, y_max=2, z=0.3, increment=0.01)
t1 = ac.TimeSamples(name=sag2)
cal = ac.Calib(from_file='calibration.xml')
es = ac.EigSpectra(time_data=t1,
                   block_size=512,
                   window="Hanning",
                   overlap='50%',
                   calib=cal)
bb = ac.BeamformerBase(freq_data=es, grid=g, mpos=m, r_diag=False)

Lm = ac.L_p(bb.synthetic(500, 0))
"""
plt.figure()
plt.imshow( Lm.T, origin='lower', vmin=Lm.max()-10, extent=g.extend(), interpolation='bicubic')


"""
예제 #5
0
import numpy as np
import sys


def format_coord(x, y):
    z = x + y
    return 'x=%1.4f, y=%1.4f, z=%1.4f' % (x, y, z)


FolderName = sys.argv[1]
datafile = FolderName + '.h5'
micgeofile = path.join(
    path.split(acoular.__file__)[0], 'xml', 'mic_geometry.xml')

mg = acoular.MicGeom(from_file=micgeofile)
ts = acoular.TimeSamples(name=datafile)
ps = acoular.PowerSpectra(time_data=ts, block_size=128, window='Hanning')

rg = acoular.RectGrid( x_min=-.715, x_max=.715, y_min=-.44, y_max=.6, z=1, \
increment=0.001 )
bb = acoular.BeamformerBase(freq_data=ps, grid=rg, mpos=mg)
#bb = acoular.BeamformerCapon( freq_data=ps, grid=rg, mpos=mg,c=346.04 )
#bb = acoular.BeamformerMusic( freq_data=ps, grid=rg, mpos=mg,c=346.04,n=6 )

pm = bb.synthetic(8000, 3)
Lm = acoular.L_p(pm)

plt.imsave(FolderName,
           Lm.T,
           origin='lower',
           vmin=Lm.max() - 3,