-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoi.py
104 lines (84 loc) · 3.32 KB
/
poi.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
'''Points of Interest
This is a collection of interesting (to me, at least) things in the sky,
some of which are not built-in to ephem. They are stored here for easy use
in other scripts, particularly in today.py.
'''
import ephem
# Celestial Poles
north_pole = ephem.FixedBody()
north_pole._ra = 0
north_pole._dec = '90.'
south_pole = ephem.FixedBody()
south_pole._ra = 0
south_pole._dec = '-90.'
# The center of the galaxy
galactic_center = ephem.FixedBody()
galactic_center._ra = '17:45:40.04'
galactic_center._dec = '-29:00:28.1'
# The magellanic clouds
large_magellanic_cloud = ephem.FixedBody()
large_magellanic_cloud._ra = '05:23:34.5'
large_magellanic_cloud._dec = '-69:45:22'
small_magellanic_cloud = ephem.FixedBody()
small_magellanic_cloud._ra = '00:52:44.8'
small_magellanic_cloud._dec = '-72:49:43'
# The center of the Southern Cross
# Constellation contains star Mimosa, which ephem knows about
crux = ephem.FixedBody()
crux._ra = '12:30:00.0'
crux._dec = '-60:00:00.0'
coalsack = ephem.FixedBody()
coalsack._ra = '12:50:00'
coalsack._dec = '-62:30:00'
class Asterism(dict):
"""An asterism is a group of stars (or other fixed bodies).
This call will treat a collection of fixed bodies as a group
so that compute calls need only happen once for the group, and
a check can be done to see if the entire asterism is above the
horizon.
"""
def compute(self, location):
for body in self.itervalues():
body.compute(location)
def is_up(self):
for body in self.itervalues():
if body.alt < 0:
return False
return True
def add_stars(self, *args):
"""From a list of strings, add the given stars to the asterism.
These stars must be in epehem's database.
"""
for s in args:
self[s.lower()] = ephem.star(s)
summer_triangle = Asterism(deneb=ephem.star('Deneb'), altair=ephem.star('Altair'), vega=ephem.star('Vega'))
winter_hexagon = Asterism()
winter_hexagon.add_stars('Rigel', 'Aldebaran', 'Capella', 'Pollux', 'Procyon', 'Sirius')
def bodies(location, planets=True, poles=True, galaxy=True, winter_hexagon=True, summer_triangle=True):
"""Return a dictionary with pretty names and ephem bodies for the desired things.
"""
#bodies = collections.OrderedDict() # want to be able to reference them by name
bodies = {'Sun': ephem.Sun(location),
'Moon': ephem.Moon(location)
}
if galaxy:
bodies['Galaxy'] = galactic_center
bodies['Galaxy'].compute(location)
bodies['LMC'] = large_magellanic_cloud
bodies['LMC'].compute(location)
bodies['SMC'] = small_magellanic_cloud
bodies['SMC'].compute(location)
bodies['Crux'] = crux
bodies['Crux'].compute(location)
bodies['Coalsack'] = coalsack
bodies['Coalsack'].compute(location)
if planets:
for body in ('Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'):
bodies[body] = getattr(ephem, body)(location)
if winter_hexagon:
for star in ('Sirius', 'Rigel', 'Betelgeuse', 'Aldebaran', 'Capella', 'Pollux', 'Procyon'):
bodies[star] = ephem.star(star, location)
if summer_triangle:
for star in ('Deneb', 'Altair', 'Vega'):
bodies[star] = ephem.star(star, location)
return bodies