import matplotlib.pyplot as plt import numpy as np import random import acoustics.decibel as db freq_upper = 1000 #size of the frequency spectrum we want to investigate #freq_div = 10 #freq_bin = freq_upper/freq_div x = np.array(range(freq_upper)) #initialize frequencies (x-axis) bkgd = np.zeros(freq_upper) source = np.zeros(freq_upper) fav_received = np.zeros(freq_upper) fav_source = np.zeros(freq_upper) for i in range(len(bkgd)): bkgd[i] = -.003*x[i]-60 #input model for background here. each freq is assigned an SNR bkgd[i] = 10**(bkgd[i]/20) tonals = [20,40,100,500, 800] #build our threat object here widths = [2,2,2,2,2] #how diffuse is each tonal decr = [.8,.8,.8,.90,.90] #sound decrement from ambient #for i in range(len(source)): # source[i] = random.randint(0,10)/200 for tone,wide,loud in zip(tonals, 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 source[freq] = bkgd[i]*(1-loud) # freq += 1 # received = bkgd + source for i in range(freq_upper): received[i] = 20*np.log10(received[i]) for i in range(freq_upper): source[i] = 20*np.log10(source[i]) for i in range(freq_upper-1): fav_received[i] = abs((received[i]-received[i+1])**3) for i in range(freq_upper): source[i] = db.dbsub(received[i],bkgd[i]/2) for i in range(freq_upper-1): fav_source[i] = abs((source[i]-source[i+1])**3) plt.plot(x, received, label = "Legacy") plt.plot(x, source, label = "Distilled") plt.xlabel("freq (Hz)") plt.ylabel("SNR") plt.title("Concept") plt.legend() plt.show() """plt.plot(x, fav_received, label = "Traces") plt.plot(x, fav_source+1, label = "Distilled Traces") plt.legend() plt.show() """