4

Pythonでラインアレイの音圧レベルを見つける方法を知りたいですか? 基本的には、スピーカーのラインアレイソースからの距離に基づいて SPL を示す等高線を描きたいと考えています。サンプルの輪郭は次のとおりです。

ここに画像の説明を入力

私が得た最も近いものは、このスニペットからのものでした:

import matplotlib.pyplot as plt
from pylab import linspace, meshgrid, sqrt, log

x = linspace(-30.0, 30.0, 15)
y = linspace(0, 30, 15)
X, Y = meshgrid(x, y)
Z = sqrt(X**2 + Y**2)

plt.figure()
CS = plt.contourf(Y, X, Z)
plt.show()

必要な輪郭が洗練されたソフトウェアと方程式によって生成されることはわかっていますが、それに近いものでも問題ありません。

このリンクは役立つかもしれませんが、この情報からの方程式でその輪郭を取得する方法がわかりません。 http://personal.cityu.edu.hk/~bsapplec/transmis1.htm

前もってありがとう、dksr

4

1 に答える 1

3

私が行ったことは、このスニペットに 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 関数が環境条件に基づいて相対強度を計算するコンピューターでこの実験を実行できます。音が周囲とどのように相互作用するかをさらに理解する必要があります。有限要素分析と音圧レベルをグーグルで検索することをお勧めします

于 2012-06-30T01:46:26.553 に答える