Name the band beside every frequency, and map who was heard
Two additions, both about turning a number into something meaningful. A band column. Next to every frequency -- on the live display, in the line-per-hit output, in saunterbrowse's list and details -- is the name of the band it falls in. 421 MHz is the 70 cm amateur band, and being told so is quicker than remembering where the edges are. The names come from the existing preset table, so there is one band plan to keep right rather than two, but naming is not the job that table was shaped for: several presets cover any frequency, some of them whole-tuner sweeps that say nothing. So the candidates are ranked. Sweeps and the "-complete" duplicates are dropped outright. The narrowest of what is left wins, because it says the most -- 146.52 MHz comes back as the 2 m simplex calling channel rather than as the whole 2 m band. Two exceptions where the narrowest would be the wrong answer: ISM yields to the allocation it shares (433.92 is 70 cm first, 915 is 33 cm first), and shortwave broadcast yields to amateur where the two overlap, because 3.9-4.0 and 7.2-7.3 MHz are Region 1 and 3 broadcast but Region 2 amateur, and this plan is documented as Region 2. 6 MHz really is 49 m shortwave and is left alone. The name is written into each capture's sidecar, so it travels with the recording and an edit to the plan later cannot rewrite history, and saunterbrowse searches on it: /70 cm finds the band without anyone having to remember 420-450 MHz. A map. A licence says where its holder is, so a list of callsigns is also a map. Callsigns heard during a scan are now looked up as the transcripts come in, announced on the display, and written to callsigns.kml in the output directory; saunterbrowse --kml builds the same file from recordings already on disk, and the two continue one map rather than starting two. One placemark per station, not one per transmission: the same repeater heard twenty times in an evening is one operator, and twenty pins on one rooftop would say less than one. Each pin carries the callsign, the licensee, the town, the grid square, and every frequency and time it was heard on. The file is read back on open and added to, so later scans build it up rather than replacing it. Where a licence has no coordinates the grid square's centre is used and the placemark says so -- a square is kilometres across where an address is a street. A callsign with no licence at all is still recorded, in a folder that starts switched off, because that a station was heard is worth keeping even when nothing says where. A file already there that is not readable as KML is never overwritten. Also fixed along the way: - The hit list's "no signals recorded yet" placeholder was one cell short of its row, so it landed in the SNR column and wrapped, making the panel taller than the layout had budgeted for and scrolling the display off a short terminal. The identification column can no longer wrap either, which is what _hit_capacity has always assumed. - Licence lookups now record coordinates. The cache is versioned so that entries written before this are asked about again, rather than pinning every station to its grid square for good. - CallsignBook.wait dropped joined threads; an all-night scan calls it after every transcript and the list only ever grew. - Tests redirect XDG_CACHE_HOME, so a run no longer reads or writes the real lookup cache. 676 -> 761 tests.
This commit is contained in:
parent
739a2faaf4
commit
fb2bb3344b
23 changed files with 2155 additions and 42 deletions
|
|
@ -356,3 +356,64 @@ def test_the_report_carries_the_extra_detail():
|
|||
oper_class="EXTRA", grid="DM42lj", status="found")
|
||||
line = report([entry], width=0)[1]
|
||||
assert "Extra" in line and "DM42lj" in line
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Coordinates, and the cache that holds them
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_a_lookup_records_where_the_licence_says_the_station_is(monkeypatch):
|
||||
"""The map is built from these, so they have to survive the parse."""
|
||||
body = {"status": "VALID", "name": "ARRL HQ OPERATORS CLUB",
|
||||
"address": {"line2": "NEWINGTON, CT 06111"},
|
||||
"location": {"latitude": "41.714775", "longitude": "-72.727260",
|
||||
"gridsquare": "FN31pr"}}
|
||||
entry = Callsign(call="W1AW")
|
||||
CallsignBook._apply(entry, body)
|
||||
assert entry.position == pytest.approx((41.714775, -72.727260))
|
||||
assert not entry.coarse_position
|
||||
|
||||
|
||||
def test_a_licence_with_only_a_grid_square_falls_back_to_it(monkeypatch):
|
||||
body = {"status": "VALID", "name": "SOMEONE",
|
||||
"address": {"line2": "SOMEWHERE, AZ 85742"},
|
||||
"location": {"gridsquare": "DM42lj"}}
|
||||
entry = Callsign(call="KU0W")
|
||||
CallsignBook._apply(entry, body)
|
||||
assert entry.position is not None
|
||||
# and it says the position is only as good as the square
|
||||
assert entry.coarse_position
|
||||
|
||||
|
||||
def test_a_licence_with_no_position_at_all_has_none():
|
||||
body = {"status": "VALID", "name": "SOMEONE", "address": {}, "location": {}}
|
||||
entry = Callsign(call="K7XYZ")
|
||||
CallsignBook._apply(entry, body)
|
||||
assert entry.position is None
|
||||
assert not entry.coarse_position
|
||||
|
||||
|
||||
def test_an_entry_cached_before_coordinates_is_looked_up_again(tmp_path):
|
||||
"""Otherwise a warm cache pins every station to its grid square for good."""
|
||||
from bandsaunter.callsign import CACHE_VERSION
|
||||
cache = tmp_path / "callsigns.json"
|
||||
cache.write_text(json.dumps({"W1AW": {
|
||||
"call": "W1AW", "name": "Arrl Hq Operators Club", "status": "found",
|
||||
"grid": "FN31pr", "fetched_at": time.time()}}))
|
||||
book = CallsignBook(online=False, cache=cache)
|
||||
assert "W1AW" not in book._entries
|
||||
|
||||
cache.write_text(json.dumps({"W1AW": {
|
||||
"call": "W1AW", "name": "Arrl Hq Operators Club", "status": "found",
|
||||
"grid": "FN31pr", "fetched_at": time.time(),
|
||||
"version": CACHE_VERSION}}))
|
||||
assert "W1AW" in CallsignBook(online=False, cache=cache)._entries
|
||||
|
||||
|
||||
def test_an_unlisted_callsign_is_cached_too(tmp_path, monkeypatch):
|
||||
"""Asking again every run about a callsign with no licence is waste."""
|
||||
from bandsaunter.callsign import CACHE_VERSION
|
||||
entry = Callsign(call="XX9ZZ")
|
||||
CallsignBook._apply(entry, {"status": "INVALID"})
|
||||
assert entry.status == "unlisted"
|
||||
assert entry.version == CACHE_VERSION
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue