-
Notifications
You must be signed in to change notification settings - Fork 11
/
secdir.py
executable file
·89 lines (69 loc) · 2 KB
/
secdir.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
import astrology
import chart
import mtexts
import util
class SecDir:
def __init__(self, chrt, age, direct, soltime):
self.chart = chrt
self.age = age
self.direct = direct
self.soltime = soltime
def compute(self):
y = self.chart.time.year
m = self.chart.time.month
d = self.chart.time.day
hour = self.chart.time.hour
minute = self.chart.time.minute
second = self.chart.time.second
hr = 0.0
#GMT to LocalMean
t = (self.chart.place.deglon+self.chart.place.minlon/60.0)*4 #long * 4min
meantime = 0.0
if self.chart.place.east:
meantime = self.chart.time.time+t/60.0
else:
meantime = self.chart.time.time-t/60.0
#check over/underflow
HOURSPERDAY = 24.0
if meantime >= HOURSPERDAY:
meantime -= HOURSPERDAY
y, m, d = util.incrDay(y, m, d)
elif meantime < 0.0:
meantime += HOURSPERDAY
y, m, d = util.decrDay(y, m, d)
if self.soltime:
calflag = astrology.SE_GREG_CAL
if self.chart.time.cal == chart.Time.JULIAN:
calflag = astrology.SE_JUL_CAL
yt = y
if self.chart.time.bc:
yt = -y
jdmean = swisseph.julday(yt, m, d, meantime, calflag)
#Get jdapp
ret, te, serr = swisseph.time_equ(jdmean)
jdapp = jdmean-te
y, m, d, hr = swisseph.revjul(jdapp, calflag)
hour,minute,second = util.decToDeg(hr)
# print '%d:%02d:%02d' % (hour,minute,second)
else:
hour,minute,second = util.decToDeg(meantime)
for i in range(self.age):
if self.direct:
y, m, d = util.incrDay(y, m, d)
else:
y, m, d = util.decrDay(y, m, d)
if self.soltime:
#Back to meantime on the last day
yt = y
if self.chart.time.bc:
yt = -y
calflag = astrology.SE_GREG_CAL
if self.chart.time.cal == chart.Time.JULIAN:
calflag = astrology.SE_JUL_CAL
jdapp = swisseph.julday(yt, m, d, hr, calflag)
ret, te, serr = swisseph.time_equ(jdapp)
jdmean = jdapp+te
y, m, d, hr = swisseph.revjul(jdmean, calflag)
hour,minute,second = util.decToDeg(hr)
# print '%d:%02d:%02d' % (hour,minute,second)
return y, m, d, hour, minute, second