How to calculate average from multiple SPL mics?
Erik Kostson
Member, Employee Posts: 202
✭✭✭✭
Say we have a harmonic acoustic analysis. How can we then add automatically a linear array of far field microphones and evaluate the average result (SPL) from them?
0
Best Answers

below is a mechanical script that does that:
nrmic=3 # number of mics to place totspl=0 # total spl avspl=0 # average spl stepx=2 # distance between mic. locations in meters model = ExtAPI.DataModel.Project.Model analysis=model.Analyses[0] for i in range(1,nrmic+1): myacfar=analysis.Solution.AddAcousticFarFieldSPLMic() myacfar.XCoordinate = Quantity(stepx*i, "m") # mics. placed along X every stepx  in meters change if mm myacfar.EvaluateAllResults() myspl=str(myacfar.Maximum) # get maximim spl myspl=myspl.Split("[")[0] # get the number not the dB totspl=totspl+float(myspl) # add to total avspl=totspl/nrmic # get average print('Average is: ' + str(avspl))
0 
for multiple frequencies the below should give the average (from mics.):
import csv nrmic=2 # number of mics to place stepx=5 # distance between mic. locations in meters model = ExtAPI.DataModel.Project.Model analysis=model.Analyses[0] time_steps = len(analysis.GetResultsData().ListTimeFreq) size=time_steps/2 avsplar=[0]*size# average spl array for i in range(1,nrmic+1): myacfar=analysis.Solution.AddAcousticFarFieldSPLMic() myacfar.XCoordinate = Quantity(stepx*i, "m") # mics. placed along X every stepx  in meters change if mm myacfar.EvaluateAllResults() myacfar.Activate() myfile='D:\mysplmic'+str(i)+'.txt' myacfar.ExportToTextFile(myfile) r=0 with open(myfile, 'rb') as f: data = csv.reader(f,delimiter='\t') next(data) for row in data: avsplar[r]=avsplar[r]+(float(row[1]))/(float(nrmic)) r=r+1 print(avsplar)
0
This discussion has been closed.