def test_vhf_frequencies(self): assert freq_to_band(70001) == {"band": 4, "mode": None} assert freq_to_band(144000) == {"band": 2, "mode": const.CW} assert freq_to_band(144150) == {"band": 2, "mode": const.USB} assert freq_to_band(144400) == {"band": 2, "mode": None} assert freq_to_band(220000) == {"band": 1.25, "mode": None}
def test_vhf_frequencies(self): assert freq_to_band(70001) == {"band" : 4, "mode":None} assert freq_to_band(144000) == {"band" : 2, "mode":const.CW} assert freq_to_band(144150) == {"band" : 2, "mode":const.USB} assert freq_to_band(144400) == {"band" : 2, "mode":None} assert freq_to_band(220000) == {"band" : 1.25, "mode":None}
def test_shf_frequencies(self): assert freq_to_band(2390000) == {"band" : 0.13, "mode":None} assert freq_to_band(3300000) == {"band" : 0.09, "mode":None} assert freq_to_band(5650000) == {"band" : 0.053, "mode":None} assert freq_to_band(10000000) == {"band" : 0.03, "mode":None} assert freq_to_band(24000000) == {"band" : 0.0125, "mode":None} assert freq_to_band(47000000) == {"band" : 0.0063, "mode":None} with pytest.raises(KeyError): freq_to_band(16304)
def test_shf_frequencies(self): assert freq_to_band(2390000) == {"band": 0.13, "mode": None} assert freq_to_band(3300000) == {"band": 0.09, "mode": None} assert freq_to_band(5650000) == {"band": 0.053, "mode": None} assert freq_to_band(10000000) == {"band": 0.03, "mode": None} assert freq_to_band(24000000) == {"band": 0.0125, "mode": None} assert freq_to_band(47000000) == {"band": 0.0063, "mode": None} with pytest.raises(KeyError): freq_to_band(16304)
def test_hf_frequencies(self): assert freq_to_band(137) == {"band" : 2190, "mode":const.CW} assert freq_to_band(1805) == {"band" : 160, "mode":const.CW} assert freq_to_band(1838) == {"band" : 160, "mode":const.DIGITAL} assert freq_to_band(1870) == {"band" : 160, "mode":const.LSB} assert freq_to_band(3500) == {"band" : 80, "mode":const.CW} assert freq_to_band(3580) == {"band" : 80, "mode":const.DIGITAL} assert freq_to_band(3799) == {"band" : 80, "mode":const.LSB} assert freq_to_band(5200) == {"band" : 60, "mode":None} assert freq_to_band(7000) == {"band" : 40, "mode":const.CW} assert freq_to_band(7044) == {"band" : 40, "mode":const.DIGITAL} assert freq_to_band(7139) == {"band" : 40, "mode":const.LSB} assert freq_to_band(10100) == {"band" : 30, "mode":const.CW} assert freq_to_band(10141) == {"band" : 30, "mode":const.DIGITAL} assert freq_to_band(14000) == {"band" : 20, "mode":const.CW} assert freq_to_band(14070) == {"band" : 20, "mode":const.DIGITAL} assert freq_to_band(14349) == {"band" : 20, "mode":const.USB} assert freq_to_band(18068) == {"band" : 17, "mode":const.CW} assert freq_to_band(18096) == {"band" : 17, "mode":const.DIGITAL} assert freq_to_band(18250) == {"band" : 17, "mode":const.USB} assert freq_to_band(21000) == {"band" : 15, "mode":const.CW} assert freq_to_band(21070) == {"band" : 15, "mode":const.DIGITAL} assert freq_to_band(21449) == {"band" : 15, "mode":const.USB} assert freq_to_band(24890) == {"band" : 12, "mode":const.CW} assert freq_to_band(24916) == {"band" : 12, "mode":const.DIGITAL} assert freq_to_band(24965) == {"band" : 12, "mode":const.USB} assert freq_to_band(28000) == {"band" : 10, "mode":const.CW} assert freq_to_band(28070) == {"band" : 10, "mode":const.DIGITAL} assert freq_to_band(28500) == {"band" : 10, "mode":const.USB} assert freq_to_band(50000) == {"band" : 6, "mode":const.CW} assert freq_to_band(50100) == {"band" : 6, "mode":const.USB} assert freq_to_band(50500) == {"band" : 6, "mode":const.DIGITAL}
def test_uhf_frequencies(self): assert freq_to_band(420000) == {"band" : 0.7, "mode":None} assert freq_to_band(902000) == {"band" : 0.33, "mode":None} assert freq_to_band(1200000) == {"band" : 0.23, "mode":None}
def __init__(self, line, linehook="", verbose=False): self._line = line self._fields = {} self.linehook = linehook self.verbose = verbose values = self._line.split(",") reporter = { 'latitude': 0, 'ituz': 0, 'country': 'NA', 'cqz': 0, 'continent': 'NA', 'adif': 0, 'longitude': 0 } callsign = { 'latitude': 0, 'ituz': 0, 'country': 'NA', 'cqz': 0, 'continent': 'NA', 'adif': 0, 'longitude': 0 } band = {'band': 0, 'mode': 'NA'} cic = Callinfo(my_lookuplib) try: reporter = cic.get_all(values[2]) if self.verbose: sys.stderr.write("Decoded reporter => " + values[2] + "\n") except: sys.stderr.write("Error decoding reporter => " + values[2] + "\n") try: callsign = cic.get_all(values[6]) if self.verbose: sys.stderr.write("Decoded callsign => " + values[6] + "\n") except: sys.stderr.write("Error decoding callsign => " + values[6] + "\n") try: band = freq_to_band(float(values[5]) * 1000) except: sys.stderr.write("Error decoding freq => " + values[5] + "\n") self._fields[0] = WsprField('spotid', values[0]) self._fields[1] = WsprField( 'timestamp', datetime.utcfromtimestamp(int( values[1])).strftime('%Y-%m-%d %H:%M:%S')) self._fields[2] = WsprField('reporter', values[2]) self._fields[3] = WsprField('reportergrid', values[3]) self._fields[4] = WsprField('snr', values[4]) self._fields[5] = WsprField('freq', values[5]) self._fields[6] = WsprField('callsign', values[6]) self._fields[7] = WsprField('grid', values[7]) self._fields[8] = WsprField('power', values[8]) self._fields[9] = WsprField('drift', values[9]) self._fields[10] = WsprField('distance', values[10]) self._fields[11] = WsprField('azimuth', values[11]) self._fields[12] = WsprField('band', band['band']) self._fields[13] = WsprField('version', values[13]) self._fields[14] = WsprField('code', values[14]) self._fields[15] = WsprField( 'date', datetime.utcfromtimestamp(int(values[1])).strftime('%Y-%m-%d')) self._fields[16] = WsprField( 'time', datetime.utcfromtimestamp(int(values[1])).strftime('%H:%M:%S')) self._fields[17] = WsprField('reporter_latitude', reporter['latitude']) self._fields[18] = WsprField('reporter_longitude', reporter['longitude']) self._fields[19] = WsprField('reporter_ituz', reporter['ituz']) self._fields[20] = WsprField('reporter_country', reporter['country']) self._fields[21] = WsprField('reporter_cqz', reporter['cqz']) self._fields[22] = WsprField('reporter_continent', reporter['continent']) self._fields[23] = WsprField('reporter_adif', reporter['adif']) self._fields[24] = WsprField('callsign_latitude', callsign['latitude']) self._fields[25] = WsprField('callsign_longitude', callsign['longitude']) self._fields[26] = WsprField('callsign_ituz', callsign['ituz']) self._fields[27] = WsprField('callsign_country', callsign['country']) self._fields[28] = WsprField('callsign_cqz', callsign['cqz']) self._fields[29] = WsprField('callsign_continent', callsign['continent']) self._fields[30] = WsprField('callsign_adif', callsign['adif']) self._fields[31] = WsprField('bandmode', band['mode']) if self.linehook: self._execHook() else: sys.stderr.write("no hook script defined!\n")
def test_hf_frequencies(self): assert freq_to_band(137) == {"band": 2190, "mode": const.CW} assert freq_to_band(1805) == {"band": 160, "mode": const.CW} assert freq_to_band(1838) == {"band": 160, "mode": const.DIGITAL} assert freq_to_band(1870) == {"band": 160, "mode": const.LSB} assert freq_to_band(3500) == {"band": 80, "mode": const.CW} assert freq_to_band(3580) == {"band": 80, "mode": const.DIGITAL} assert freq_to_band(3799) == {"band": 80, "mode": const.LSB} assert freq_to_band(5200) == {"band": 60, "mode": None} assert freq_to_band(7000) == {"band": 40, "mode": const.CW} assert freq_to_band(7044) == {"band": 40, "mode": const.DIGITAL} assert freq_to_band(7139) == {"band": 40, "mode": const.LSB} assert freq_to_band(10100) == {"band": 30, "mode": const.CW} assert freq_to_band(10141) == {"band": 30, "mode": const.DIGITAL} assert freq_to_band(14000) == {"band": 20, "mode": const.CW} assert freq_to_band(14070) == {"band": 20, "mode": const.DIGITAL} assert freq_to_band(14349) == {"band": 20, "mode": const.USB} assert freq_to_band(18068) == {"band": 17, "mode": const.CW} assert freq_to_band(18096) == {"band": 17, "mode": const.DIGITAL} assert freq_to_band(18250) == {"band": 17, "mode": const.USB} assert freq_to_band(21000) == {"band": 15, "mode": const.CW} assert freq_to_band(21070) == {"band": 15, "mode": const.DIGITAL} assert freq_to_band(21449) == {"band": 15, "mode": const.USB} assert freq_to_band(24890) == {"band": 12, "mode": const.CW} assert freq_to_band(24916) == {"band": 12, "mode": const.DIGITAL} assert freq_to_band(24965) == {"band": 12, "mode": const.USB} assert freq_to_band(28000) == {"band": 10, "mode": const.CW} assert freq_to_band(28070) == {"band": 10, "mode": const.DIGITAL} assert freq_to_band(28500) == {"band": 10, "mode": const.USB} assert freq_to_band(50000) == {"band": 6, "mode": const.CW} assert freq_to_band(50100) == {"band": 6, "mode": const.USB} assert freq_to_band(50500) == {"band": 6, "mode": const.DIGITAL}
def test_uhf_frequencies(self): assert freq_to_band(420000) == {"band": 0.7, "mode": None} assert freq_to_band(902000) == {"band": 0.33, "mode": None} assert freq_to_band(1200000) == {"band": 0.23, "mode": None}
def test_ft_frequencies(self): assert freq_to_band(1840) == {"band": 160, "mode": const.DIGITAL} #FT8 assert freq_to_band(3573) == {"band": 80, "mode": const.DIGITAL} #FT8 assert freq_to_band(7074) == {"band": 40, "mode": const.DIGITAL} #FT8 assert freq_to_band(10136) == {"band": 30, "mode": const.DIGITAL} #FT8 assert freq_to_band(14074) == {"band": 20, "mode": const.DIGITAL} #FT8 assert freq_to_band(18100) == {"band": 17, "mode": const.DIGITAL} #FT8 assert freq_to_band(21074) == {"band": 15, "mode": const.DIGITAL} #FT8 assert freq_to_band(24915) == {"band": 12, "mode": const.DIGITAL} #FT8 assert freq_to_band(28074) == {"band": 10, "mode": const.DIGITAL} #FT8 assert freq_to_band(50313) == {"band": 6, "mode": const.DIGITAL} #FT8 assert freq_to_band(144174.5) == { "band": 2, "mode": const.DIGITAL } #FT8