Skip to content

Commit fc8a912

Browse files
committed
Add option for folder organisation
1 parent 80c16b2 commit fc8a912

File tree

9 files changed

+47
-28
lines changed

9 files changed

+47
-28
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ Note - I keep my all.txt files fairly small by archiving sections into other fil
7979
The software uses a simple wsjt_all.ini file to locate the all.txt files and set a couple of options. If none exists, the software can create a template for you but you still need to edit it to specify the paths to the all files. The wsjt_all.ini file looks like this:
8080
```
8181
[inputs]
82-
allA = C:\Users\drala\AppData\Local\WSJT-X\all.txt <- this file is used for the 'single all file' case
82+
allA = C:\Users\drala\AppData\Local\WSJT-X\all.txt
8383
allB = C:\Users\drala\AppData\Local\WSJT-X - AltAB\all.txt
8484
8585
[settings]
8686
session_guard_seconds = 300
8787
live_plot_window_seconds = 300
88-
show_best_snrs_only = N <- controls the behaviour of the lower SNR plot in the A/B analysis case
88+
show_best_snrs_only = N
89+
use_bandmode_folders = Y
8990
```
9091

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "wsjt_all"
3-
version = "1.5.0"
3+
version = "1.6.0"
44
license = "MIT"
55
license-files = ["LICENSE"]
66

src/wsjt_all/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .prog_flow import wsjt_all, wsjt_all_live, wsjt_all_ab, wsjt_all_ab_live
1+
from .run import wsjt_all, wsjt_all_live, wsjt_all_ab, wsjt_all_ab_live
22

src/wsjt_all/load_sessions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def list_sessions(sessions):
2323
print(f"{i+1} {get_session_info_string(s)}")
2424

2525
def load_sessions(allfilepath, session_split_guard_secs, skip_all_before = 0):
26+
print(f"Reading {allfilepath}")
2627
decodes =[]
2728
for line in open(allfilepath):
2829
if(allstr_to_epoch(line) > skip_all_before):

src/wsjt_all/plotter_dual.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ def make_chart_dual(plt, fig, axs, decodes_A, decodes_B, session_info, show_best
8383
fig.suptitle(f"Session: {session_info_string}")
8484
plt.tight_layout()
8585

86-
def plot_all_historic_dual(allfilepath_A, allfilepath_B, session_guard_seconds, show_best_snrs_only):
87-
sessions_AB, decodes_A, decodes_B = load_overlapping_sessions(allfilepath_A, allfilepath_B, session_guard_seconds)
88-
for i, session_info in enumerate(sessions_AB):
89-
session_info_string = get_session_info_string(session_info)
90-
print(f"Plotting session {i+1} of {len(sessions_AB)}: {session_info_string}")
91-
fig, axs = plt.subplots(3,1, figsize=(7, 9), height_ratios = (0.1,1,1))
92-
make_chart_dual(plt, fig, axs, decodes_A, decodes_B, session_info, show_best_snrs_only)
93-
save_chart(plt, session_info_string+".png")
94-
plt.close()
95-
9686
def plot_live_dual(allfilepath_A, allfilepath_B, session_guard_seconds, plot_window_seconds, show_best_snrs_only):
9787
fig, axs = plt.subplots(3,1, figsize=(7, 9), height_ratios = (0.1,1,1))
9888
plt.ion()
@@ -111,3 +101,13 @@ def plot_live_dual(allfilepath_A, allfilepath_B, session_guard_seconds, plot_win
111101
axs[0].cla(), axs[1].cla(), axs[2].cla()
112102
make_chart_dual(plt, fig, axs, decodes_A, decodes_B, session_info, show_best_snrs_only)
113103
plt.pause(5)
104+
105+
def plot_all_historic_dual(allfilepath_A, allfilepath_B, subfolder, session_guard_seconds, show_best_snrs_only, use_bandmode_folders):
106+
sessions_AB, decodes_A, decodes_B = load_overlapping_sessions(allfilepath_A, allfilepath_B, session_guard_seconds)
107+
for i, session_info in enumerate(sessions_AB):
108+
session_info_string = get_session_info_string(session_info)
109+
print(f"Plotting session {i+1} of {len(sessions_AB)}: {session_info_string}")
110+
fig, axs = plt.subplots(3,1, figsize=(7, 9), height_ratios = (0.1,1,1))
111+
make_chart_dual(plt, fig, axs, decodes_A, decodes_B, session_info, show_best_snrs_only)
112+
save_chart(plt, session_info_string+".png", subfolder, session_info, use_bandmode_folders)
113+
plt.close()

src/wsjt_all/plotter_single.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def make_chart_single(plt, fig, axs, decodes_A, session_info):
4747
fig.suptitle(f"Session: {session_info_string}")
4848
plt.tight_layout()
4949

50-
def plot_live_single(allfilepath_A, session_guard_seconds, plot_window_seconds, show_best_snrs_only):
50+
def plot_live_single(allfilepath_A, session_guard_seconds, plot_window_seconds):
5151
fig, axs = plt.subplots(2,1, figsize=(6, 9), height_ratios = (1,1))
5252
plt.ion()
5353
print("Waiting for live session data")
@@ -63,13 +63,13 @@ def plot_live_single(allfilepath_A, session_guard_seconds, plot_window_seconds,
6363
make_chart_single(plt, fig, axs, decodes_A, session_info)
6464
plt.pause(5)
6565

66-
def plot_all_historic_single(allfilepath_A, session_guard_seconds):
66+
def plot_all_historic_single(allfilepath_A, subfolder, session_guard_seconds, use_bandmode_folders):
6767
decodes_A, sessions_A = load_sessions(allfilepath_A, session_guard_seconds)
6868
for i, session_info in enumerate(sessions_A):
6969
if(session_info[1] > session_info[0] and len(sessions_A)>2):
7070
session_info_string = get_session_info_string(session_info)
7171
print(f"Plotting session {i+1} of {len(sessions_A)}: {session_info_string}")
7272
fig, axs = plt.subplots(2,1, figsize=(6, 9), height_ratios = (1,1))
7373
make_chart_single(plt, fig, axs, decodes_A, session_info)
74-
save_chart(plt, session_info_string+"_timeline.png")
74+
save_chart(plt, session_info_string+".png", subfolder, session_info, use_bandmode_folders)
7575
plt.close()
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def check_config():
1616
txt += "\nsession_guard_seconds = 300"
1717
txt += "\nlive_plot_window_seconds = 300"
1818
txt += "\nshow_best_snrs_only = N"
19+
txt += "\nuse_bandmode_folders = Y"
1920
txt += "\n"
2021
with open("wsjt_all.ini","w") as f:
2122
f.write(txt)
@@ -30,14 +31,28 @@ def run(option):
3031
session_guard_seconds = int(config.get("settings","session_guard_seconds"))
3132
live_plot_window_seconds = int(config.get("settings","live_plot_window_seconds"))
3233
show_best_snrs_only = (config.get("settings","show_best_snrs_only") == "Y")
34+
use_bandmode_folders = (config.get("settings","use_bandmode_folders") == "Y")
35+
3336
if(option=="hist_single"):
34-
plot_all_historic_single(allfilepath_A, session_guard_seconds)
37+
plot_all_historic_single(allfilepath_A, "A/", session_guard_seconds, use_bandmode_folders)
38+
if(allfilepath_A != allfilepath_B):
39+
plot_all_historic_single(allfilepath_B, "B/", session_guard_seconds, use_bandmode_folders)
40+
if(option=="live_single"):
41+
plot_live_single(allfilepath_A,session_guard_seconds, live_plot_window_seconds)
42+
3543
if(option=="hist_ab"):
36-
plot_all_historic_dual(allfilepath_A, allfilepath_B, session_guard_seconds, show_best_snrs_only)
44+
allfilepath_B = config.get("inputs","allB")
45+
if(allfilepath_A == allfilepath_B):
46+
print("AB analysis requires two different all.txt files")
47+
else:
48+
plot_all_historic_dual(allfilepath_A, allfilepath_B, "AB/", session_guard_seconds, show_best_snrs_only, use_bandmode_folders)
3749
if(option=="live_ab"):
38-
plot_live_dual(allfilepath_A, allfilepath_B, session_guard_seconds, live_plot_window_seconds, show_best_snrs_only)
39-
if(option=="live_single"):
40-
plot_live_single(allfilepath_A,session_guard_seconds, live_plot_window_seconds,False)
50+
allfilepath_B = config.get("inputs","allB")
51+
if(allfilepath_A == allfilepath_B):
52+
print("AB analysis requires two different all.txt files")
53+
else:
54+
plot_live_dual(allfilepath_A, allfilepath_B, session_guard_seconds, live_plot_window_seconds, show_best_snrs_only)
55+
4156

4257
def wsjt_all():
4358
run("hist_single")

src/wsjt_all/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import hashlib
2-
global colourseries
32
import random
43
import os
54

65
def hash_color(callsign, cmap):
76
h = int(hashlib.sha1(callsign.encode()).hexdigest(), 16)
87
return cmap(h % cmap.N)
98

10-
def save_chart(plt, plotfile):
11-
if not os.path.exists("plots"):
12-
os.makedirs("plots")
13-
print(f"Saving plot plots/{plotfile}")
14-
plt.savefig(f"plots/{plotfile}")
9+
def save_chart(plt, plotfile, subfolder, session_info, use_bandmode_folders):
10+
print(use_bandmode_folders)
11+
folder = f"plots/{session_info[2].replace('-','/')}/{subfolder}" if(use_bandmode_folders) else "plots"
12+
if not os.path.exists(folder):
13+
os.makedirs(folder)
14+
print(f"Saving {plotfile}")
15+
plt.savefig(f"{folder}/{plotfile}")
1516

1617
def dither(vals, amplitude_factor):
1718
amplitude = amplitude_factor * (max(vals) - min(vals))

tests/wsjt_all.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ allB = C:\Users\drala\AppData\Local\WSJT-X - AltAB\all.txt
66
session_guard_seconds = 300
77
live_plot_window_seconds = 300
88
show_best_snrs_only = N
9+
use_bandmode_folders = Y

0 commit comments

Comments
 (0)