-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
371 lines (314 loc) · 10.3 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
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
#!/usr/bin/python3
import asyncio, bz2
from pyscript import document
from pyweb import pydom
"""
== CSN ON ECLIPTIC J2000 (modified 17.11.2007):==
<31deg> ARIES <56deg> TAURUS <92deg> GEMINI
<118deg> CANCER <137deg> LEO <172deg> VIRGO
<215deg> LIBRA <239deg> SCORPIO
<266deg> SAGITTARIUS <296deg> CAPRICORN
<326deg> AQUARIUS <349deg> PISCES
sol sagitario
luna scorpio
saturno leo
jupiter scorpio
marte scorpio
venus sagitario
mercurio capricornio
SOL LUNA SATURNO JUPITER MARTE VENUS MERCURIO
# DESDE: --------------------------------------------------------
7.5 6.5 3.5 6.5 6.5 7.5 8.5
# HASTA: --------------------------------------------------------
9.0 8.0 5.0 8.0 8.0 9.0 10.0
# MEJOR: --------------------------------------------------------
8.5 7.5 4.5 7.5 7.5 8.5 9.5
SOL LUNA SATURNO JUPITER MARTE VENUS MERCURIO
# DESDE: --------------------------------------------------------
8.0 7.0 4.0 7.0 7.0 8.0 9.0
# HASTA: --------------------------------------------------------
9.0 8.0 5.0 8.0 8.0 9.0 10.0
# MEJOR: --------------------------------------------------------
8.5 7.5 4.5 7.5 7.5 8.5 9.5
============================================================
0 ARIES 1 TAURO 2 GEMINIS 3 CANCER 4 LEO 5 VIRGO 6 LIBRA 7 ESCORPIO 8 SAGITARIO 9 CAPRICORNIO 10 ACUARIO 11 PISCIS 12=0
============================================================
"""
#Z = [310,560,920,1180,1370,1720,2150,2390,2660,2960,3260,3490,3900,4150]
#zod: te da pos zodiaco de una posición en décimas de grados
def zod(p):
if p<310:
i=11
p+=3600
else:
for i in range(len(Z)-1):
if p<Z[i+1]:
break
q=p-Z[i]
d=(Z[i+1]-Z[i])/10
q=int(q/d)
return str(i)+'.'+str(q)
#ini: te da inicio del intervalo en *decimas de grados* (grados/10)
def ini(i):
a=Z[int(h1[i])]
b=(h1[i]-int(h1[i]))*(Z[int(h1[i])+1]-a)
res = a+b+6
if res > 3590:
res-=3590
return (res)
#fin: te da fin del intervalo en *decimas de grados* (grados/10)
def fin(i):
a=Z[int(h2[i])]
b=(h2[i]-int(h2[i]))*(Z[int(h2[i])+1]-a)
res = a+b+6
if res > 3590:
res-=3590
return (res)
#mejor: te da el "mejor punto" del intervalo en *decimas de grados* (grados/10)
def mejor(i):
a=Z[int(m[i])]
b=(m[i]-int(m[i]))*(Z[int(m[i])+1]-a)
res = a+b+6
if res > 3590:
res-=3590
return (res)
def suma(a,b):
if (res := a + b) >= 3600:
res-=3600
return res
def resta(a,b):
if (res := a - b) <= 0:
res+=3600
return res
def ang(a,b):
if (a < b):
a,b = b,a
if (res := a -b) > 1800:
res=3600-res
return res
def ang_s(a,b):
s = 1
if (a < b):
a,b = b,a
s = -1
if (res := a -b) > 1800:
res=3600-res
return res*s
def imprimir(reg):
"""
dst = []
for i in range(0,dst):
dst.append(int(ang(reg[i+1],mejor[i])))
"""
a=ang(reg[1],mejor(0))
b=ang(reg[2],mejor(1))
c=ang(reg[3],mejor(2))
d=ang(reg[4],mejor(3))
e=ang(reg[5],mejor(4))
f=ang(reg[6],mejor(5))
g=ang(reg[7],mejor(6))
avgdst=(a+b+c+d+e+f+g)/7
cadena=""
cadena+="\n----------------------------------------"
cadena+="\nPLANETS FIT THE HOROSCOPE AT JD:"+str(reg[0])+"\n"
gc=""
if int(reg[0])>2299160:
gc=" (GC)"
cadena+='YEAR/MONTH/DAY='+str(reg[8])+'/ '+str(reg[9])+'/ '+str(reg[10])+gc+"\n"+"\n"
cadena+="\tPositions: J2000/ planet-Sun J2000/ CS:\n\n"
cadena+="\tSUN\tMOON\tSATURN\tJUPITER\tMARS\tVENUS\tMERCURY\n"
cadena+='\t{:.1f}'.format(reg[1]/10)
cadena+='\t{:.1f}'.format(reg[2]/10)
cadena+='\t{:.1f}'.format(reg[3]/10)
cadena+='\t{:.1f}'.format(reg[4]/10)
cadena+='\t{:.1f}'.format(reg[5]/10)
cadena+='\t{:.1f}'.format(reg[6]/10)
cadena+='\t{:.1f}'.format(reg[7]/10)+'\n'
cadena+='\t{:.1f}'.format(0.0)
cadena+='\t{:.1f}'.format(ang_s(reg[2],reg[1])/10)
cadena+='\t{:.1f}'.format(ang_s(reg[3],reg[1])/10)
cadena+='\t{:.1f}'.format(ang_s(reg[4],reg[1])/10)
cadena+='\t{:.1f}'.format(ang_s(reg[5],reg[1])/10)
cadena+='\t{:.1f}'.format(ang_s(reg[6],reg[1])/10)
cadena+='\t{:.1f}'.format(ang_s(reg[7],reg[1])/10)+'\n'
for i in range (1,8):
cadena+='\t'+zod(reg[i])
cadena+='\n\nAVERAGE DISTANCE FROM BEST POINTS:'
cadena+='\t{:.1f}'.format(avgdst/10) + ' deg'
cadena+='\n YEAR/MONTH/DAY=\t'+str(reg[8])+'/ '+str(reg[9])+'/ '+str(reg[10])+gc
cadena+="\n----------------------------------------"
return cadena
def limpiar(event):
infile = open('saludo','rt')
#infile = open('planetpos.dat','rt')
textarea = document.querySelector("#textarea")
textarea.value = infile.read()
runButton=document.getElementById("run")
runButton.removeAttribute("disabled")
dwnldButton=document.getElementById("save")
dwnldButton.setAttribute("disabled","true")
"""
for i in ["sun","moon","sat","jup","mars","venus","merc"]:
pos=document.querySelector("#i"+i)
pos.value="0.0"
pos=document.querySelector("#f"+i)
pos.value="0.0"
pos=document.querySelector("#b"+i)
pos.value="0.0"
nombre=document.querySelector("#nombre")
nombre.value=""
"""
infile.close()
async def horosweb(event):
runButton=document.getElementById("run")
runButton.setAttribute("value","Press 'New'")
runButton.setAttribute("disabled","true")
newButton=document.getElementById("new")
newButton.setAttribute("disabled","true")
dwnldButton=document.getElementById("save")
dwnldButton.setAttribute("disabled","true")
textarea = document.querySelector("#textarea")
#desde:
global h1
#h1 = [8,7,4,7,7,8,9]
#h1 = [6,3,11,1,11,9,10]
h1=[]
#hasta:
global h2
#h2 = [9,8,5,8,8,9,10]
#h2 = [11,4,12,2,12,11,11]
h2=[]
#mejor:
global m
#m = [8.5,7.5,4.5,7.5,7.5,8.5,9.5]
#m = [10.5,3.5,11.5,1.5,11.5,10.5,10.5]
m=[]
j=0
for i in ["sun","moon","sat","jup","mars","venus","merc"]:
pos=document.querySelector("#i"+i)
h1.append(float(pos.value))
pos=document.querySelector("#f"+i)
h2.append(float(pos.value))
pos=document.querySelector("#b"+i)
m.append(float(pos.value))
#zodiaco J2000:
global Z
Z = [310,560,920,1180,1370,1720,2150,2390,2660,2960,3260,3490,3900,4150]
#EMENDATIONE TEMPORUM:
emtemp=document.getElementById("emtemp")
if emtemp.checked==True:
for i in range(0,len(Z)):
Z[i]=Z[i]-100
#dopusk:
global D
D = 50
#esto se puede simplificar, pero no tengo tiempo:
sun_f = suma(resta(fin(0),resta(ini(0),D)),D)/2
moon_f = suma(resta(fin(1),resta(ini(1),D)),D)/2
saturn_f = suma(resta(fin(2),resta(ini(2),D)),D)/2
jupiter_f = suma(resta(fin(3),resta(ini(3),D)),D)/2
mars_f = suma(resta(fin(4),resta(ini(4),D)),D)/2
venus_f = suma(resta(fin(5),resta(ini(5),D)),D)/2
mercury_f = suma(resta(fin(6),resta(ini(6),D)),D)/2
sun_i = suma(resta(ini(0),D),sun_f)
moon_i = suma(resta(ini(1),D),moon_f)
saturn_i = suma(resta(ini(2),D),saturn_f)
jupiter_i = suma(resta(ini(3),D),jupiter_f)
mars_i = suma(resta(ini(4),D),mars_f)
venus_i = suma(resta(ini(5),D),venus_f)
mercury_i = suma(resta(ini(6),D),mercury_f)
cadena=""
cadena+=" ======= CONSTELLATION SCALE ===================\n"
cadena+=" 12=0-ARIES-1-TAURUS-2-GEMINI-3\n"
cadena+=" 3-CANCER-4-LEO-5-VIRGO-6\n"
cadena+=" 6-LIBRA-7-SCORPIO-8-SAGITTARIUS-9\n"
cadena+=" 9-CAPRICORN-10-AQUARIUS-11-PISCES-12=0\n\n"
cadena+=" --- HOROSCOPE ACCORDING TO CONSTELLATIONS SCALE: --\n"
cadena+="\tSUN\tMOON\tSATURN\tJUPITER\tMARS\tVENUS\tMERCURY\n"
cadena+='from:\t{:.1f}'.format(h1[0])
cadena+='\t{:.1f}'.format(h1[1])
cadena+='\t{:.1f}'.format(h1[2])
cadena+='\t{:.1f}'.format(h1[3])
cadena+='\t{:.1f}'.format(h1[4])
cadena+='\t{:.1f}'.format(h1[5])
cadena+='\t{:.1f}'.format(h1[6])+"\n"
cadena+='to:\t{:.1f}'.format(h2[0])
cadena+='\t{:.1f}'.format(h2[1])
cadena+='\t{:.1f}'.format(h2[2])
cadena+='\t{:.1f}'.format(h2[3])
cadena+='\t{:.1f}'.format(h2[4])
cadena+='\t{:.1f}'.format(h2[5])
cadena+='\t{:.1f}'.format(h2[6])+"\n"
cadena+='point:\t{:.1f}'.format(m[0])
cadena+='\t{:.1f}'.format(m[1])
cadena+='\t{:.1f}'.format(m[2])
cadena+='\t{:.1f}'.format(m[3])
cadena+='\t{:.1f}'.format(m[4])
cadena+='\t{:.1f}'.format(m[5])
cadena+='\t{:.1f}'.format(m[6])+"\n"
cadena+="===================================================\n\n"
cadena+=" == CSN ON ECLIPTIC J2000 (modified 17.11.2007):==\n\n"
cadena+=' <31deg> ARIES <56deg> TAURUS <92deg> GEMINI\n'
cadena+=' <118deg> CANCER <137deg> LEO <172deg> VIRGO\n'
cadena+=' <215deg> LIBRA <239deg> SCORPIO\n'
cadena+=' <266deg> SAGITTARIUS <296deg> CAPRICORN\n'
cadena+=' <326deg> AQUARIUS <349deg> PISCES\n\n'
cadena+="---- HOROSCOPE ON ECLIPTIC J2000 (IN DEGREES): -----\n"
cadena+="\tSUN\tMOON\tSATURN\tJUPITER\tMARS\tVENUS\tMERCURY\n"
cadena+='from:\t{:.1f}'.format(ini(0)/10)
cadena+='\t{:.1f}'.format(ini(1)/10)
cadena+='\t{:.1f}'.format(ini(2)/10)
cadena+='\t{:.1f}'.format(ini(3)/10)
cadena+='\t{:.1f}'.format(ini(4)/10)
cadena+='\t{:.1f}'.format(ini(5)/10)
cadena+='\t{:.1f}'.format(ini(6)/10)+"\n"
cadena+='to:\t{:.1f}'.format(fin(0)/10)
cadena+='\t{:.1f}'.format(fin(1)/10)
cadena+='\t{:.1f}'.format(fin(2)/10)
cadena+='\t{:.1f}'.format(fin(3)/10)
cadena+='\t{:.1f}'.format(fin(4)/10)
cadena+='\t{:.1f}'.format(fin(5)/10)
cadena+='\t{:.1f}'.format(fin(6)/10)+"\n"
cadena+="================================================================\n\n\n"
cadena+=" RESULTS OF CALCULATIONS\n"
cadena+=" From year -10000 to year +1950\n"
cadena+=" (with tolerance = "+str(D/10)+" degrees)\n"
infile = bz2.open('plpos.bz2','rt')
#infile = gzip.open('planetpos.dat.gz','rt')
textarea.value = cadena
txt_area=pydom['#textarea']
txt_area.style["color"] = "orange"
cont=0
cont2=0
rega=[-1931441,113,3031,2782,1612,3494,3260,3467,-10000,1,2]
for line in infile:
reg=[int(x) for x in line.strip().split('\t')]
for j in range(len(reg)):
reg[j]+=rega[j]
if ang(reg[1],sun_i) <= sun_f and \
ang(reg[2],moon_i) <= moon_f and \
ang(reg[3],saturn_i) <= saturn_f and \
ang(reg[4],jupiter_i) <= jupiter_f and \
ang(reg[5],mars_i) <= mars_f and \
ang(reg[6],venus_i) <= venus_f and \
ang(reg[7],mercury_i) <= mercury_f:
cadena+=imprimir(reg)
cont+=1
if cont==20000:
cont=0
simbolos=["|","/","—","\\"]
simbolo=simbolos[cont2]
cont2+=1
if cont2==4:
cont2=0
textarea.value = cadena + "\n\n" + simbolo + "Searching " + str(int(reg[8]/100)*100) + "'s"
textarea.scrollTop = textarea.scrollHeight
await asyncio.sleep(0)
rega=reg
cadena+="\n\n\tEND OF CALCULATIONS."
textarea.value = cadena
textarea.scrollTop = textarea.scrollHeight
txt_area.style["color"] = "white"
newButton.removeAttribute("disabled")
dwnldButton.removeAttribute("disabled")
infile.close()