forked from thetronjohnson/temp-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp-plot.py
More file actions
114 lines (103 loc) · 3.51 KB
/
temp-plot.py
File metadata and controls
114 lines (103 loc) · 3.51 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
from tkinter import *
import matplotlib.pyplot as plt
import fnmatch
import os
from tkinter import messagebox
def layout():
#Setting up the window
window = Tk()
window.title("Temperature Plotter")
window.geometry('350x150')
#Setting Up the input area
year = Label(window, text="Enter The Year")
month = Label(window, text="Enter The Month")
date = Label(window, text="Enter The Date")
year.grid(column=1, row=1)
month.grid(column=1, row=2)
date.grid(column=1, row=3)
year_txt = Entry(window,width=10)
year_txt.grid(column=2, row=1)
month_txt = Entry(window,width=10)
month_txt.grid(column=2, row=2)
date_txt = Entry(window,width=10)
date_txt.grid(column=2, row=3)
def shift_one():
y = year_txt.get()
m = month_txt.get()
d = date_txt.get()
for file in os.listdir('.'): #Check for file in directory
if fnmatch.fnmatch(file, f"Temp_log_{y}_{m}_{d}*"):
f = open(file,"r")
l = f.readlines()
f.close()
x = []
y = []
x_s = []
y_s = []
for i in l:
sub = i.split("\t")
x += [float(sub[3]+"."+sub[4])]
y += [float(sub[6])]
for i in range(len(x)):
if x[i]>=0 and x[i]<8:
x_s.append(x[i])
y_s.append(y[i])
plt.grid(True)
plt.plot(x_s,y_s)
plt.show()
def shift_two():
y = year_txt.get()
m = month_txt.get()
d = date_txt.get()
for file in os.listdir('.'): #Check for file in directory
if fnmatch.fnmatch(file, f"Temp_log_{y}_{m}_{d}*"):
f = open(file,"r")
l = f.readlines()
f.close()
x = []
y = []
x_s = []
y_s = []
for i in l:
sub = i.split("\t")
x += [float(sub[3]+"."+sub[4])]
y += [float(sub[6])]
for i in range(len(x)):
if x[i]>=8 and x[i]<16:
x_s.append(x[i])
y_s.append(y[i])
plt.grid(True)
plt.plot(x_s,y_s)
plt.show()
def shift_three():
y = year_txt.get()
m = month_txt.get()
d = date_txt.get()
for file in os.listdir('.'): #Check for file in directory
if fnmatch.fnmatch(file, f"Temp_log_{y}_{m}_{d}*"):
f = open(file,"r")
l = f.readlines()
f.close()
x = []
y = []
x_s = []
y_s = []
for i in l:
sub = i.split("\t")
x += [float(sub[3]+"."+sub[4])]
y += [float(sub[6])]
for i in range(len(x)):
if x[i]>=16 and x[i]<24:
x_s.append(x[i])
y_s.append(y[i])
plt.grid(True)
plt.plot(x_s,y_s)
plt.show()
btn1 = Button(window, text="Shift One", command=shift_one)
btn1.grid(column=1, row=4)
btn2 = Button(window, text="Shift Two", command=shift_two)
btn2.grid(column=2, row=4)
btn3 = Button(window, text="Shift Three", command=shift_three)
btn3.grid(column=3, row=4)
window.mainloop()
layout()