-
Notifications
You must be signed in to change notification settings - Fork 11
/
regiomontanpd.py
executable file
·388 lines (313 loc) · 12.1 KB
/
regiomontanpd.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
372
373
374
375
376
377
378
379
380
import math
import astrology
import primdirs
import regiocampbasepd
import planets
import chart
import fortune
import houses
import secmotion
import util
class RegiomontanPD(regiocampbasepd.RegioCampBasePD):
'Implements Regiomontanian Primary Directions'
def __init__(self, chrt, options, pdrange, direction, abort):
regiocampbasepd.RegioCampBasePD.__init__(self, chrt, options, pdrange, direction, abort)
def toPlanet(self, mundane, idprom, idprom2, lonprom, latprom, raprom, declprom, promasp, sig, sigasp, calcsecmotion=True, paspect=chart.Chart.NONE):
plsig = self.chart.planets.planets[sig]
aspect = chart.Chart.Aspects[sigasp]
SINISTER = 0
DEXTER = 1
for k in range(DEXTER+1):
if k == DEXTER:
if sigasp == chart.Chart.CONJUNCTIO or sigasp == chart.Chart.OPPOSITIO:
break
aspect *= -1
wprom, wsig = 0.0, 0.0
if mundane or self.options.subzodiacal == primdirs.PrimDirs.SZSIGNIFICATOR or self.options.subzodiacal == primdirs.PrimDirs.SZBOTH: #mundane or zod with sig's latitude
wsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.W]
if sigasp == chart.Chart.CONJUNCTIO:
val = math.tan(math.radians(declprom))*math.tan(math.radians(plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.POLE]))
if math.fabs(val) > 1.0:
continue
qprom = math.degrees(math.asin(val))
if plsig.eastern:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)#
else:
if mundane:
wsig += aspect
wsig = util.normalize(wsig)
med = math.fabs(self.ramc-wsig)
if med > 180.0:
med = 360.0-med
icd = math.fabs(self.raic-wsig)
if icd > 180.0:
icd = 360.0-icd
mdsig = med
if icd < med:
mdsig = icd
val = math.tan(math.radians(declprom))*math.tan(math.radians(self.chart.place.lat))*math.sin(math.radians(mdsig))
if math.fabs(val) > 1.0:
continue
qprom = math.degrees(math.asin(val))
eastern = True
if self.ramc > self.raic:
if wsig > self.raic and wsig < self.ramc:
eastern = False
else:
if (wsig > self.raic and wsig < 360.0) or (wsig < self.ramc and wsig > 0.0):
eastern = False
if eastern:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)#
else:#zodiacal with sig's latitude
lonsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]+aspect
lonsig = util.normalize(lonsig)
latsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LAT]
if self.options.bianchini:
val = self.getBianchini(latsig, chart.Chart.Aspects[sigasp])
if math.fabs(val) > 1.0:
continue
latsig = math.degrees(math.asin(val))
ok, wsig, spole, seastern, md, umd = self.getZodW(plsig, lonsig, latsig)
if not ok:
continue
ok, wprom, ppole, seastern, md, umd = self.getZodW(plsig, lonprom, latprom, spole, seastern)
if not ok:
continue
else: #zodiacal
lonsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]+aspect
lonsig = util.normalize(lonsig)
ok, wsig, spole, seastern, md, umd = self.getZodW(plsig, lonsig, 0.0)
if not ok:
continue
ok, wprom, ppole, seastern, md, umd = self.getZodW(plsig, lonprom, latprom, spole, seastern)
if not ok:
continue
arc = wprom-wsig
ok = True
if idprom == astrology.SE_MOON and idprom2 == primdirs.PrimDir.NONE and self.options.pdsecmotion and calcsecmotion:
if paspect == chart.Chart.NONE:
for itera in range(self.options.pdsecmotioniter+1):
ok, arc = self.calcArcWithSM(mundane, idprom, latprom, sig, sigasp, aspect, arc)
if not ok:
break
else:
for itera in range(self.options.pdsecmotioniter+1):
ok, arc = self.calcArcWithSM2(idprom, promasp, sig, paspect, arc)
if not ok:
break
if ok:
self.create(mundane, idprom, idprom2, sig, promasp, sigasp, arc)
def toHCs(self, mundane, idprom, raprom, declprom, aspect, asp=0.0):
'''Calculates directions of the Promissor to intermediate house cusps'''
#aspects of proms to HCs in Zodiacal!?
ID = 0
W = 1
MD = 2
UMD = 3
EASTERN = 4
#Regiomontan: W of housecusps (equator)
HL = 30.0
HC11 = util.normalize(self.ramc+HL)
HC12 = util.normalize(HC11+HL)
HC2 = util.normalize(HC12+2*HL)
HC3 = util.normalize(HC2+HL)
HC5 = util.normalize(self.raic+HL)
HC6 = util.normalize(HC5+HL)
HC8 = util.normalize(HC6+2*HL)
HC9 = util.normalize(HC8+HL)
#housecusps
hcps = ((primdirs.PrimDir.HC2, HC2, 2*HL, False, True), (primdirs.PrimDir.HC3, HC3, HL, False, True), (primdirs.PrimDir.HC5, HC5, HL, False, False), (primdirs.PrimDir.HC6, HC6, 2*HL, False, False), (primdirs.PrimDir.HC8, HC8, 2*HL, True, False), (primdirs.PrimDir.HC9, HC9, HL, True, False), (primdirs.PrimDir.HC11, HC11, HL, True, True), (primdirs.PrimDir.HC12, HC12, 2*HL, True, True))
pl = self.chart.planets.planets[0]
for h in range(len(hcps)):
#get zd of HC
zdsig = pl.getZD(hcps[h][MD], self.chart.place.lat, 0.0, hcps[h][UMD])
val = math.sin(math.radians(self.chart.place.lat))*math.sin(math.radians(zdsig))
if math.fabs(val) > 1.0:
continue
polesig = math.degrees(math.asin(val))
val = math.tan(math.radians(declprom))*math.tan(math.radians(polesig))
if math.fabs(val) > 1.0:
continue
qprom = math.degrees(math.asin(val))
wprom = 0.0
if hcps[h][EASTERN]:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)
arc = wprom-hcps[h][W]
ok = True
if idprom == astrology.SE_MOON and self.options.pdsecmotion:
for itera in range(self.options.pdsecmotioniter+1):
ok, arc = self.calcHArcWithSM(mundane, idprom, h, hcps, arc, aspect, asp)
if not ok:
break
if ok:
self.create(mundane, idprom, primdirs.PrimDir.NONE, hcps[h][ID], aspect, chart.Chart.CONJUNCTIO, arc)
def calcMP(self, ra, decl, pl):
eastern = True
if self.ramc > self.raic:
if ra > self.raic and ra < self.ramc:
eastern = False
else:
if (ra > self.raic and ra < 360.0) or (ra < self.ramc and ra > 0.0):
eastern = False
med = math.fabs(self.ramc-ra)
if med > 180.0:
med = 360.0-med
icd = math.fabs(self.raic-ra)
if icd > 180.0:
icd = 360.0-icd
md = med
umd = True
if icd < med:
md = icd
umd = False
#zd
zd = pl.getZD(md, self.chart.place.lat, decl, umd)
#pole
val = math.sin(math.radians(self.chart.place.lat))*math.sin(math.radians(zd))
if math.fabs(val) > 1.0:
return False, 0.0
pole = math.degrees(math.asin(val))
#Q
val = math.tan(math.radians(decl))*math.tan(math.radians(pole))
if math.fabs(val) > 1.0:
return False, 0.0
Q = math.degrees(math.asin(val))
#W
W = 0.0
if eastern:
W = ra-Q
else:
W = ra+Q
return True, util.normalize(W)
#####################################Moon's SecMotion
def calcArcWithSM(self, mundane, idprom, latprom, sig, sigasp, aspect, arc):
sm = secmotion.SecMotion(self.chart.time, self.chart.place, idprom, arc, self.chart.place.lat, self.chart.houses.ascmc2, self.options.topocentric)
lonprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]
raprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.RA]
declprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.DECL]
if not mundane and self.options.subzodiacal != primdirs.PrimDirs.SZPROMISSOR and self.options.subzodiacal != primdirs.PrimDirs.SZBOTH:
raprom, declprom, distprom = swisseph.cotrans(lonprom, 0.0, 1.0, -self.chart.obl[0])
plsig = self.chart.planets.planets[sig]
wprom, wsig = 0.0, 0.0
if mundane or self.options.subzodiacal == primdirs.PrimDirs.SZSIGNIFICATOR or self.options.subzodiacal == primdirs.PrimDirs.SZBOTH: #mundane or zod with sig's latitude
wsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.W]
if sigasp == chart.Chart.CONJUNCTIO:
val = math.tan(math.radians(declprom))*math.tan(math.radians(plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.POLE]))
if math.fabs(val) > 1.0:
return False, 0.0
qprom = math.degrees(math.asin(val))
if plsig.eastern:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)#
else:
if mundane:
wsig += aspect
wsig = util.normalize(wsig)
med = math.fabs(self.ramc-wsig)
if med > 180.0:
med = 360.0-med
icd = math.fabs(self.raic-wsig)
if icd > 180.0:
icd = 360.0-icd
mdsig = med
if icd < med:
mdsig = icd
val = math.tan(math.radians(declprom))*math.tan(math.radians(self.chart.place.lat))*math.sin(math.radians(mdsig))
if math.fabs(val) > 1.0:
return False, 0.0
qprom = math.degrees(math.asin(val))
eastern = True
if self.ramc > self.raic:
if wsig > self.raic and wsig < self.ramc:
eastern = False
else:
if (wsig > self.raic and wsig < 360.0) or (wsig < self.ramc and wsig > 0.0):
eastern = False
if eastern:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)#
else:#zodiacal with sig's latitude
lonsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]+aspect
lonsig = util.normalize(lonsig)
latsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LAT]
if self.options.bianchini:
val = self.getBianchini(latsig, chart.Chart.Aspects[sigasp])
if math.fabs(val) > 1.0:
return False, 0.0
latsig = math.degrees(math.asin(val))
ok, wsig, spole, seastern, md, umd = self.getZodW(plsig, lonsig, latsig)
if not ok:
return False, 0.0
ok, wprom, ppole, seastern, md, umd = self.getZodW(plsig, lonprom, latprom, spole, seastern)
if not ok:
return False, 0.0
else: #zodiacal
lonsig = plsig.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]+aspect
lonsig = util.normalize(lonsig)
ok, wsig, spole, seastern, md, umd = self.getZodW(plsig, lonsig, 0.0)
if not ok:
return False, 0.0
ok, wprom, ppole, seastern, md, umd = self.getZodW(plsig, lonprom, latprom, spole, seastern)
if not ok:
return False, 0.0
arc = wprom-wsig
return True, arc
def calcHArcWithSM(self, mundane, idprom, h, hcps, arc, aspect, asp=0.0):
sm = secmotion.SecMotion(self.chart.time, self.chart.place, idprom, arc, self.chart.place.lat, self.chart.houses.ascmc2, self.options.topocentric)
lonprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LONG]
pllat = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.LAT]
raprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.RA]
declprom = sm.planet.speculums[primdirs.PrimDirs.REGIOSPECULUM][planets.Planet.DECL]
if not mundane:
lonprom += asp
lonprom = util.normalize(lonprom)
latprom, raprom, declprom = 0.0, 0.0, 0.0
if self.options.subzodiacal == primdirs.PrimDirs.SZPROMISSOR or self.options.subzodiacal == primdirs.PrimDirs.SZBOTH:
if self.options.bianchini:
val = self.getBianchini(pllat, chart.Chart.Aspects[aspect])
if math.fabs(val) > 1.0:
return False, 0.0
latprom = math.degrees(math.asin(val))
else:
latprom = pllat
#calc real(wahre)ra
# raprom, declprom = util.getRaDecl(lonprom, latprom, self.chart.obl[0])
raprom, declprom, dist = swisseph.cotrans(lonprom, latprom, 1.0, -self.chart.obl[0])
else:
raprom, declprom, distprom = swisseph.cotrans(lonprom, 0.0, 1.0, -self.chart.obl[0])
ID = 0
W = 1
MD = 2
UMD = 3
EASTERN = 4
pl = self.chart.planets.planets[0]
#get zd of HC
zdsig = pl.getZD(hcps[h][MD], self.chart.place.lat, 0.0, hcps[h][UMD])
val = math.sin(math.radians(self.chart.place.lat))*math.sin(math.radians(zdsig))
if math.fabs(val) > 1.0:
return False, 0.0
polesig = math.degrees(math.asin(val))
val = math.tan(math.radians(declprom))*math.tan(math.radians(polesig))
if math.fabs(val) > 1.0:
return False, 0.0
qprom = math.degrees(math.asin(val))
wprom = 0.0
if hcps[h][EASTERN]:
wprom = raprom-qprom
else:
wprom = raprom+qprom
wprom = util.normalize(wprom)
return True, wprom-hcps[h][W]