-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
108 lines (96 loc) · 3.13 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
import requests
from bs4 import BeautifulSoup
import numpy as np
def linkInput():
print("Paste the offsets link")
return str(input())
def infoInput():
print("Paste the object info")
return str(input())
def compute(arr, info):
date = info[0:15]
ra = info[18:28]
dec = info[29:38]
spd = info[54:58]
pa = info[60:65]
cfields = np.array(["0 0"])
sfields = np.array([0])
for x in range(arr.size // 2):
xsize = arr[x*2]
ysize = arr[x*2+1]
#print(str(xsize) + " " + str(ysize))
if np.abs(xsize) < 1100 and np.abs(ysize) < 1100:
sfields[0] += 1
else:
#print(str(xsize) + " " + str(ysize))
yf = int(np.abs(ysize) // 1100)
if ysize < 0:
yf *= -1
xf = int(np.abs(xsize) // 1100)
if xsize < 0:
xf *= -1
c = str(xf) + " " + str(yf)
confirm = False
for i in range(cfields.size):
if cfields[i] == c:
confirm = True
sfields += 1
break
if confirm == False:
cfields = np.append(cfields, str(xf) + " " + str(yf))
sfields = np.append(sfields, int(1))
#file1 = open("MyFile.txt","w")
for i in range(sfields.size):
dims = cfields[i].split(" ")
rs = float(ra[6:10])
rm = int(ra[3:5])
rh = int(ra[0:2])
rw = rh * 3600 + rm * 60 + rs + (2200 * int(dims[0]) / 15)
rh = rw // 3600
rw = rw % 3600
rm = rw // 60
rw = rw % 60
rs = round(rw,1)
newra = str(int(rh)) + " " + str(int(rm)) + " " + str(rs)
ds = float(dec[7:9])
dm = int(dec[4:6])
dh = int(dec[0:3])
dw = dh * 3600 + dm * 60 + ds + 2200 * int(dims[0])
dh = dw // 3600
dw = dw % 3600
dm = dw // 60
dw = dw % 60
ds = round(dw,1)
if dh < 0:
newdec = str(int(dh)) + " " + str(int(dm)) + " " + str(int(ds))
else:
newdec = "+" + str(int(dh)) + " " + str(int(dm)) + " " + str(int(ds))
scp = info[0:18] + newra + " " + newdec + info[38:]
print("hits:" + str(sfields[i]))
print(scp)
#file1.close()
def main():
lynk = '0'
while lynk != '':
info = infoInput()
soup = BeautifulSoup(requests.get(linkInput()).content, "html.parser")
table = soup.find("pre").contents
arr = np.array([])
for row in table:
try:
if str(row)[1] != 'N':
st = str(row)[1:20]
else:
st = str(row)[12:31]
st.strip(" ")
if st[0] != "a":
spts = st.split(" ")
for spt in spts:
if str(spt) != '':
if str(spt[0]) == "-" or str(spt[0]) == "+":
arr = np.append(arr, int(spt))
except:
break
compute(arr, info)
if __name__ == "__main__":
main()