私が行ったことは、このスニペットに 2 つの小さな関数 (ラムダ関数) を作成して、参考文献の式 [8] に従ってピタゴラス距離と SPL を計算することです。
なお、指向性係数は実験的に決まるものなので、ここでは単純に余弦を代表例として挙げました。Q 関数を、角度シータと距離 r を指定すると、実験結果の補間により強度スコアを返す関数に置き換えることができます。
import matplotlib.pyplot as plt
from pylab import linspace, meshgrid, sqrt, log10, angle, cos
x = linspace(-30.0, 30.0, 15)
y = linspace(0, 30, 15)
X, Y = meshgrid(x, y)
#Z = sqrt(X**2 + Y**2)
def SPL(source_SPL, x, y, x1, y1, Q):
'''Given a source sound pressure level, the x and y vectors describing
the space, the x1 and y1 coordinates of the sound origin
and a directivity factor function, return the SPL matrix'''
#Using eqation 8 from the source
dist = lambda x1, x2, y1, y2: sqrt((x1-x2)**2 + (y1-y2)**2)
spl = lambda r, q: source_SPL - 20*log10(r) - 10*log10(q) - 11
spl_matrix = []
for y2 in y:
# Create a new row
spl_matrix.append([])
for x2 in x:
r = dist(x1, x2, y1, y2)
theta = angle(complex(x2-x1, y2-y1))
q = Q(theta, r)/float(source_SPL)
# After calculating r and q, put them into the spl equation to get Db
Db = spl(r, q)
spl_matrix[-1].append(Db)
return spl_matrix
Q = lambda theta, r: r*abs(cos(theta))
Z = SPL(1, x, y, 0.1, 0.1, Q)
plt.figure()
#Need to draw the contour twice, once for the lines (in 10 sections)
CS = plt.contour(Y, X, Z, 10, linewidths=0.5, colors='k')
#And again for the fills
CS = plt.contourf(Y, X, Z, 10)
plt.show()

配列を使用せずにこれを解決しましたが、ループではなく行列演算を使用するように、numpy とこのコードをベクトル化する方法を調べる必要があります。ただし、これは数学の問題ほどコードの問題ではありません。
最後に、エンジニアリングのバックグラウンドがある場合は、Q 関数が環境条件に基づいて相対強度を計算するコンピューターでこの実験を実行できます。音が周囲とどのように相互作用するかをさらに理解する必要があります。有限要素分析と音圧レベルをグーグルで検索することをお勧めします