-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
237 lines (159 loc) · 6.12 KB
/
main.py
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
# main.py
# Sets up GUI and displays .csv files
# This script utilizes the functions in the other files to calculate
# ephemerides for Starlink, determine which are visible, and create
# an ACP observing plan for the Pomenis telescope
#
# Harry Krantz
# Steward Observatory
# University of Arizona
# Copyright May 2020
#
# This original script has been modified for developing a user-friendly
# interface for planning Starlink satellite observations.
# This is intended for students and amateur astronomers.
# @author modifications: Ian Snider
# Truman State University
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import datetime as dt
import os
import pandas as pd
from starlinkPassPredictor import *
from locations import *
from writeAcpPlan import *
from printPlan import *
from skyfield import api
from skyfield import almanac
from tkinter import *
from tkinter import filedialog, messagebox, ttk
from datetime import datetime
# Start of GUI block
print("Starting GUI")
# create root window
root = Tk()
# root window title and dimensions
root.title("Starlink Pass Predictor")
root.geometry('600x900')
# adding menu bar in root window
# new item in menu bar labeled as 'New'
# adding more items in menu bar
# menu = Menu(root)
# item = Menu(menu)
# item.add_command(label = 'New')
# menu.add_cascade(label = 'File', menu = item)
# root.config(menu = menu)
# frame for treeview
display_frame = LabelFrame(root, text="File Data")
display_frame.place(height=320,width=900)
#frame for file dialog
file_frame = LabelFrame(root, text="Open File")
file_frame.place(height=100, width=500, rely=0.4, relx=0)
#frame for plan calculation
calc_frame = LabelFrame(root, text="Calculate Observation Plan")
calc_frame.place(height=400, width=600, rely=0.55, relx=0)
#frame inside calc_frame for setting a specific time
setTime_frame = LabelFrame(calc_frame, text="Specific Start Time")
setTime_frame.place(height=100, width=500, rely=0.5, relx=0.05)
#end of style GUI Block
##############################
#Browse observation plan files
selectFileBtn = Button(file_frame, text="Select File", fg = "purple", command=lambda: file_dialog())
selectFileBtn.place(rely=0.65, relx=0.5)
#Load observation plan files
loadFileBtn = Button(file_frame, text="Load File", fg = "purple", command=lambda: load_data())
loadFileBtn.place(rely=0.65, relx=0.25)
# label file
label_file = ttk.Label(file_frame, text="No File Selected")
label_file.place(rely=0, relx=0)
##############################
#PassPredictor plan GUI output
# #plan header
# planX = Label(root, text = "Name ID Rise Time Rise Azimuth Peak Time Peak Alt Peak Azimuth Set Time Set Azimuth Duration")
# planX.place(x=5,y=65)
# #textbox output for copy/pasting
# planBox = ScrolledText(root, width=120, font=("lucida", 13))
# planBox.place(x=5,y=85)
##############################
# treeview widget
tv1 = ttk.Treeview(display_frame)
tv1.place(relheight=1, relwidth=1)
treescrolly = Scrollbar(display_frame, orient="vertical", command=tv1.yview)
treescrollx = Scrollbar(display_frame, orient="horizontal", command=tv1.xview)
tv1.configure(xscrollcommand=treescrollx.set, yscrollcommand=treescrolly.set)
treescrollx.pack(side="bottom", fill="x")
treescrolly.pack(side="right", fill="y")
# csv file display functions
def file_dialog():
fileName = filedialog.askopenfilename(initialdir="/StarlinkPassPredictorUI-main", title="Select a file", filetypes=(("csv files", "*.csv"),("All Files","*.*")))
label_file["text"] = fileName
return None
def load_data():
filePath = label_file["text"]
try:
csv_fileName = r"{}".format(filePath)
df = pd.read_csv(csv_fileName)
except ValueError:
tk.messagebox.showerror("Information", "Invalid file")
return None
except FileNotFoundError:
tk.messagebox.showerror("Information", "File not found")
return None
clear_data()
tv1["column"] = list(df.columns)
tv1["show"] = "headings"
for column in tv1["columns"]:
tv1.heading(column, text=column)
df_rows = df.to_numpy().tolist()
for row in df_rows:
tv1.insert("", "end", values=row)
return None
def clear_data():
tv1.delete(*tv1.get_children())
return None
##############################
# adding a label to the root window
locLbl = Label(calc_frame, text = "Input location (Latitude, Longitude, Elevation)")
locLbl.place(rely=0.05, relx=0.05)
# adding Entry field
#Latitude
latEntry = Entry(calc_frame, width=15)
latEntry.place(rely=0.15, relx=0.05)
#Logitude
lonEntry = Entry(calc_frame, width=15)
lonEntry.place(rely=0.15, relx=0.35)
#Elevation
elevationEntry = Entry(calc_frame, width=15)
elevationEntry.place(rely=0.15, relx=0.65)
#Specific time
startTimeEntry = Entry(setTime_frame, width=15)
startTimeEntry.place(rely=0.25, relx=0.05)
###############################
# run printPlan button
btn = Button(calc_frame, text = "Calculate Plan", fg = "purple", command=calculatePlan(latEntry, lonEntry, elevationEntry))
btn.place(rely=0.3, relx=0.05)
calcLbl = Label(calc_frame, text = "*Takes 1-2 mins*")
calcLbl.place(rely=0.4, relx=0.05)
###############################
# #Find .txt file for GUI
# #yyyy-mm-dd
# thisDay = datetime.utcnow().strftime("%Y-%m-%d")
# #find file
# searchFile = thisDay + "_Starlink" + "/" + filename
# f = open(searchFile, "r")
# #configure GUI plan details text
# satLabel = Label(root, text=f.readline())
# satLabel.place(x=1005,y=0)
###########################
#Execute tkinter
root.mainloop()
###########################
print("Done!")