acoular / acoular

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

Some solvers ind CMF can yield negative source strength results #204

Open adku1173 opened 7 months ago

adku1173 commented 7 months ago

including:

Reproduce with:

import acoular
from acoular import L_p, Calib, MicGeom, Environment, PowerSpectra, \
RectGrid, MaskedTimeSamples,BeamformerCMF, SteeringVector

# other imports
from os import path
from pylab import figure, imshow, colorbar, title

# files
datafile = 'example_data.h5'
calibfile = 'example_calib.xml'
micgeofile = path.join( path.split(acoular.__file__)[0],'xml','array_56.xml')

#octave band of interest
cfreq = 4000

t1 = MaskedTimeSamples(name=datafile)
t1.start = 0 # first sample, default
t1.stop = 16000 # last valid sample = 15999
invalid = [1,7] # list of invalid channels (unwanted microphones etc.)
t1.invalid_channels = invalid 

t1.calib = Calib(from_file=calibfile)

m = MicGeom(from_file=micgeofile)
m.invalid_channels = invalid

g = RectGrid(x_min=-0.6, x_max=-0.0, y_min=-0.3, y_max=0.3, z=0.68,
             increment=0.05)
env = Environment(c = 346.04)
st = SteeringVector(grid=g, mics=m, env=env)
f = PowerSpectra(time_data=t1, 
               window='Hanning', overlap='50%', block_size=128, #FFT-parameters
               ind_low=8, ind_high=16) #to save computational effort, only
               # frequencies with indices 8..15 are used
bcmf = BeamformerCMF(freq_data=f, steer=st, method='LassoLars')

figure(1,(10,6))
smap = bcmf.synthetic(cfreq,1)
print(smap.min())
esarradj commented 1 week ago

For sklearn solvers there is a new positive parameter which can be set to enforce strictly non-negative results.