acoustic_fp/brg_freq_mesh.py
2025-03-23 20:06:45 -04:00

42 lines
988 B
Python

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button
soundscape = np.empty((1000,1))
for i in range(1000):
soundscape[(i,0)] = -.003*i-60
brgs = np.ones((1,360))
brg_freq = np.matmul(soundscape, brgs)
targ_brg = [60]
brg_width = [5]
tonals = [20,40,100,500, 800] #build our threat object here
tonal_widths = [2,2,2,2,2] #how diffuse is each tonal
decr = [.8,.8,.8,.90,.90] #sound decrement from ambient
for azim,spread in zip(targ_brg,brg_width):
brg = azim - spread//2
while brg <= azim + spread//2:
for tone,wide,loud in zip(tonals, tonal_widths, decr):#right now the source is based on bkgd
freq = tone - wide//2 #strength, but we will need to just
while freq < tone + wide//2: #assign values
brg_freq[(freq,brg)] = -50 #
freq += 1
brg += 1
axtime = plt.axes()
time = Slider(axtime, "Time", 0, 60)
def update(brg):
t = time.val
time.on_changed(update)
plt.imshow(brg_freq)
plt.colorbar()
plt.show()