wip
This commit is contained in:
parent
666744086d
commit
ba83fe23c9
1 changed files with 8 additions and 4 deletions
12
process
12
process
|
@ -18,8 +18,8 @@ DETECT_FREQUENCY_TOLERANCE = 2 # Hz
|
||||||
DETECT_FREQUENCY_FROM = DETECT_FREQUENCY - DETECT_FREQUENCY_TOLERANCE # Hz
|
DETECT_FREQUENCY_FROM = DETECT_FREQUENCY - DETECT_FREQUENCY_TOLERANCE # Hz
|
||||||
DETECT_FREQUENCY_TO = DETECT_FREQUENCY + DETECT_FREQUENCY_TOLERANCE # Hz
|
DETECT_FREQUENCY_TO = DETECT_FREQUENCY + DETECT_FREQUENCY_TOLERANCE # Hz
|
||||||
ADJACENCY_FACTOR = 2 # area to look for noise around the target frequency
|
ADJACENCY_FACTOR = 2 # area to look for noise around the target frequency
|
||||||
AMPLITUDE_THRESHOLD = 200 # rDB
|
AMPLITUDE_THRESHOLD = 200 # relative DB (rDB) (because not calibrated)
|
||||||
BLOCK_SECONDS = 1 # seconds
|
BLOCK_SECONDS = 3 # seconds (longer means more frequency resolution, but less time resolution)
|
||||||
|
|
||||||
|
|
||||||
def process_recording(filename):
|
def process_recording(filename):
|
||||||
|
@ -51,13 +51,17 @@ def process_recording(filename):
|
||||||
max_amplitude_index = np.argmax(adjacent_amplitudes)
|
max_amplitude_index = np.argmax(adjacent_amplitudes)
|
||||||
max_freq = adjacent_labels[max_amplitude_index]
|
max_freq = adjacent_labels[max_amplitude_index]
|
||||||
|
|
||||||
|
# get the average amplitude of the adjacent frequencies
|
||||||
|
noise = np.mean(adjacent_amplitudes)/max_amplitude
|
||||||
|
|
||||||
# check for detection criteria
|
# check for detection criteria
|
||||||
max_freq_detected = DETECT_FREQUENCY_FROM <= max_freq <= DETECT_FREQUENCY_TO
|
max_freq_detected = DETECT_FREQUENCY_FROM <= max_freq <= DETECT_FREQUENCY_TO
|
||||||
amplitude_detected = max_amplitude > AMPLITUDE_THRESHOLD
|
amplitude_detected = max_amplitude > AMPLITUDE_THRESHOLD
|
||||||
|
low_noise_detected = noise < 0.1
|
||||||
|
|
||||||
# conclude detection
|
# conclude detection
|
||||||
if max_freq_detected and amplitude_detected:
|
if max_freq_detected and amplitude_detected and low_noise_detected:
|
||||||
print(f'{block_date}: {max_amplitude:.2f}rDB @ {max_freq:.2f}Hz')
|
print(f'{block_date}: {max_amplitude:.1f}rDB @ {max_freq:.1f}Hz ({noise:.3f}rDB noise)')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue