acoular / acoular

Acoular - Acoustic testing and source mapping software
https://www.acoular.org
BSD 3-Clause "New" or "Revised" License
421 stars 120 forks source link

Point source with OpenJet or SlotJet #80

Open cyrillebreard opened 6 months ago

cyrillebreard commented 6 months ago

I am using the point source with OpenJet/SlotJet flow environment , and I and getting Nan results for the beamforming. Here is the code with an array

from os import path import acoular from acoular import L_p, MicGeom, PowerSpectra, Environment,\ RectGrid, BeamformerBase, BeamformerEig, PointSource, \ SteeringVector, SlotJet,GeneralFlowEnvironment,WNoiseGenerator

from pylab import figure, plot, subplot, imshow, show, colorbar, title, tight_layout, Axes import matplotlib.pyplot as plt micgeofile = path.join(path.split(acoular.file)[0],'xml','array_64.xml') m = acoular.MicGeom( from_file=micgeofile ) g = acoular.RectGrid( x_min=-0.2, x_max=0.2, y_min=-0.2, y_max=0.2, z=1, increment=0.02 ) sos=343 openjet=SlotJet(v0 = 50., origin = [-2,0,0.5] , B = 4) envUJet= GeneralFlowEnvironment(ff=openjet, N=400, c=sos)

point source

duration = 2 fs = 51200 sloc1=(0,0,7) nsamples = int(duration*fs)

White noise generator

n1 = WNoiseGenerator(sample_freq=fs, numsamples=nsamples, seed=1) p01 = PointSource(signal=n1, mics=m, env = envUJet, loc=sloc1) pUJet1 = PointSource(signal=n1, mics=m, env = envUJet, loc=sloc1) nblock = 1024 flow = 1000. fhig = 9000. ilow = int(flow/fsnblock) ihig = int(fhig/fsnblock) PSUJet = PowerSpectra(time_data=pUJet1, window='Hanning', overlap='50%', block_size=nblock, ind_low=ilow, ind_high=ihig) stUJet = SteeringVector(grid=g, mics=m, env=envUJet, steer_type = 'true level',ref=16 ) bbUJet = BeamformerBase(freq_data=PSUJet, steer=stUJet, r_diag=True) norderfreq=0 cfreq = 3150 pm = bbUJet.synthetic(cfreq,norderfreq) mx = L_p(pm.max()) print("Lm.max: {0:.4}".format(mx))


Output is :

[('PointSource_3c6f5b5d78e6ab92e63df649841ecd52_cache.h5', 4)] Lm.max: nan

it works for Uniform flow

esarradj commented 6 months ago

I suspect it is the huge ref=16 you use. Could you please try to go with the default ref=(0,0,0)? Somehow your code seems to be not properly formatted, so I can't run it myself.

Generally it make not much sense to use a fixed reference value unless you have a very good reason of doing so, because this will change the beamformer response and may come at the cost of lower spatial resolution.

cyrillebreard commented 6 months ago

I tried again with ref=(0,0,0) and clean up the code (sorry for the messy coding), I am still getting nan...


from os import path import acoular from acoular import L_p, MicGeom, PowerSpectra, Environment,UniformFlowEnvironment,\ RectGrid, BeamformerBase, BeamformerCleansc, PointSource, \ SteeringVector, SlotJet,GeneralFlowEnvironment,WNoiseGenerator

from pylab import figure, plot, subplot, imshow, show, colorbar, title, tight_layout, Axes import matplotlib.pyplot as plt micgeofile = path.join(path.split(acoular.file)[0],'xml','array_64.xml') m = acoular.MicGeom( from_file=micgeofile )

Grid

g = acoular.RectGrid( x_min=-0.2, x_max=0.2, y_min=-0.2, y_max=0.2, z=1,increment=0.02 )

Flow

sos=343 openjet=SlotJet(v0 = 50., origin = [-2,0,1] , B = 0.2) envUJet= GeneralFlowEnvironment(ff=openjet, N=400, c=sos) # duration = 2 fs = 51200 sloc=(0,0,1) nsamples = int(duration*fs)

White noise generator

n1 = WNoiseGenerator(sample_freq=fs, numsamples=nsamples, seed=1)

point source

pUJet1 = PointSource(signal=n1, mics=m, env = envUJet,loc=sloc) nblock = 1024 flow = 1000. fhig = 9000. ilow = int(flow/fsnblock) ihig = int(fhig/fsnblock) PSUJet = PowerSpectra(time_data=pUJet1, window='Hanning', overlap='50%', block_size=nblock, ind_low=ilow, ind_high=ihig) # stUJet = SteeringVector(grid=g, mics=m, env=envUJet, steer_type = 'true level',ref=(0,0,0) ) # bbUJet = BeamformerBase(freq_data=PSUJet, steer=stUJet, r_diag=True) norderfreq=0 cfreq = 3150 pm = bbUJet.synthetic(cfreq,norderfreq) mx = L_p(pm.max()) print("Lm.max: {0:.4}".format(mx))