Skip to content

Commit

Permalink
[python] Improve detect_room_modes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 18, 2024
1 parent 181dd98 commit 7534753
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/python/pffdtd/analysis/room_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def detect_room_modes(
window = windows.hann(buf.shape[0])
buf *= window

nfft = (2**iceil(np.log2(buf.shape[0])))*2
nfft = (2**iceil(np.log2(buf.shape[0])))*8
spectrum = np.fft.rfft(buf, nfft)
freqs = np.fft.rfftfreq(nfft, 1/fs)

Expand All @@ -157,7 +157,7 @@ def detect_room_modes(
dB += 75.0

dB_max = np.max(dB)
peaks, _ = find_peaks(dB, width=2)
peaks, _ = find_peaks(dB, width=2, height=50.0)
measured_mode_freqs = freqs[peaks]

print(measured_mode_freqs[:10])
Expand Down
2 changes: 1 addition & 1 deletion src/python/test/test_sim3d_detect_room_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'room,fmax,ppw,fcc,dx_scale,tolerance_pct',
[
((2.8, 2.076, 1.48), 400, 10.5, False, 2, 1.7),
((3.0, 1.0, 2.0), 600, 7.7, True, 3, 3.4),
((3.0, 1.0, 2.0), 600, 7.7, True, 3, 3.8),
]
)
def test_sim3d_detect_room_modes(tmp_path, engine, room, fmax, ppw, fcc, dx_scale, tolerance_pct):
Expand Down

0 comments on commit 7534753

Please sign in to comment.