OK, I’ve been doing some more work on this and checked my calculations (and BTW found an error in my code NOT related to the dB conversion), so I’ll summarise it here if I can.
The manual contains this code to convert Pa to dB:
# plot the three curves
ax1.plot(st[0].times(reftime=start), st[0].data, lw=1)
ax2.plot(st[0].times(reftime=start), (st[0].data/56000), lw=1)
ax3.plot(st[0].times(reftime=start), 93.979400087*abs(st[0].data/56000), lw=1)
This converts the counts to Pa by dividing by 56000 (in my code the instrument response takes care of this) so st[0].data/56000 = Pascals.
Decibels are calculated using the formula dB = 93.979400087*abs(Pa).
where Pa is the pressure in Pascals.
The correct formula for the Sound Pressure Level in dB = 10log(PaPa/(PrefPref)) or 10log(PaPa) + 93.9794.00087!
The 93.979400087 = -10*log(Pref * Pref) where Pref = 2e-5 Pa.
So the corrected code for the conversion of Pa to dB is:
10*math.log10(pmax*pmax) + 93.979400087
where pmax is the maximum pressure, but this can be any pressure as long as it is in Pascals.
I did find an error in my code (I used math.log() instead of math.log10() ) but this resulted in a small numeric error so it went unnoticed till now.
I’ll replace the wrong code in the Boom Event Report Thread.
I’d love to see a solution for how to apply the math.log10() function to a trace to produce a true plot of dB.
Al.