-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmendel_temperature_tracker.py
More file actions
1881 lines (1609 loc) · 98.7 KB
/
mendel_temperature_tracker.py
File metadata and controls
1881 lines (1609 loc) · 98.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Mendel Temperature Measurement - Classic Style (OPTIMIZED)
This version ensures reliable data saving and plotting for both simulation and modern measurements.
KEY FIXES:
1. All measurements now include 'month' and 'year' fields (required for plotting)
2. Data validation on load prevents malformed entries
3. Both simulation AND modern measurements appear on plot
4. Clear visual distinction: simulation (black borders), modern (red borders)
5. Console logging for debugging data flow
FONT SIZE ADJUSTMENT GUIDE:
Modify these constants to change all fonts at once:
"""
import tkinter as tk
from tkinter import ttk, messagebox, StringVar
import datetime as dt
import json
import os
from pathlib import Path
import csv
import platform
_IS_MAC = (platform.system() == "Darwin")
# === FONT SIZES - ADJUST THESE TO CHANGE ALL FONTS ===
FONT_TITLE = 14 # Main titles
FONT_HEADING = 12 # Section headings
FONT_BODY = 11 # Regular text
FONT_SMALL = 10 # Secondary text
FONT_TEMP_DISPLAY = 20 # Large temperature display
# === COLOR SCHEME (from plot) ===
COLOR_MORNING = '#4A5F7A' # Blue-gray
COLOR_AFTERNOON = '#8B4513' # Saddle brown
COLOR_EVENING = '#2F4F4F' # Dark slate gray
COLOR_BG_PARCHMENT = '#F5F3E8' # Parchment background
COLOR_BG_LIGHT = '#FDFCF5' # Light cream
COLOR_TEXT_PRIMARY = '#333333' # Dark text
COLOR_TEXT_SECONDARY = '#666666' # Gray text
COLOR_BORDER = '#5D4E37' # Dark brown
COLOR_SEPARATOR = '#DDDDDD' # Light gray
try:
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
MATPLOTLIB_AVAILABLE = True
except ImportError:
Figure = None
FigureCanvasTkAgg = None
MATPLOTLIB_AVAILABLE = False
# Try to import scipy for smooth curves (optional)
try:
from scipy.interpolate import make_interp_spline
import numpy as np
SCIPY_AVAILABLE = True
except ImportError:
SCIPY_AVAILABLE = False
class TemperatureTracker:
"""Temperature tracking following Mendel's schedule."""
VALID_HOURS = [6, 14, 22]
HOUR_NAMES = {6: "Morning", 14: "Afternoon", 22: "Evening"}
def __init__(self, garden_env, data_dir="data", climate_csv="climate/mendel_yearly_monthly_6_14_22.csv"):
self.garden_env = garden_env
self.data_dir = Path(data_dir)
self.data_dir.mkdir(exist_ok=True)
self.measurements = []
self.measurements_file = self.data_dir / "temperature_measurements.json"
self.modern_measurements = []
self.modern_measurements_file = self.data_dir / "modern_temperature_measurements.json"
self.mendel_averages = self._load_averages(climate_csv)
self._load_measurements()
self._load_modern_measurements()
self.window = None
def _load_averages(self, path):
"""Load Mendel's 15-year averages."""
if not os.path.exists(path):
# Adjusted values: 6am reduced by ~0.5°C, 14:00 increased by ~0.5°C
return {1:{6:-4.4,14:0.0,22:-2.8},2:{6:-3.0,14:3.0,22:-0.9},3:{6:-0.3,14:7.6,22:2.3},
4:{6:4.5,14:14.6,22:7.7},5:{6:9.4,14:19.6,22:12.2},6:{6:13.9,14:24.0,22:16.2},
7:{6:14.8,14:25.6,22:17.7},8:{6:14.4,14:24.5,22:17.3},9:{6:10.1,14:20.7,22:13.2},
10:{6:6.3,14:15.0,22:8.8},11:{6:1.2,14:5.9,22:2.7},12:{6:-2.9,14:1.0,22:-1.9}}
try:
with open(path, 'r') as f:
reader = csv.DictReader(f)
monthly_data = {}
for row in reader:
m = int(row['month'])
if m not in monthly_data:
monthly_data[m] = {6:[],14:[],22:[]}
monthly_data[m][6].append(float(row['T06_C']))
monthly_data[m][14].append(float(row['T14_C']))
monthly_data[m][22].append(float(row['T22_C']))
return {m: {h: sum(monthly_data[m][h])/len(monthly_data[m][h]) for h in [6,14,22]}
for m in monthly_data}
except:
# Adjusted values: 6am reduced by ~0.5°C, 14:00 increased by ~0.5°C
return {1:{6:-4.4,14:0.0,22:-2.8},2:{6:-3.0,14:3.0,22:-0.9},3:{6:-0.3,14:7.6,22:2.3},
4:{6:4.5,14:14.6,22:7.7},5:{6:9.4,14:19.6,22:12.2},6:{6:13.9,14:24.0,22:16.2},
7:{6:14.8,14:25.6,22:17.7},8:{6:14.4,14:24.5,22:17.3},9:{6:10.1,14:20.7,22:13.2},
10:{6:6.3,14:15.0,22:8.8},11:{6:1.2,14:5.9,22:2.7},12:{6:-2.9,14:1.0,22:-1.9}}
def _load_measurements(self):
"""Load simulation measurements with data validation."""
if self.measurements_file.exists():
try:
with open(self.measurements_file, 'r') as f:
loaded = json.load(f)
# Validate and fix each measurement
self.measurements = []
fixed_count = 0
for m in loaded:
# Ensure all required fields exist
if 'temperature' not in m or 'hour' not in m:
continue
# Add month and year if missing (CRITICAL FIX)
if 'month' not in m or 'year' not in m:
try:
if 'date' in m:
date_obj = dt.datetime.strptime(m['date'], "%Y-%m-%d")
m['month'] = date_obj.month
m['year'] = date_obj.year
fixed_count += 1
else:
continue # Skip if we can't determine date
except:
continue
self.measurements.append(m)
# Save the validated data back if we fixed anything
if fixed_count > 0:
print(f"[VALIDATION] Fixed {fixed_count} simulation measurements missing month/year fields")
self._save_measurements()
print(f"[LOAD] Loaded {len(self.measurements)} simulation measurements")
except Exception as e:
print(f"[ERROR] Failed to load measurements: {e}")
self.measurements = []
else:
print("[LOAD] No existing simulation measurements file")
def _save_measurements(self):
"""Save simulation measurements."""
try:
with open(self.measurements_file, 'w') as f:
json.dump(self.measurements, f, indent=2)
print(f"[SAVE] Saved {len(self.measurements)} simulation measurements")
except Exception as e:
print(f"[ERROR] Save error: {e}")
def _load_modern_measurements(self):
"""Load modern-day measurements with data validation."""
if self.modern_measurements_file.exists():
try:
with open(self.modern_measurements_file, 'r') as f:
loaded = json.load(f)
# Validate and fix each measurement
self.modern_measurements = []
fixed_count = 0
for m in loaded:
# Ensure all required fields exist
if 'temperature' not in m or 'hour' not in m:
continue
# Add month and year if missing (CRITICAL FIX)
if 'month' not in m or 'year' not in m:
try:
if 'date' in m:
date_obj = dt.datetime.strptime(m['date'], "%Y-%m-%d")
m['month'] = date_obj.month
m['year'] = date_obj.year
fixed_count += 1
else:
continue
except:
continue
self.modern_measurements.append(m)
# Save the validated data back if we fixed anything
if fixed_count > 0:
print(f"[VALIDATION] Fixed {fixed_count} modern measurements missing month/year fields")
self._save_modern_measurements()
print(f"[LOAD] Loaded {len(self.modern_measurements)} modern measurements")
except Exception as e:
print(f"[ERROR] Failed to load modern measurements: {e}")
self.modern_measurements = []
else:
print("[LOAD] No existing modern measurements file")
def _save_modern_measurements(self):
"""Save modern-day measurements."""
try:
with open(self.modern_measurements_file, 'w') as f:
json.dump(self.modern_measurements, f, indent=2)
print(f"[SAVE] Saved {len(self.modern_measurements)} modern measurements")
except Exception as e:
print(f"[ERROR] Save error: {e}")
def _get_datetime(self):
try:
if hasattr(self.garden_env, '_get_datetime'):
return self.garden_env._get_datetime()
return dt.datetime(
getattr(self.garden_env, 'year', 1856),
getattr(self.garden_env, 'month', 4),
getattr(self.garden_env, 'day_of_month', 1),
int(getattr(self.garden_env, 'clock_hour', 6)), 0)
except:
return dt.datetime(1856, 4, 1, 6, 0)
def can_measure_now(self):
if not self.garden_env:
return False, None, "No environment"
current_time = self._get_datetime()
hour = current_time.hour
if hour not in self.VALID_HOURS:
next_h = min([h for h in self.VALID_HOURS if h > hour] + [self.VALID_HOURS[0]+24])
if next_h >= 24: next_h -= 24
return False, None, f"Next: {next_h:02d}:00"
date_str = current_time.strftime("%Y-%m-%d")
for m in self.measurements:
if m['date'] == date_str and m['hour'] == hour:
return False, hour, "Already measured"
return True, hour, "Ready"
def get_current_temperature(self):
if not self.garden_env:
return None
try:
if hasattr(self.garden_env, 'climate'):
return round(self.garden_env.climate.get_temperature(self._get_datetime()), 1)
except:
pass
try:
temp = getattr(self.garden_env, 'temp', None)
if temp: return round(float(temp), 1)
except:
pass
return None
def take_measurement(self):
"""Quick measurement - returns (success, message). ALWAYS includes month and year for plotting."""
can, hour, reason = self.can_measure_now()
if not can:
return False, reason
temp = self.get_current_temperature()
if temp is None:
return False, "No temperature"
ct = self._get_datetime()
exp = self.mendel_averages.get(ct.month, {}).get(hour)
# Create measurement with ALL required fields for plotting
measurement = {
'date': ct.strftime("%Y-%m-%d"),
'datetime': ct.strftime("%Y-%m-%d %H:%M"),
'hour': hour,
'temperature': temp,
'month': ct.month, # CRITICAL for plotting
'year': ct.year, # CRITICAL for plotting
'is_simulation': True
}
self.measurements.append(measurement)
self._save_measurements()
print(f"[MEASUREMENT] Saved simulation: date={measurement['date']}, hour={hour}, temp={temp}°C, month={ct.month}")
msg = f"Recorded: {temp}°C"
if exp:
dev = temp - exp
msg += f" (avg: {exp:.1f}°C, {'+' if dev>0 else ''}{dev:.1f}°C)"
return True, msg
def open_observatory(self):
"""Open full window."""
if self.window and self.window.winfo_exists():
self.window.lift()
return
self.window = tk.Toplevel()
self.window.title("Meteorological Observatory")
self.window.geometry("950x700")
self.window.configure(bg=COLOR_BG_PARCHMENT)
# ── Cross-platform button styling ─────────────────────────────────────
obs_style = ttk.Style(self.window)
if _IS_MAC:
try:
obs_style.theme_use("clam")
except tk.TclError:
pass
# Primary action (blue-gray, white text) — Take / Record
obs_style.configure("Obs.TButton",
padding=(20, 10), foreground="white",
background=COLOR_MORNING, font=("Segoe UI", FONT_BODY, "bold"))
obs_style.map("Obs.TButton",
foreground=[("active", "white")],
background=[("active", "#3A4F6A")])
# Danger (red) — Delete All
obs_style.configure("ObsDel.TButton",
padding=(8, 4), foreground="white",
background="#c0392b", font=("Segoe UI", FONT_SMALL))
obs_style.map("ObsDel.TButton",
foreground=[("active", "white")],
background=[("active", "#922b21")])
# Neutral — Refresh
obs_style.configure("ObsRef.TButton",
padding=(8, 3), foreground=COLOR_TEXT_PRIMARY,
background="#dddddd", font=("Segoe UI", FONT_SMALL, "bold"))
obs_style.map("ObsRef.TButton",
foreground=[("active", COLOR_TEXT_PRIMARY)],
background=[("active", "#cccccc")])
self._obs_style_ready = True
nb = ttk.Notebook(self.window)
nb.pack(fill="both", expand=True, padx=8, pady=8)
# Create tabs
tab_record = tk.Frame(nb, bg="white")
tab_history = tk.Frame(nb, bg="white")
tab_plot = tk.Frame(nb, bg="white")
tab_about = tk.Frame(nb, bg="white")
nb.add(tab_record, text=" 📝 Record ")
nb.add(tab_history, text=" 📊 History ")
nb.add(tab_plot, text=" 📈 Plot ")
nb.add(tab_about, text=" ℹ️ About ")
self._tab_record_merged(tab_record)
self._tab_history(tab_history)
self._tab_plot(tab_plot)
self._tab_about(tab_about)
# Bind tab change event to refresh plot
def on_tab_change(event):
current_tab = event.widget.index("current")
if current_tab == 2: # Plot tab (0-indexed)
self._tab_plot(tab_plot)
nb.bind("<<NotebookTabChanged>>", on_tab_change)
def _tab_measure(self, parent):
c = tk.Canvas(parent, bg="white")
sb = tk.Scrollbar(parent, orient="vertical", command=c.yview)
s = tk.Frame(c, bg="white")
s.bind("<Configure>", lambda e: c.configure(scrollregion=c.bbox("all")))
c.create_window((0, 0), window=s, anchor="nw")
c.configure(yscrollcommand=sb.set)
tk.Label(s, text="Current Conditions", font=("Segoe UI",FONT_TITLE,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=20, pady=(20,15))
info = tk.Frame(s, bg=COLOR_BG_LIGHT, highlightbackground=COLOR_BORDER,
highlightthickness=2)
info.pack(fill="x", padx=20, pady=(0,20))
temp = self.get_current_temperature()
ct = self._get_datetime()
can, hour, reason = self.can_measure_now()
tk.Label(info, text=f"{temp}°C" if temp else "—",
font=("Segoe UI",FONT_TEMP_DISPLAY,"bold"), bg=COLOR_BG_LIGHT,
fg=COLOR_TEXT_PRIMARY).pack(pady=(15,5))
tk.Label(info, text=ct.strftime("%Y-%m-%d %H:%M"),
font=("Segoe UI",FONT_BODY), bg=COLOR_BG_LIGHT,
fg=COLOR_TEXT_SECONDARY).pack(pady=(0,15))
tk.Label(s, text="Measurement Schedule", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=20, pady=(0,10))
sched = tk.Frame(s, bg="white")
sched.pack(fill="x", padx=20)
for h in self.VALID_HOURS:
f = tk.Frame(sched, bg=COLOR_BG_LIGHT, highlightbackground=COLOR_SEPARATOR,
highlightthickness=1)
f.pack(side="left", expand=True, fill="both", padx=5, pady=5)
tk.Label(f, text=f"{h:02d}:00", font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_BG_LIGHT, fg=COLOR_TEXT_PRIMARY).pack(pady=(8,2))
tk.Label(f, text=self.HOUR_NAMES[h], font=("Segoe UI",FONT_SMALL),
bg=COLOR_BG_LIGHT, fg=COLOR_TEXT_SECONDARY).pack(pady=(0,8))
tk.Label(s, text="Take Measurement", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=20, pady=(20,10))
status = tk.Label(s, text="", font=("Segoe UI",FONT_BODY), bg="white")
status.pack(padx=20, pady=(0,10))
def do_measure():
success, msg = self.take_measurement()
status.config(text=msg, fg=COLOR_MORNING if success else "red")
if success:
self.window.after(2000, lambda: status.config(text=""))
if _IS_MAC:
btn = ttk.Button(s, text="\U0001f4dd Take Measurement",
style="Obs.TButton", command=do_measure)
else:
btn = tk.Button(s, text="\U0001f4dd Take Measurement",
font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_MORNING, fg="white",
activebackground="#3A4F6A",
command=do_measure, cursor="hand2",
bd=0, padx=20, pady=10)
btn.pack(pady=(0,20))
if not can:
tk.Label(s, text=f"Status: {reason}", font=("Segoe UI",FONT_BODY),
bg="white", fg=COLOR_TEXT_SECONDARY).pack(pady=(0,20))
c.pack(side="left", fill="both", expand=True)
sb.pack(side="right", fill="y")
def _tab_record_merged(self, parent):
"""Merged tab with simulation measurement on left and modern recording on right."""
# Main container with two columns
main_frame = tk.Frame(parent, bg="white")
main_frame.pack(fill="both", expand=True)
# Left column: Simulation measurement (from old Measure tab)
left_col = tk.Frame(main_frame, bg="white", highlightbackground=COLOR_SEPARATOR,
highlightthickness=1)
left_col.pack(side="left", fill="both", expand=True, padx=(10,5), pady=10)
# Right column: Modern recording (from old Record tab)
right_col = tk.Frame(main_frame, bg="white", highlightbackground=COLOR_SEPARATOR,
highlightthickness=1)
right_col.pack(side="left", fill="both", expand=True, padx=(5,10), pady=10)
# === LEFT: SIMULATION MEASUREMENT ===
left_scroll = tk.Canvas(left_col, bg="white")
left_sb = tk.Scrollbar(left_col, orient="vertical", command=left_scroll.yview)
left_content = tk.Frame(left_scroll, bg="white")
left_content.bind("<Configure>", lambda e: left_scroll.configure(scrollregion=left_scroll.bbox("all")))
left_scroll.create_window((0, 0), window=left_content, anchor="nw")
left_scroll.configure(yscrollcommand=left_sb.set)
tk.Label(left_content, text="Simulation Recording", font=("Segoe UI",FONT_TITLE,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(15,10))
tk.Label(left_content, text="Current Conditions", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(10,8))
info = tk.Frame(left_content, bg=COLOR_BG_LIGHT, highlightbackground=COLOR_BORDER,
highlightthickness=2)
info.pack(fill="x", padx=15, pady=(0,15))
temp = self.get_current_temperature()
ct = self._get_datetime()
can, hour, reason = self.can_measure_now()
tk.Label(info, text=f"{temp}°C" if temp else "—",
font=("Segoe UI",FONT_TEMP_DISPLAY,"bold"), bg=COLOR_BG_LIGHT,
fg=COLOR_TEXT_PRIMARY).pack(pady=(12,4))
tk.Label(info, text=ct.strftime("%Y-%m-%d %H:%M"),
font=("Segoe UI",FONT_BODY), bg=COLOR_BG_LIGHT,
fg=COLOR_TEXT_SECONDARY).pack(pady=(0,12))
tk.Label(left_content, text="Measurement Schedule", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(5,8))
sched = tk.Frame(left_content, bg="white")
sched.pack(fill="x", padx=15)
for h in self.VALID_HOURS:
f = tk.Frame(sched, bg=COLOR_BG_LIGHT, highlightbackground=COLOR_SEPARATOR,
highlightthickness=1)
f.pack(side="left", expand=True, fill="both", padx=3, pady=3)
tk.Label(f, text=f"{h:02d}:00", font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_BG_LIGHT, fg=COLOR_TEXT_PRIMARY).pack(pady=(6,2))
tk.Label(f, text=self.HOUR_NAMES[h], font=("Segoe UI",FONT_SMALL),
bg=COLOR_BG_LIGHT, fg=COLOR_TEXT_SECONDARY).pack(pady=(0,6))
tk.Label(left_content, text="Record Measurement", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(15,8))
status_sim = tk.Label(left_content, text="", font=("Segoe UI",FONT_BODY), bg="white")
status_sim.pack(padx=15, pady=(0,8))
def do_measure():
success, msg = self.take_measurement()
status_sim.config(text=msg, fg=COLOR_MORNING if success else "red")
if success:
left_content.after(2000, lambda: status_sim.config(text=""))
if _IS_MAC:
btn_sim = ttk.Button(left_content, text="\U0001f4dd Take Measurement",
style="Obs.TButton", command=do_measure)
else:
btn_sim = tk.Button(left_content, text="\U0001f4dd Take Measurement",
font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_MORNING, fg="white",
activebackground="#3A4F6A",
command=do_measure, cursor="hand2",
bd=0, padx=20, pady=10)
btn_sim.pack(pady=(0,15))
if not can:
tk.Label(left_content, text=f"Status: {reason}", font=("Segoe UI",FONT_SMALL),
bg="white", fg=COLOR_TEXT_SECONDARY).pack(pady=(0,15))
left_scroll.pack(side="left", fill="both", expand=True)
left_sb.pack(side="right", fill="y")
# === RIGHT: MODERN RECORDING ===
right_scroll = tk.Canvas(right_col, bg="white")
right_sb = tk.Scrollbar(right_col, orient="vertical", command=right_scroll.yview)
right_content = tk.Frame(right_scroll, bg="white")
right_content.bind("<Configure>", lambda e: right_scroll.configure(scrollregion=right_scroll.bbox("all")))
right_scroll.create_window((0, 0), window=right_content, anchor="nw")
right_scroll.configure(yscrollcommand=right_sb.set)
tk.Label(right_content, text="Modern Day Recording", font=("Segoe UI",FONT_TITLE,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(15,10))
tk.Label(right_content, text="Record today's actual temperature to compare with Mendel's 1850s data.",
font=("Segoe UI",FONT_BODY), bg="white", fg=COLOR_TEXT_SECONDARY,
wraplength=350, justify="left").pack(anchor="w", padx=15, pady=(0,15))
# Date
tk.Label(right_content, text="Date", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(5,3))
date_var = StringVar(value=dt.date.today().strftime("%Y-%m-%d"))
date_entry = tk.Entry(right_content, textvariable=date_var, font=("Segoe UI",FONT_BODY),
width=25, bd=2, relief="solid")
date_entry.pack(anchor="w", padx=15, pady=(0,10))
# Hour
tk.Label(right_content, text="Hour (6, 14, or 22)", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(5,3))
hour_var = StringVar()
hour_frame = tk.Frame(right_content, bg="white")
hour_frame.pack(anchor="w", padx=15, pady=(0,10))
for h in self.VALID_HOURS:
tk.Radiobutton(hour_frame, text=f"{h:02d}:00", variable=hour_var, value=str(h),
font=("Segoe UI",FONT_BODY), bg="white",
selectcolor=COLOR_BG_LIGHT).pack(side="left", padx=(0,10))
# Temperature
tk.Label(right_content, text="Temperature (°C)", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(5,3))
temp_var = StringVar()
temp_entry = tk.Entry(right_content, textvariable=temp_var, font=("Segoe UI",FONT_BODY),
width=25, bd=2, relief="solid")
temp_entry.pack(anchor="w", padx=15, pady=(0,10))
temp_entry.focus_set()
status_modern = tk.Label(right_content, text="", font=("Segoe UI",FONT_BODY), bg="white")
status_modern.pack(padx=15, pady=(5,10))
def record_modern():
try:
date_str = date_var.get().strip()
hour_str = hour_var.get().strip()
temp_str = temp_var.get().strip()
if not date_str or not hour_str or not temp_str:
status_modern.config(text="⚠ Please fill all fields", fg="red")
return
date_obj = dt.datetime.strptime(date_str, "%Y-%m-%d").date()
hour = int(hour_str)
temp = float(temp_str)
if hour not in self.VALID_HOURS:
status_modern.config(text="⚠ Hour must be 6, 14, or 22", fg="red")
return
# Check for duplicate
for m in self.modern_measurements:
if m['date'] == date_str and m['hour'] == hour:
status_modern.config(text="⚠ Already recorded for this date/hour", fg="orange")
return
mendel_avg = self.mendel_averages.get(date_obj.month, {}).get(hour)
measurement = {
'date': date_str,
'datetime': f"{date_str} {hour:02d}:00",
'hour': hour,
'temperature': temp,
'month': date_obj.month,
'year': date_obj.year,
'is_modern': True
}
self.modern_measurements.append(measurement)
self._save_modern_measurements()
msg = f"✓ Recorded: {temp}°C"
if mendel_avg:
dev = temp - mendel_avg
msg += f" (Mendel: {mendel_avg:.1f}°C, {'+' if dev>0 else ''}{dev:.1f}°C)"
status_modern.config(text=msg, fg=COLOR_AFTERNOON)
temp_var.set("")
temp_entry.focus_set()
except ValueError:
status_modern.config(text="⚠ Enter valid values", fg="red")
if _IS_MAC:
btn_modern = ttk.Button(right_content, text="\U0001f4be Record Measurement",
style="Obs.TButton", command=record_modern)
else:
btn_modern = tk.Button(right_content, text="\U0001f4be Record Measurement",
font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_AFTERNOON, fg="white",
activebackground="#7A3A0F",
command=record_modern, cursor="hand2",
bd=0, padx=20, pady=10)
btn_modern.pack(pady=(5,15), anchor="w", padx=15)
temp_entry.bind('<Return>', lambda e: record_modern())
# Tips
tk.Frame(right_content, height=2, bg=COLOR_SEPARATOR).pack(fill="x", padx=15, pady=15)
tk.Label(right_content, text="Tips", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=15, pady=(0,8))
tips = """• Record at Mendel's times: 6:00, 14:00, 22:00
• Modern data appears with RED borders on Plot
• Press Enter to record quickly
• Compare today's climate with 1850s"""
tk.Label(right_content, text=tips, font=("Segoe UI",FONT_SMALL), bg="white",
fg=COLOR_TEXT_SECONDARY, justify="left").pack(anchor="w", padx=15, pady=(0,15))
right_scroll.pack(side="left", fill="both", expand=True)
right_sb.pack(side="right", fill="y")
def _tab_history(self, parent):
"""Display both simulation and modern measurements side-by-side with delete buttons."""
# Clear any existing widgets (for refresh after delete)
for widget in parent.winfo_children():
widget.destroy()
# Title with totals and refresh button at top center
title_frame = tk.Frame(parent, bg="white")
title_frame.pack(pady=(10,5), padx=10)
header_row = tk.Frame(title_frame, bg="white")
header_row.pack()
tk.Label(header_row, text="Measurement History", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(0,10))
# Refresh button
if _IS_MAC:
refresh_btn = ttk.Button(header_row, text="\U0001f504 Refresh",
style="ObsRef.TButton",
command=lambda: self._tab_history(parent))
else:
refresh_btn = tk.Button(header_row, text="\U0001f504 Refresh",
font=("Segoe UI",FONT_SMALL,"bold"),
bg=COLOR_BG_LIGHT, fg=COLOR_TEXT_PRIMARY,
command=lambda: self._tab_history(parent),
cursor="hand2", bd=1, relief="solid",
padx=8, pady=3)
refresh_btn.pack(side="left")
totals_text = f"Recorded: {len(self.measurements)} | Modern: {len(self.modern_measurements)}"
tk.Label(title_frame, text=totals_text, font=("Segoe UI",FONT_SMALL),
bg="white", fg=COLOR_TEXT_SECONDARY).pack()
# Two columns frame
cols = tk.Frame(parent, bg="white")
cols.pack(fill="both", expand=True, padx=10, pady=(0,10))
# LEFT: Simulation
left = tk.Frame(cols, bg="white")
left.pack(side="left", fill="both", expand=True, padx=(0,5))
# Header with delete button
hdr1 = tk.Frame(left, bg=COLOR_BG_PARCHMENT)
hdr1.pack(fill="x", pady=(0,5))
tk.Label(hdr1, text="Recorded Measurements", font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_BG_PARCHMENT, fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=10, pady=5)
def del_sim():
self.measurements = []
self._save_measurements()
self._tab_history(parent) # Refresh
if _IS_MAC:
ttk.Button(hdr1, text="\U0001f5d1\ufe0f Delete All", style="ObsDel.TButton",
command=del_sim).pack(side="right", padx=10, pady=5)
else:
tk.Button(hdr1, text="\U0001f5d1\ufe0f Delete All", command=del_sim,
font=("Segoe UI",FONT_SMALL),
bg="#dc3545", fg="white",
padx=10, pady=2).pack(side="right", padx=10, pady=5)
# Scrollable canvas for simulation
c1 = tk.Canvas(left, bg="white", highlightthickness=1, highlightbackground=COLOR_SEPARATOR)
sb1 = tk.Scrollbar(left, orient="vertical", command=c1.yview)
s1 = tk.Frame(c1, bg="white")
s1.bind("<Configure>", lambda e: c1.configure(scrollregion=c1.bbox("all")))
c1.create_window((0, 0), window=s1, anchor="nw")
c1.configure(yscrollcommand=sb1.set)
if not self.measurements:
tk.Label(s1, text="No data yet", font=("Segoe UI",FONT_BODY),
bg="white", fg=COLOR_TEXT_SECONDARY).pack(padx=20, pady=20)
else:
for m in sorted(self.measurements, key=lambda x: x.get('datetime',''), reverse=True):
i = tk.Frame(s1, bg="#E8F4F8", padx=10, pady=6)
i.pack(fill="x", padx=10, pady=2)
tk.Label(i, text=m.get('datetime','N/A'), font=("Segoe UI",FONT_SMALL,"bold"),
bg="#E8F4F8", fg=COLOR_TEXT_PRIMARY).pack(anchor="w")
txt = f"{m.get('temperature','N/A')}°C"
if 'month' in m and 'hour' in m:
exp = self.mendel_averages.get(m['month'],{}).get(m['hour'])
if exp:
dev = m['temperature'] - exp
txt += f" • Avg: {exp:.1f}°C • Diff: {'+' if dev>0 else ''}{dev:.1f}°C"
tk.Label(i, text=txt, font=("Segoe UI",FONT_SMALL-1),
bg="#E8F4F8", fg=COLOR_TEXT_SECONDARY).pack(anchor="w")
c1.pack(side="left", fill="both", expand=True)
sb1.pack(side="right", fill="y")
# RIGHT: Modern
right = tk.Frame(cols, bg="white")
right.pack(side="left", fill="both", expand=True, padx=(5,0))
# Header with delete button
hdr2 = tk.Frame(right, bg=COLOR_BG_PARCHMENT)
hdr2.pack(fill="x", pady=(0,5))
tk.Label(hdr2, text="Modern Measurements", font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_BG_PARCHMENT, fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=10, pady=5)
def del_mod():
self.modern_measurements = []
self._save_modern_measurements()
self._tab_history(parent) # Refresh
if _IS_MAC:
ttk.Button(hdr2, text="\U0001f5d1\ufe0f Delete All", style="ObsDel.TButton",
command=del_mod).pack(side="right", padx=10, pady=5)
else:
tk.Button(hdr2, text="\U0001f5d1\ufe0f Delete All", command=del_mod,
font=("Segoe UI",FONT_SMALL),
bg="#dc3545", fg="white",
padx=10, pady=2).pack(side="right", padx=10, pady=5)
# Scrollable canvas for modern
c2 = tk.Canvas(right, bg="white", highlightthickness=1, highlightbackground=COLOR_SEPARATOR)
sb2 = tk.Scrollbar(right, orient="vertical", command=c2.yview)
s2 = tk.Frame(c2, bg="white")
s2.bind("<Configure>", lambda e: c2.configure(scrollregion=c2.bbox("all")))
c2.create_window((0, 0), window=s2, anchor="nw")
c2.configure(yscrollcommand=sb2.set)
if not self.modern_measurements:
tk.Label(s2, text="No data yet\n\nUse 'Record' tab", font=("Segoe UI",FONT_BODY),
bg="white", fg=COLOR_TEXT_SECONDARY, justify="center").pack(padx=20, pady=20)
else:
for m in sorted(self.modern_measurements, key=lambda x: x.get('datetime',''), reverse=True):
i = tk.Frame(s2, bg="#FFE4E1", padx=10, pady=6)
i.pack(fill="x", padx=10, pady=2)
tk.Label(i, text=m.get('datetime','N/A'), font=("Segoe UI",FONT_SMALL,"bold"),
bg="#FFE4E1", fg=COLOR_TEXT_PRIMARY).pack(anchor="w")
txt = f"{m.get('temperature','N/A')}°C"
if 'month' in m and 'hour' in m:
exp = self.mendel_averages.get(m['month'],{}).get(m['hour'])
if exp:
dev = m['temperature'] - exp
txt += f" • Avg: {exp:.1f}°C • Change: {'+' if dev>0 else ''}{dev:.1f}°C"
tk.Label(i, text=txt, font=("Segoe UI",FONT_SMALL-1),
bg="#FFE4E1", fg=COLOR_TEXT_SECONDARY).pack(anchor="w")
c2.pack(side="left", fill="both", expand=True)
sb2.pack(side="right", fill="y")
def _tab_record(self, parent):
"""Manual data entry for modern measurements."""
c = tk.Canvas(parent, bg="white")
sb = tk.Scrollbar(parent, orient="vertical", command=c.yview)
s = tk.Frame(c, bg="white")
s.bind("<Configure>", lambda e: c.configure(scrollregion=c.bbox("all")))
c.create_window((0, 0), window=s, anchor="nw")
c.configure(yscrollcommand=sb.set)
tk.Label(s, text="Record Modern Temperature", font=("Segoe UI",FONT_TITLE,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=20, pady=(20,10))
tk.Label(s, text="Enter today's actual temperature (e.g., from weather report) to compare with Mendel's historical data.",
font=("Segoe UI",FONT_BODY), bg="white", fg=COLOR_TEXT_SECONDARY,
wraplength=600).pack(anchor="w", padx=20, pady=(0,20))
# Date entry
date_frame = tk.Frame(s, bg="white")
date_frame.pack(anchor="w", padx=20, pady=(0,10))
tk.Label(date_frame, text="Date:", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(0,8))
now = dt.datetime.now()
date_var = StringVar(value=now.strftime("%Y-%m-%d"))
tk.Entry(date_frame, textvariable=date_var, font=("Segoe UI",FONT_BODY),
width=12).pack(side="left")
# Hour selection and temperature entry on same line
input_frame = tk.Frame(s, bg="white")
input_frame.pack(anchor="w", padx=20, pady=(0,10))
tk.Label(input_frame, text="Hour:", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(0,8))
hour_var = StringVar(value="14")
hour_dropdown = ttk.Combobox(input_frame, textvariable=hour_var,
values=["6", "14", "22"], width=5,
font=("Segoe UI",FONT_BODY), state="readonly")
hour_dropdown.pack(side="left", padx=(0,20))
tk.Label(input_frame, text="Temperature:", font=("Segoe UI",FONT_BODY,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(0,8))
temp_var = StringVar()
temp_entry = tk.Entry(input_frame, textvariable=temp_var, font=("Segoe UI",FONT_BODY),
width=10)
temp_entry.pack(side="left", padx=(0,6))
tk.Label(input_frame, text="°C", font=("Segoe UI",FONT_BODY),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left")
# Status label for feedback
status_label = tk.Label(s, text="", font=("Segoe UI",FONT_SMALL),
bg="white", fg=COLOR_MORNING)
status_label.pack(anchor="w", padx=20, pady=(5,0))
def record_modern():
try:
date_str = date_var.get()
hour = int(hour_var.get())
temp = float(temp_var.get())
if temp < -50 or temp > 60:
status_label.config(text="⚠ Temperature must be -50 to 60°C", fg="red")
return
# Parse date
try:
date_obj = dt.datetime.strptime(date_str, "%Y-%m-%d")
except:
status_label.config(text="⚠ Invalid date format (use YYYY-MM-DD)", fg="red")
return
# Check for duplicate
for m in self.modern_measurements:
if m['date'] == date_str and m['hour'] == hour:
status_label.config(text="⚠ Already recorded for this date and hour", fg="orange")
return
# Get Mendel's average for comparison
mendel_avg = self.mendel_averages.get(date_obj.month, {}).get(hour)
# Create measurement with ALL required fields for plotting
measurement = {
'date': date_str,
'datetime': f"{date_str} {hour:02d}:00",
'hour': hour,
'temperature': temp,
'month': date_obj.month, # CRITICAL for plotting
'year': date_obj.year, # CRITICAL for plotting
'is_modern': True
}
self.modern_measurements.append(measurement)
self._save_modern_measurements()
print(f"[MEASUREMENT] Saved modern: date={date_str}, hour={hour}, temp={temp}°C, month={date_obj.month}")
# Show feedback
msg = f"✓ Recorded: {temp}°C"
if mendel_avg:
dev = temp - mendel_avg
msg += f" (Mendel avg: {mendel_avg:.1f}°C, {'+' if dev>0 else ''}{dev:.1f}°C)"
status_label.config(text=msg, fg=COLOR_MORNING)
# Clear temperature for next entry
temp_var.set("")
temp_entry.focus_set()
except ValueError:
status_label.config(text="⚠ Enter a valid temperature number", fg="red")
# Record button
if _IS_MAC:
btn = ttk.Button(s, text="\U0001f4be Record Measurement",
style="Obs.TButton", command=record_modern)
else:
btn = tk.Button(s, text="\U0001f4be Record Measurement",
font=("Segoe UI",FONT_BODY,"bold"),
bg=COLOR_AFTERNOON, fg="white",
activebackground="#7A3A0F",
command=record_modern, cursor="hand2",
bd=0, padx=20, pady=10)
btn.pack(pady=(10,20), anchor="w", padx=20)
# Enable Enter key to record
temp_entry.bind('<Return>', lambda e: record_modern())
# Tips section
tk.Frame(s, height=2, bg=COLOR_SEPARATOR).pack(fill="x", padx=20, pady=20)
tk.Label(s, text="Tips", font=("Segoe UI",FONT_HEADING,"bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(anchor="w", padx=20, pady=(0,10))
tips = """• Use this to record actual temperatures from your location
• Compare modern climate with Mendel's 1850s measurements
• Record at the same hours as Mendel: 6:00, 14:00, or 22:00
• Data appears with RED borders on the Plot tab
• Press Enter after typing temperature to record quickly"""
tk.Label(s, text=tips, font=("Segoe UI",FONT_BODY), bg="white",
fg=COLOR_TEXT_SECONDARY, justify="left").pack(anchor="w", padx=20, pady=(0,20))
c.pack(side="left", fill="both", expand=True)
sb.pack(side="right", fill="y")
def _tab_plot(self, parent):
"""Plot with RELIABLE data display - shows BOTH simulation and modern measurements."""
# Clear previous plot widgets
for w in parent.winfo_children():
w.destroy()
global Figure, FigureCanvasTkAgg, MATPLOTLIB_AVAILABLE
print(f"\n[PLOT] Refreshing plot...")
print(f"[PLOT] Simulation measurements: {len(self.measurements)}")
print(f"[PLOT] Modern measurements: {len(self.modern_measurements)}")
# Create control frame for checkboxes
control_frame = tk.Frame(parent, bg="white")
control_frame.pack(fill="x", padx=10, pady=(10, 0))
def _cb(frame, text, var):
tk.Checkbutton(frame, text=text, variable=var,
command=lambda: self._tab_plot(parent),
font=("Segoe UI", FONT_BODY),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=5)
# ── ROW 1: Mendel (15-year avg) ──────────────────────────────────────
row1_frame = tk.Frame(control_frame, bg="white")
row1_frame.pack(fill="x", pady=2)
tk.Label(row1_frame, text="Mendel (15-year Avg):", font=("Segoe UI", FONT_BODY, "bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(5, 2))
if not hasattr(self, 'show_mendel_baseline_var'):
self.show_mendel_baseline_var = tk.BooleanVar(value=True)
_cb(row1_frame, "6:00, 14:00, 22:00", self.show_mendel_baseline_var)
if not hasattr(self, 'show_mendel_yearly_avg_var'):
self.show_mendel_yearly_avg_var = tk.BooleanVar(value=False)
_cb(row1_frame, "15-year Average", self.show_mendel_yearly_avg_var)
# ── ROW 2: Recorded data ─────────────────────────────────────────────
row2_frame = tk.Frame(control_frame, bg="white")
row2_frame.pack(fill="x", pady=2)
tk.Label(row2_frame, text="Recorded:", font=("Segoe UI", FONT_BODY, "bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(5, 2))
if not hasattr(self, 'show_recorded_points_var'):
self.show_recorded_points_var = tk.BooleanVar(value=True)
_cb(row2_frame, "Show Data Points", self.show_recorded_points_var)
if not hasattr(self, 'show_sim_monthly_avg_var'):
self.show_sim_monthly_avg_var = tk.BooleanVar(value=False)
_cb(row2_frame, "Monthly Avg", self.show_sim_monthly_avg_var)
if not hasattr(self, 'show_sim_yearly_avg_var'):
self.show_sim_yearly_avg_var = tk.BooleanVar(value=False)
_cb(row2_frame, "Yearly Avg (all times)", self.show_sim_yearly_avg_var)
# ── ROW 3: Brno 2025 ────────────────────────────────────────────────
row3_frame = tk.Frame(control_frame, bg="white")
row3_frame.pack(fill="x", pady=2)
tk.Label(row3_frame, text="Brno (2025):", font=("Segoe UI", FONT_BODY, "bold"),
bg="white", fg=COLOR_TEXT_PRIMARY).pack(side="left", padx=(5, 2))
if not hasattr(self, 'show_2025_data_var'):
self.show_2025_data_var = tk.BooleanVar(value=False)
_cb(row3_frame, "Show Data Points", self.show_2025_data_var)
if not hasattr(self, 'show_2025_avg_var'):
self.show_2025_avg_var = tk.BooleanVar(value=False)
_cb(row3_frame, "Monthly Avg", self.show_2025_avg_var)
if not hasattr(self, 'show_2025_yearly_avg_var'):
self.show_2025_yearly_avg_var = tk.BooleanVar(value=False)
_cb(row3_frame, "Yearly Avg", self.show_2025_yearly_avg_var)