-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintPlan.py
217 lines (126 loc) · 5.58 KB
/
printPlan.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
# printPlan.py
# Created on Thu Oct 21 13:15:39 2021
# @author: iqsnider
import datetime as dt
import os
from starlinkPassPredictor import *
from locations import *
from writeAcpPlan import *
from skyfield import api
from skyfield import almanac
from tkinter import *
from tkinter.scrolledtext import ScrolledText
from datetime import datetime
#functions to display user text when button is clicked
def calculatePlan(x, y, z):
return lambda : callback(x, y, z)
#callback function for printing to text box
def callback(x, y, z):
##########################
# Parameters
##########################
exposureTime = 3
exposureRepeat = 1
filterLetter = "v"
binning = 1
offset = 9 #offset the requested time to allow for slewing etc. 6 sec for starting at center of FOV. increase to trigger sooner
timePer = dt.timedelta(seconds=90) #minimum number of sec to wait before next target
minAlt = 20
sunUp = False
moonUp = None #any
eclipsed = False
params = [sunUp, moonUp, eclipsed, minAlt]
start = dt.datetime.utcnow().replace(hour=0, minute=00, second=00)
stop = dt.datetime.utcnow().replace(hour=4, minute=00, second=00)
#start = dt.datetime(2020,5,28,0,00,00)
#stop = dt.datetime(2020,5,28,5,00,00)
#set location
# loc = locations["TSU farm"]
# input location
loc = inputLocation(x, y, z)
#imagePath = "F:\\++__2020.5__++\\Sats\\%s_Starlink" % (start.strftime('%Y-%m-%d'))
imagePath = "%s_Starlink" % (start.strftime('%Y-%m-%d'))
#staticPath = "C:\\Users\\Pomenis\\Documents\\ACP Astronomy\\Plans"
staticPath = imagePath
###########################
#Make a new directory for todays data
#path = start.strftime('%Y-%m-%d')
path = imagePath
if os.path.isdir(path):
print("%s already exists, opening it..." % path)
else:
try:
os.mkdir(path)
except OSError:
print ("Creation of the directory %s failed" % path)
else:
print ("Successfully created the directory %s " % path)
###########################
ts = api.load.timescale()
e = api.load('de421.bsp')
### Evening ###
print("\n\n ### EVENING ### \n\n")
#Determine when is sunset and twilight
t, y = almanac.find_discrete(ts.utc(start.replace(tzinfo=api.utc)), ts.utc(stop.replace(tzinfo=api.utc)), almanac.dark_twilight_day(e, loc))
for ti, yi in zip(t,y):
if yi == 3:
sunset = ti
if yi == 1:
twilight = ti
twilight = twilight.utc_datetime()
print("Astronomical Twilght is " + twilight.strftime('%Y-%m-%d %H:%M:%S'))
###########################
# TODO function that accepts custom start time
# will then go here | *maybe* not for certain if this will work (but shall try lol)
# V
#Find all passes
passes = starlinkPassPredictor(twilight, stop, loc, params, path, "allPassesEvening_" + start.strftime('%Y-%m-%d'))
#Select some to observe
passes = selectStarlinkPasses(passes, timePer, path, "selectedPassesEvening_" + start.strftime('%Y-%m-%d'))
#Make an ACP plan
filename = "starlinkPlanEvening.txt"
print("Writing ACP Plan as " + filename)
#Reorganize for ACP plan
obs = []
for p in passes:
obs.append([p["name"],p["maxTime"],offset,p["maxRA"],p["maxDec"],p["maxAlt"],p["maxAz"]])
#Write ACP plan for Pomenis
writeAcpPlan(obs, exposureTime, exposureRepeat, filterLetter, binning, imagePath, os.path.join(path, filename), False)
writeAcpPlan(obs, exposureTime, exposureRepeat, filterLetter, binning, imagePath, os.path.join(staticPath, filename), False)
###########################
### Morning ###
print("\n\n ### MORNING ### \n\n")
start = dt.datetime.utcnow().replace(hour=9, minute=00, second=00)
stop = dt.datetime.utcnow().replace(hour=15, minute=00, second=00)
#start = dt.datetime(2020,5,28,9,00,00)
#stop = dt.datetime(2020,5,28,15,00,00)
#Determine when is sunset and twilight
t, y = almanac.find_discrete(ts.utc(start.replace(tzinfo=api.utc)), ts.utc(stop.replace(tzinfo=api.utc)), almanac.dark_twilight_day(e, loc))
for ti, yi in zip(t,y):
if yi == 3:
sunset = ti
if yi == 1:
twilight = ti
twilight = twilight.utc_datetime()
print("Astronomical Twilght is " + twilight.strftime('%Y-%m-%d %H:%M:%S') )
###########################
#Find all passes
passes = starlinkPassPredictor(start, twilight, loc, params, path, "allPassesMorning_" + start.strftime('%Y-%m-%d'))
#Select some to observe
passes = selectStarlinkPasses(passes, timePer, path, "selectedPassesMorning_" + start.strftime('%Y-%m-%d'))
###########################
#Make an ACP plan
filename = "starlinkPlanMorning.txt"
print("Writing ACP Plan as " + filename)
#Reorganize for ACP plan
obs = []
for p in passes:
obs.append([p["name"],p["maxTime"],offset,p["maxRA"],p["maxDec"],p["maxAlt"],p["maxAz"]])
#Write ACP plan for Pomenis
writeAcpPlan(obs, exposureTime, exposureRepeat, filterLetter, binning, imagePath, os.path.join(path, filename), True)
writeAcpPlan(obs, exposureTime, exposureRepeat, filterLetter, binning, imagePath, os.path.join(staticPath, filename), True)
###########################
# #insert to text box
# temp = passes
# planBox.insert(END, temp)
# planBox.see(END)