Skip to content

Commit

Permalink
apply update from keenerd#11
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-foy committed Oct 29, 2020
1 parent 4d74fdc commit 979148d
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions heatmap/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
from collections import defaultdict
from itertools import *

urlretrieve = lambda a, b: None
try:
import urllib.request
urlretrieve = urllib.request.urlretrieve
except:
import urllib
urlretrieve = urllib.urlretrieve

# todo:
# matplotlib powered --interactive
Expand All @@ -22,15 +15,11 @@
# gain normalization
# check pil version for brokenness

vera_url = "https://github.com/keenerd/rtl-sdr-misc/raw/master/heatmap/Vera.ttf"
vera_path = os.path.join(sys.path[0], "Vera.ttf")
vera_path = os.path.join(sys.path[0], "/usr/share/fonts/TTF/DejaVuSans.ttf")

tape_height = 25
tape_pt = 10

if not os.path.isfile(vera_path):
urlretrieve(vera_url, vera_path)

try:
font = ImageFont.truetype(vera_path, 10)
except:
Expand Down Expand Up @@ -217,7 +206,7 @@ def open_raw_data(path):
raw_data = lambda: gzip_wrap(path)
return raw_data

def slice_columns(columns, low_freq, high_freq):
def slice_columns(columns, low, high, low_freq, high_freq):
start_col = 0
stop_col = len(columns)
if low_freq is not None and low <= low_freq <= high:
Expand Down Expand Up @@ -258,7 +247,8 @@ def summarize_pass(args):
break
times.add(t)
columns = list(frange(low, high, step))
start_col, stop_col = slice_columns(columns, args.low_freq, args.high_freq)
start_col, stop_col = slice_columns(columns, low, high, args.low_freq, args.high_freq)
print(start_col, stop_col)
f_key = (columns[start_col], columns[stop_col], step)
zs = line[6+start_col:6+stop_col+1]
if not zs:
Expand Down Expand Up @@ -380,7 +370,7 @@ def collate_row(x_size):
high = int(line[3]) + args.offset_freq
step = float(line[4])
columns = list(frange(low, high, step))
start_col, stop_col = slice_columns(columns, args.low_freq, args.high_freq)
start_col, stop_col = slice_columns(columns, low, high, args.low_freq, args.high_freq)
if args.low_freq and columns[stop_col] < args.low_freq:
continue
if args.high_freq and columns[start_col] > args.high_freq:
Expand Down Expand Up @@ -623,3 +613,4 @@ def create_labels(args, img):
print("saving")
img.save(args.output_path)


0 comments on commit 979148d

Please sign in to comment.