18 lines
452 B
Python
18 lines
452 B
Python
import numpy as np
|
|
|
|
def decibels(f):
|
|
return 10 * np.log10(f)
|
|
|
|
def find_top_two_keys(d, threshold):
|
|
sorted_items = sorted(d.items(), key=lambda item: item[1], reverse=True)
|
|
|
|
if len(sorted_items) < 3:
|
|
return None
|
|
|
|
top_two = sorted_items[:2]
|
|
third_value = sorted_items[2][1]
|
|
if top_two[0][1] - third_value < threshold or top_two[1][1] - third_value < threshold:
|
|
return None
|
|
|
|
return top_two[0][0], top_two[1][0]
|