-
Notifications
You must be signed in to change notification settings - Fork 11
/
fixstars.py
executable file
·59 lines (47 loc) · 1.58 KB
/
fixstars.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
import astrology
import swisseph
import sys
class FixStars:
"""Calculates the positions of the fixstars"""
NAME = 0
NOMNAME = 1
LON = 2
LAT = 3
RA = 4
DECL = 5
def __init__(self, tjd_ut, flag, names, obl):
self.data = []
i = 0
for k in names:
self.data.append(['', '', 0.0, 0.0, 0.0, 0.0])
dat = swisseph.fixstar_ut(','+k, tjd_ut, flag)[0]
nam = k
nomnam = ''
DELIMITER = ','
if nam.find(DELIMITER) != -1:
snam = nam.split(DELIMITER)
nam = snam[0].strip()
nomnam = snam[1].strip()
self.data[i][FixStars.NAME] = nam
self.data[i][FixStars.NOMNAME] = nam
self.data[i][FixStars.LON] = dat[0]
self.data[i][FixStars.LAT] = dat[1]
ra, decl, dist = swisseph.cotrans(dat[0], dat[1], 1.0, -obl)
self.data[i][FixStars.RA] = ra
self.data[i][FixStars.DECL] = decl
i += 1
self.sort()
def sort(self):
num = len(self.data)
self.mixed = []
for i in range(num):
self.mixed.append(i)
for i in range(num):
for j in range(num-1):
if (self.data[j][FixStars.LON] > self.data[j+1][FixStars.LON]):
tmp = self.data[j][:]
self.data[j] = self.data[j+1][:]
self.data[j+1] = tmp[:]
tmp = self.mixed[j]
self.mixed[j] = self.mixed[j+1]
self.mixed[j+1] = tmp