-
Notifications
You must be signed in to change notification settings - Fork 11
/
syzygy.py
executable file
·285 lines (236 loc) · 9.9 KB
/
syzygy.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
import astrology
import chart
import houses
import planets
import options
import util
import swisseph
class Syzygy:
LON = 0
LAT = 1
RA = 2
DECL = 3
#for topical almutens
TOPICALDEFAULT = 0
TOPICALCONIUNCTIO = 1
TOPICALOPPOSITIO = 2
TOPICALOPPOSITIORADIX = 3
TOPICALMOON = 4
def __init__(self, chrt):
self.time = chrt.time
self.lon = chrt.planets.planets[astrology.SE_MOON].data[planets.Planet.LONG]
self.flags = astrology.SEFLG_SPEED+astrology.SEFLG_SWIEPH
#for topical almutens
self.lons = []
if not chrt.time.bc:
lonsun = chrt.planets.planets[astrology.SE_SUN].data[planets.Planet.LONG]
lonmoon = chrt.planets.planets[astrology.SE_MOON].data[planets.Planet.LONG]
d, m, s = util.decToDeg(lonsun)
lonsun = d+m/60.0+s/3600.0
d, m, s = util.decToDeg(lonmoon)
lonmoon = d+m/60.0+s/3600.0
diff = lonmoon-lonsun
self.newmoon, self.ready = self.isNewMoon(diff)
if not self.ready:
ok, self.time, self.ready = self.getDateHour(self.time, chrt.place, self.newmoon)
if not self.ready:
ok, self.time, self.ready = self.getDateMinute(self.time, chrt.place, self.newmoon)
if not self.ready:
ok, self.time, self.ready = self.getDateSecond(self.time, chrt.place, self.newmoon)
hses = houses.Houses(self.time.jd, 0, chrt.place.lat, chrt.place.lon, chrt.options.hsys, chrt.obl[0], chrt.options.ayanamsha, chrt.ayanamsha)
moon = planets.Planet(self.time.jd, astrology.SE_MOON, self.flags, chrt.place.lat, hses.ascmc2)
if self.newmoon:
self.lon = moon.data[planets.Planet.LONG]
else:
if chrt.options.syzmoon == options.Options.MOON:
self.lon = moon.data[planets.Planet.LONG]
elif chrt.options.syzmoon == options.Options.ABOVEHOR:
if moon.abovehorizon:
self.lon = moon.data[planets.Planet.LONG]
else:
sun = planets.Planet(self.time.jd, astrology.SE_SUN, self.flags)
self.lon = sun.data[planets.Planet.LONG]
else:
moon = planets.Planet(self.time.jd, astrology.SE_MOON, self.flags, chrt.place.lat, chrt.houses.ascmc2)
if moon.abovehorizon:
self.lon = moon.data[planets.Planet.LONG]
else:
sun = planets.Planet(self.time.jd, astrology.SE_SUN, self.flags)
self.lon = sun.data[planets.Planet.LONG]
ra, decl, dist = swisseph.cotrans(self.lon, 0.0, 1.0, -chrt.obl[0])
self.speculum = [self.lon, 0.0, ra, decl]
#the other syzygy (i.e. if the syzygy was conjunction then calculate the opposition and vice versa)
self.lon2 = chrt.planets.planets[astrology.SE_MOON].data[planets.Planet.LONG]
if not chrt.time.bc:
self.time2 = self.time
ok, self.time2, self.ready2 = self.getDateHour(self.time2, chrt.place, not self.newmoon)
if not self.ready2:
ok, self.time2, self.ready2 = self.getDateMinute(self.time2, chrt.place, not self.newmoon)
if not self.ready2:
ok, self.time2, self.ready2 = self.getDateSecond(self.time2, chrt.place, not self.newmoon)
hses2 = houses.Houses(self.time2.jd, 0, chrt.place.lat, chrt.place.lon, chrt.options.hsys, chrt.obl[0], chrt.options.ayanamsha, chrt.ayanamsha)
moon2 = planets.Planet(self.time2.jd, astrology.SE_MOON, self.flags, chrt.place.lat, hses2.ascmc2)
if not self.newmoon:
self.lon2 = moon2.data[planets.Planet.LONG]
else:
if chrt.options.syzmoon == options.Options.MOON:
self.lon2 = moon2.data[planets.Planet.LONG]
elif chrt.options.syzmoon == options.Options.ABOVEHOR:
if moon2.abovehorizon:
self.lon2 = moon2.data[planets.Planet.LONG]
else:
sun2 = planets.Planet(self.time2.jd, astrology.SE_SUN, self.flags)
self.lon2 = sun2.data[planets.Planet.LONG]
else:
moon2 = planets.Planet(self.time2.jd, astrology.SE_MOON, self.flags, chrt.place.lat, chrt.houses.ascmc2)
if moon2.abovehorizon:
self.lon2 = moon2.data[planets.Planet.LONG]
else:
sun2 = planets.Planet(self.time2.jd, astrology.SE_SUN, self.flags)
self.lon2 = sun2.data[planets.Planet.LONG]
ra2, decl2, dist2 = swisseph.cotrans(self.lon2, 0.0, 1.0, -chrt.obl[0])
self.speculum2 = [self.lon2, 0.0, ra2, decl2]
#for topical almutens
self.lons.append(self.lon)#Default
if self.newmoon: #Conjunction
self.lons.append(self.lon)
else:
self.lons.append(self.lon2)
#Moon in chart of Syzygy
hses = houses.Houses(self.time.jd, 0, chrt.place.lat, chrt.place.lon, chrt.options.hsys, chrt.obl[0], chrt.options.ayanamsha, chrt.ayanamsha)
moonSyz = planets.Planet(self.time.jd, astrology.SE_MOON, self.flags, chrt.place.lat, hses.ascmc2)
hses2 = houses.Houses(self.time2.jd, 0, chrt.place.lat, chrt.place.lon, chrt.options.hsys, chrt.obl[0], chrt.options.ayanamsha, chrt.ayanamsha)
moonSyz2 = planets.Planet(self.time2.jd, astrology.SE_MOON, self.flags, chrt.place.lat, hses2.ascmc2)
if not self.newmoon: #Opposition
if moonSyz.abovehorizon:
self.lons.append(moonSyz.data[planets.Planet.LONG])
else:
sun = planets.Planet(self.time.jd, astrology.SE_SUN, self.flags)
self.lons.append(sun.data[planets.Planet.LONG])
else:
if moonSyz2.abovehorizon:
self.lons.append(moonSyz2.data[planets.Planet.LONG])
else:
sun2 = planets.Planet(self.time2.jd, astrology.SE_SUN, self.flags)
self.lons.append(sun2.data[planets.Planet.LONG])
if not self.newmoon: #OppositionRadix
moon = planets.Planet(self.time.jd, astrology.SE_MOON, self.flags, chrt.place.lat, chrt.houses.ascmc2)
if moon.abovehorizon:
self.lons.append(moon.data[planets.Planet.LONG])
else:
sun = planets.Planet(self.time.jd, astrology.SE_SUN, self.flags)
self.lons.append(sun.data[planets.Planet.LONG])
else:
moon = planets.Planet(self.time2.jd, astrology.SE_MOON, self.flags, chrt.place.lat, chrt.houses.ascmc2)
if moon.abovehorizon:
self.lons.append(moon.data[planets.Planet.LONG])
else:
sun = planets.Planet(self.time.jd, astrology.SE_SUN, self.flags)
self.lons.append(sun.data[planets.Planet.LONG])
if not self.newmoon: #Opposition Moon
self.lons.append(moonSyz.data[planets.Planet.LONG])
else:
self.lons.append(moonSyz2.data[planets.Planet.LONG])
def isNewMoon(self, diff):
newmoon = True
ready = False
if diff == 0.0:
newmoon = True
ready = True
elif diff == 180.0 or diff == -180.0:
newmoon = False
ready = True
elif diff < 0.0:
if diff < -180.0:
newmoon = True
else:
newmoon = False
elif diff > 0.0:
if diff > 180.0:
newmoon = False
else:
newmoon = True
return newmoon, ready
def getDateHour(self, tim, place, newmoonorig):
while True:
h, m, s = util.decToDeg(tim.time)
y, mo, d = tim.year, tim.month, tim.day
h -= 1
if h < 0:
h = 23
y, mo, d = util.decrDay(y, mo, d)
if y == 0:
y = 1
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
return True, tim, True
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
sun = planets.Planet(tim.jd, astrology.SE_SUN, self.flags)
moon = planets.Planet(tim.jd, astrology.SE_MOON, self.flags)
lonsun = sun.data[planets.Planet.LONG]
lonmoon = moon.data[planets.Planet.LONG]
d, m, s = util.decToDeg(lonsun)
lonsun = d+m/60.0+s/3600.0
d, m, s = util.decToDeg(lonmoon)
lonmoon = d+m/60.0+s/3600.0
diff = lonmoon-lonsun
newmoon, ready = self.isNewMoon(diff)
if newmoon != newmoonorig or ready:
return True, tim, ready
return False, tim
def getDateMinute(self, tim, place, newmoonorig):
h, m, s = util.decToDeg(tim.time)
y, mo, d = tim.year, tim.month, tim.day
h += 1
if h > 23:
h = 0
y, mo, d = util.incrDay(y, mo, d)
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
while True:
h, m, s = util.decToDeg(tim.time)
y, mo, d = tim.year, tim.month, tim.day
y, mo, d, h, m = util.subtractMins(y, mo, d, h, m, 1)
if y == 0:
y = 1
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
return True, tim, True
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
sun = planets.Planet(tim.jd, astrology.SE_SUN, self.flags)
moon = planets.Planet(tim.jd, astrology.SE_MOON, self.flags)
lonsun = sun.data[planets.Planet.LONG]
lonmoon = moon.data[planets.Planet.LONG]
d, m, s = util.decToDeg(lonsun)
lonsun = d+m/60.0+s/3600.0
d, m, s = util.decToDeg(lonmoon)
lonmoon = d+m/60.0+s/3600.0
diff = lonmoon-lonsun
newmoon, ready = self.isNewMoon(diff)
if newmoon != newmoonorig or ready:
return True, tim, ready
return False, tim
def getDateSecond(self, tim, place, newmoonorig):
h, m, s = util.decToDeg(tim.time)
y, mo, d = tim.year, tim.month, tim.day
y, mo, d, h, m = util.addMins(y, mo, d, h, m, 1)
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
while True:
h, m, s = util.decToDeg(tim.time)
y, mo, d = tim.year, tim.month, tim.day
y, mo, d, h, m, s = util.subtractSecs(y, mo, d, h, m, s, 1)
if y == 0:
y = 1
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
return True, tim, True
tim = chart.event.DateTime(y, mo, d, h, m, s, False, tim.cal, chart.event.DateTime.GREENWICH, True, 0, 0, False, place, False)
sun = planets.Planet(tim.jd, astrology.SE_SUN, self.flags)
moon = planets.Planet(tim.jd, astrology.SE_MOON, self.flags)
lonsun = sun.data[planets.Planet.LONG]
lonmoon = moon.data[planets.Planet.LONG]
d, m, s = util.decToDeg(lonsun)
lonsun = d+m/60.0+s/3600.0
d, m, s = util.decToDeg(lonmoon)
lonmoon = d+m/60.0+s/3600.0
diff = lonmoon-lonsun
newmoon, ready = self.isNewMoon(diff)
if newmoon != newmoonorig or ready:
return True, tim, ready
return False, tim