-
Notifications
You must be signed in to change notification settings - Fork 11
/
revolutions.py
executable file
·158 lines (119 loc) · 3.61 KB
/
revolutions.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
import astrology
import mtexts
import transits
import util
class Revolutions:
SOLAR = 0
LUNAR = 1
MERCURY = 2
VENUS = 3
MARS = 4
JUPITER = 5
SATURN = 6
def __init__(self):
self.t = [0, 0, 0, 0, 0, 0]
def compute(self, typ, by, bm, bd, chrt):
if typ == Revolutions.SOLAR:
year = by
if bm > chrt.time.month or (bm == chrt.time.month and bd > chrt.time.day):
year+= 1
month = chrt.time.month
day = chrt.time.day
trans = transits.Transits()
trans.month(year, month, chrt, astrology.SE_SUN)
# if not found => checking previous or next month
if len(trans.transits) == 0:
if day < 4:
year, month = util.decrMonth(year, month)
else:
year, month = util.incrMonth(year, month)
trans = transits.Transits()
trans.month(year, month, chrt, astrology.SE_SUN)
if len(trans.transits) > 0:
self.createRevolution(year, month, trans)
return True
return False
elif typ == Revolutions.LUNAR:
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_MOON)
if len(trans.transits) > 0:
second = False
if bd > trans.transits[0].day:
# There can be more than one lunar in a month!!
if len(trans.transits) > 1:
if bd > trans.transits[1].day:
by, bm = util.incrMonth(by, bm)
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_MOON)
else:
second = True
else:
by, bm = util.incrMonth(by, bm)
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_MOON)
if len(trans.transits) > 0:
if second:
self.createRevolution(by, bm, trans, 1)
else:
self.createRevolution(by, bm, trans)
return True
return False
elif typ == Revolutions.MERCURY:
for i in range(14):
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_MERCURY)
if len(trans.transits) > 0:
if not (i == 0 and bd > trans.transits[0].day):
self.createRevolution(by, bm, trans)
return True
by, bm = util.incrMonth(by, bm)
return False
elif typ == Revolutions.VENUS:
for i in range(16):
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_VENUS)
if len(trans.transits) > 0:
if not (i == 0 and bd > trans.transits[0].day):
self.createRevolution(by, bm, trans)
return True
by, bm = util.incrMonth(by, bm)
return False
elif typ == Revolutions.MARS:
for i in range(26):
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_MARS)
if len(trans.transits) > 0:
if not (i == 0 and bd > trans.transits[0].day):
self.createRevolution(by, bm, trans)
return True
by, bm = util.incrMonth(by, bm)
return False
elif typ == Revolutions.JUPITER:
for i in range(12*12):
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_JUPITER)
if len(trans.transits) > 0:
if not (i == 0 and bd > trans.transits[0].day):
self.createRevolution(by, bm, trans)
return True
by, bm = util.incrMonth(by, bm)
return False
elif typ == Revolutions.SATURN:
for i in range(30*12):
trans = transits.Transits()
trans.month(by, bm, chrt, astrology.SE_SATURN)
if len(trans.transits) > 0:
if not (i == 0 and bd > trans.transits[0].day):
self.createRevolution(by, bm, trans)
return True
by, bm = util.incrMonth(by, bm)
return False
return False
def createRevolution(self, year, month, trans, num = 0):
self.t[0] = year
self.t[1] = month
self.t[2] = trans.transits[num].day
h, m, s = util.decToDeg(trans.transits[num].time)
self.t[3] = h
self.t[4] = m
self.t[5] = s