From 6e08a428d643342794f8ebfb1e71f6e443287738 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 19 Jul 2019 23:15:10 +0200 Subject: [PATCH] import frequencies; fix band errors --- bands.json | 2 +- owrx/bands.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bands.json b/bands.json index 971ab90..f8b6bb6 100644 --- a/bands.json +++ b/bands.json @@ -26,7 +26,7 @@ { "name": "60m", "lower_bound": 5351500, - "upper_bound": 3566500, + "upper_bound": 5366500, "frequencies": { "ft8": 5357000, "wspr": 5287200 diff --git a/owrx/bands.py b/owrx/bands.py index c2ed79e..47bd857 100644 --- a/owrx/bands.py +++ b/owrx/bands.py @@ -1,11 +1,24 @@ import json +import logging +logger = logging.getLogger(__name__) + class Band(object): def __init__(self, dict): self.name = dict["name"] self.lower_bound = dict["lower_bound"] self.upper_bound = dict["upper_bound"] + self.frequencies = [] + if "frequencies" in dict: + for (mode, freqs) in dict["frequencies"].items(): + if not isinstance(freqs, list): + freqs = [freqs] + for f in freqs: + if not self.inBand(f): + logger.warning("Frequency for {mode} on {band} is not within band limits: {frequency}".format(mode = mode, frequency = f, band = self.name)) + else: + self.frequencies.append([{"mode": mode, "frequency": f}]) def inBand(self, freq): return self.lower_bound <= freq <= self.upper_bound