22import os
33import datetime
44import matplotlib .pyplot as plt
5- from .plotter import make_chart , save_chart , init_colours
5+ from .plotter_dual import make_chart_dual , save_chart , init_colours
6+ from .plotter_single import make_chart_single
67from .load_sessions import load_sessions , load_overlapping_sessions , get_session_info_string
78
89def check_config ():
@@ -24,18 +25,18 @@ def check_config():
2425 print ("A wsjt_all.ini file has been created, but please edit the paths to point to the two ALL.txt files you want to compare." )
2526 print ("Exiting program" )
2627
27- def plot_all_historic (allfilepath_A , allfilepath_B , session_guard_seconds , show_best_snrs_only ):
28+ def plot_all_historic_dual (allfilepath_A , allfilepath_B , session_guard_seconds , show_best_snrs_only ):
2829 sessions_AB , decodes_A , decodes_B = load_overlapping_sessions (allfilepath_A , allfilepath_B , session_guard_seconds )
2930 init_colours ()
30- print ("Plotting sessions:" )
31- for session_info in sessions_AB :
31+ for i , session_info in enumerate (sessions_AB ):
3232 session_info_string = get_session_info_string (session_info )
33+ print (f"Plotting session { i } of { len (sessions_AB )} : { session_info_string } " )
3334 fig , axs = plt .subplots (3 ,1 , figsize = (7 , 9 ), height_ratios = (0.1 ,1 ,1 ))
34- make_chart (plt , fig , axs , decodes_A , decodes_B , session_info , show_best_snrs_only )
35+ make_chart_dual (plt , fig , axs , decodes_A , decodes_B , session_info , show_best_snrs_only )
3536 save_chart (plt , session_info_string + ".png" )
3637 plt .close ()
3738
38- def plot_live (allfilepath_A , allfilepath_B , session_guard_seconds , plot_window_seconds , show_best_snrs_only ):
39+ def plot_live_dual (allfilepath_A , allfilepath_B , session_guard_seconds , plot_window_seconds , show_best_snrs_only ):
3940 fig , axs = plt .subplots (3 ,1 , figsize = (7 , 9 ), height_ratios = (0.1 ,1 ,1 ))
4041 plt .ion ()
4142 init_colours ()
@@ -52,9 +53,37 @@ def plot_live(allfilepath_A, allfilepath_B, session_guard_seconds, plot_window_s
5253 bm = sessions_A [- 1 ][2 ]
5354 session_info = (ts ,te ,bm )
5455 axs [0 ].cla (), axs [1 ].cla (), axs [2 ].cla ()
55- make_chart (plt , fig , axs , decodes_A , decodes_B , session_info , show_best_snrs_only )
56+ make_chart_dual (plt , fig , axs , decodes_A , decodes_B , session_info , show_best_snrs_only )
5657 plt .pause (5 )
5758
59+ def plot_live_single (allfilepath_A , session_guard_seconds , plot_window_seconds , show_best_snrs_only ):
60+ fig , axs = plt .subplots (2 ,1 , figsize = (6 , 9 ), height_ratios = (1 ,1 ))
61+ plt .ion ()
62+ print ("Waiting for live session data" )
63+ while (True ):
64+ t_recent = datetime .datetime .now ().timestamp () - plot_window_seconds * 3 # allow for delay in receiving live spots
65+ decodes_A , sessions_A = load_sessions (allfilepath_A , session_guard_seconds , skip_all_before = t_recent )
66+ if (len (sessions_A )> 0 ):
67+ te = sessions_A [- 1 ][1 ]
68+ ts = te - plot_window_seconds
69+ bm = sessions_A [- 1 ][2 ]
70+ session_info = (ts ,te ,bm )
71+ axs [0 ].cla (), axs [1 ].cla ()
72+ make_chart_single (plt , fig , axs , decodes_A , session_info , show_best_snrs_only )
73+ plt .pause (5 )
74+
75+ def plot_all_historic_single (allfilepath_A , session_guard_seconds ):
76+ decodes_A , sessions_A = load_sessions (allfilepath_A , session_guard_seconds )
77+ for i , session_info in enumerate (sessions_A ):
78+ if (session_info [1 ] > session_info [0 ] and len (sessions_A )> 2 ):
79+ session_info_string = get_session_info_string (session_info )
80+ print (f"Plotting session { i } of { len (sessions_A )} : { session_info_string } " )
81+ fig , axs = plt .subplots (2 ,1 , figsize = (6 , 9 ), height_ratios = (1 ,1 ))
82+ make_chart_single (plt , fig , axs , decodes_A , session_info )
83+ save_chart (plt , session_info_string + "_timeline.png" )
84+ plt .close ()
85+
86+
5887def run (option ):
5988 if (check_config ()):
6089 config = configparser .ConfigParser ()
@@ -63,13 +92,26 @@ def run(option):
6392 session_guard_seconds = int (config .get ("settings" ,"session_guard_seconds" ))
6493 live_plot_window_seconds = int (config .get ("settings" ,"live_plot_window_seconds" ))
6594 show_best_snrs_only = (config .get ("settings" ,"show_best_snrs_only" ) == "Y" )
66- if (option == "hist" ):
67- plot_all_historic (allfilepath_A , allfilepath_B , session_guard_seconds , show_best_snrs_only )
68- else :
69- plot_live (allfilepath_A , allfilepath_B , session_guard_seconds , live_plot_window_seconds , show_best_snrs_only )
95+ if (option == "hist_single" ):
96+ plot_all_historic_single (allfilepath_A , session_guard_seconds )
97+ if (option == "hist_ab" ):
98+ plot_all_historic_dual (allfilepath_A , allfilepath_B , session_guard_seconds , show_best_snrs_only )
99+ if (option == "live_ab" ):
100+ plot_live_dual (allfilepath_A , allfilepath_B , session_guard_seconds , live_plot_window_seconds , show_best_snrs_only )
101+ if (option == "live_single" ):
102+ plot_live_single (allfilepath_A ,session_guard_seconds , live_plot_window_seconds ,False )
103+
104+
105+ def wsjt_all ():
106+ run ("hist_single" )
107+
108+ def wsjt_all_live ():
109+ run ("live_single" )
70110
71111def wsjt_all_ab ():
72- run ("hist " )
112+ run ("hist_ab " )
73113
74114def wsjt_all_ab_live ():
75- run ("live" )
115+ run ("live_ab" )
116+
117+
0 commit comments