diff --git a/auto_rx/autorx/scan.py b/auto_rx/autorx/scan.py index 14a192b5..9490ba14 100644 --- a/auto_rx/autorx/scan.py +++ b/auto_rx/autorx/scan.py @@ -8,6 +8,7 @@ import autorx import datetime import logging +import math import numpy as np import os import sys @@ -1072,6 +1073,7 @@ def sonde_search(self, first_only=False): # This is actually a bit of a pain to do... _peak_freq = [] _peak_lvl = [] + _search_radius = math.ceil((self.quantization / 2) / self.search_step) for _peak in peak_frequencies: try: # Find the index of the peak within our decimated frequency array. @@ -1081,13 +1083,13 @@ def sonde_search(self, first_only=False): # Because we've decimated the freq & power data, the peak location may # not be exactly at this frequency, so we take the maximum of an area # around this location. - _peak_search_min = max(0, _peak_power_idx - 5) + _peak_search_min = max(0, _peak_power_idx - _search_radius) _peak_search_max = min( - len(scan_result["freq"]) - 1, _peak_power_idx + 5 + len(scan_result["freq"]) - 1, _peak_power_idx + _search_radius ) # Grab the maximum value, and append it and the frequency to the output arrays _peak_lvl.append( - max(scan_result["power"][_peak_search_min:_peak_search_max]) + max(scan_result["power"][_peak_search_min:_peak_search_max + 1]) ) _peak_freq.append(_peak / 1e6) except: