|
|
|
@ -94,7 +94,7 @@ class max_freq(gr.sync_block): |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.center_freq = int(freq) |
|
|
|
self.center_freq = int(freq) |
|
|
|
def work(self, input_items, output_items): |
|
|
|
def work(self, input_items, output_items): |
|
|
|
if time.time()-self.timer<1:#every 1 seconds |
|
|
|
if time.time()-self.timer<2:#every 2 seconds |
|
|
|
return len(input_items[0]) |
|
|
|
return len(input_items[0]) |
|
|
|
elif self.searchMode: |
|
|
|
elif self.searchMode: |
|
|
|
#in0 = input_items[0] |
|
|
|
#in0 = input_items[0] |
|
|
|
@ -104,11 +104,13 @@ class max_freq(gr.sync_block): |
|
|
|
numbers=np.delete(input_items[0][0],range(carrier-carrier_width,carrier+carrier_width+1))#read input and disregard center (hackrf LO) |
|
|
|
numbers=np.delete(input_items[0][0],range(carrier-carrier_width,carrier+carrier_width+1))#read input and disregard center (hackrf LO) |
|
|
|
#threshold=40# uni |
|
|
|
#threshold=40# uni |
|
|
|
#threshold=60#home |
|
|
|
#threshold=60#home |
|
|
|
threshold=np.mean(numbers)#2017-03-21 fft-multi-decoder |
|
|
|
#threshold=np.mean(numbers)#2017-03-21 fft-multi-decoder |
|
|
|
|
|
|
|
threshold=0.5*np.mean(numbers)#2017-05-18 fft-multi-decoder |
|
|
|
#minimum number of consecutive maximums (in fft domain) to consider signal as station: |
|
|
|
#minimum number of consecutive maximums (in fft domain) to consider signal as station: |
|
|
|
#min_consec_max_threshold=1#uni |
|
|
|
#min_consec_max_threshold=1#uni |
|
|
|
#min_consec_max_threshold=3#home |
|
|
|
#min_consec_max_threshold=3#home |
|
|
|
min_consec_max_threshold=6#2017-03-21 fft-multi-decoder |
|
|
|
#min_consec_max_threshold=6#2017-03-21 fft-multi-decoder |
|
|
|
|
|
|
|
min_consec_max_threshold=4#2017-05-18 fft-multi-decoder |
|
|
|
fuzzyness=2#uni |
|
|
|
fuzzyness=2#uni |
|
|
|
#fuzzyness=10#home |
|
|
|
#fuzzyness=10#home |
|
|
|
|
|
|
|
|
|
|
|
@ -172,11 +174,9 @@ class max_freq(gr.sync_block): |
|
|
|
del station_indices_trunc[self.num_decoders:]#remove non decodable (too quiet) incidices |
|
|
|
del station_indices_trunc[self.num_decoders:]#remove non decodable (too quiet) incidices |
|
|
|
|
|
|
|
|
|
|
|
station_indices_tune=[0]*self.num_decoders |
|
|
|
station_indices_tune=[0]*self.num_decoders |
|
|
|
|
|
|
|
|
|
|
|
same_station_threshold=int(500000*self.fft_len/self.samp_rate)#0.5mhz |
|
|
|
same_station_threshold=int(500000*self.fft_len/self.samp_rate)#0.5mhz |
|
|
|
#same_station_threshold=3 |
|
|
|
|
|
|
|
new_stations=[] |
|
|
|
new_stations=[] |
|
|
|
#add fixed stations: |
|
|
|
#add fixed stations (currently unused): |
|
|
|
for i,old_freq in enumerate(self.last_station_indices): |
|
|
|
for i,old_freq in enumerate(self.last_station_indices): |
|
|
|
if self.index_fixed[i]: |
|
|
|
if self.index_fixed[i]: |
|
|
|
station_indices_tune[i]=old_freq |
|
|
|
station_indices_tune[i]=old_freq |
|
|
|
@ -190,14 +190,19 @@ class max_freq(gr.sync_block): |
|
|
|
if not added: |
|
|
|
if not added: |
|
|
|
new_stations.append(new_freq) |
|
|
|
new_stations.append(new_freq) |
|
|
|
#print("tune1:%s"%station_indices_tune) |
|
|
|
#print("tune1:%s"%station_indices_tune) |
|
|
|
#print("new_1 %s"%new_stations) |
|
|
|
if self.debug: |
|
|
|
|
|
|
|
print("tunc:%s"%station_indices_trunc) |
|
|
|
|
|
|
|
print("new_1:%s"%new_stations) |
|
|
|
|
|
|
|
|
|
|
|
for i,tune_freq in enumerate(station_indices_tune): |
|
|
|
for i,tune_freq in enumerate(station_indices_tune): |
|
|
|
if tune_freq == 0 and len(new_stations)>0: |
|
|
|
if tune_freq == 0 and len(new_stations)>0:#add new stations to empty decoders |
|
|
|
station_indices_tune[i]=new_stations.pop() |
|
|
|
station_indices_tune[i]=new_stations.pop() |
|
|
|
#print("tune2:%s"%station_indices_tune) |
|
|
|
#print("tune2:%s"%station_indices_tune) |
|
|
|
#print("new_2 %s"%new_stations) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.debug: |
|
|
|
|
|
|
|
print("new_2:%s"%new_stations) |
|
|
|
|
|
|
|
print("last_index:%s"%self.last_station_indices) |
|
|
|
|
|
|
|
print("tune_index:%s"%station_indices_tune) |
|
|
|
self.last_station_indices=station_indices_tune#save current stations to compare againts next |
|
|
|
self.last_station_indices=station_indices_tune#save current stations to compare againts next |
|
|
|
|
|
|
|
|
|
|
|
station_strength=[] |
|
|
|
station_strength=[] |
|
|
|
@ -206,7 +211,7 @@ class max_freq(gr.sync_block): |
|
|
|
for index in station_indices_tune: |
|
|
|
for index in station_indices_tune: |
|
|
|
startfreq=self.center_freq-self.samp_rate/2 |
|
|
|
startfreq=self.center_freq-self.samp_rate/2 |
|
|
|
freq=self.samp_rate*index/self.fft_len+startfreq |
|
|
|
freq=self.samp_rate*index/self.fft_len+startfreq |
|
|
|
freq+=30000#add 30k because detected max often too low |
|
|
|
#freq+=30000#add 30k because detected max often too low |
|
|
|
num_decimals=int(round(math.log(self.snapto,10))) |
|
|
|
num_decimals=int(round(math.log(self.snapto,10))) |
|
|
|
station_freqs.append(round(freq,-num_decimals)) |
|
|
|
station_freqs.append(round(freq,-num_decimals)) |
|
|
|
station_strength.append(round(numbers[index],-2)) |
|
|
|
station_strength.append(round(numbers[index],-2)) |
|
|
|
|