diff --git a/process b/process index dabdc51..3eddca1 100755 --- a/process +++ b/process @@ -18,8 +18,8 @@ DETECT_FREQUENCY_TOLERANCE = 2 # Hz DETECT_FREQUENCY_FROM = 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 -AMPLITUDE_THRESHOLD = 200 # rDB -BLOCK_SECONDS = 1 # seconds +AMPLITUDE_THRESHOLD = 200 # relative DB (rDB) (because not calibrated) +BLOCK_SECONDS = 3 # seconds (longer means more frequency resolution, but less time resolution) def process_recording(filename): @@ -51,13 +51,17 @@ def process_recording(filename): max_amplitude_index = np.argmax(adjacent_amplitudes) 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 max_freq_detected = DETECT_FREQUENCY_FROM <= max_freq <= DETECT_FREQUENCY_TO amplitude_detected = max_amplitude > AMPLITUDE_THRESHOLD + low_noise_detected = noise < 0.1 # conclude detection - if max_freq_detected and amplitude_detected: - print(f'{block_date}: {max_amplitude:.2f}rDB @ {max_freq:.2f}Hz') + if max_freq_detected and amplitude_detected and low_noise_detected: + print(f'{block_date}: {max_amplitude:.1f}rDB @ {max_freq:.1f}Hz ({noise:.3f}rDB noise)')