Beispiel #1
0
 def test_conversation_bijection(self, l):
     equ = set()
     hor = set()
     for a in range(-180, 180, 4):
         for d in range(-89, 89, 4):
             e = Equatorial(a, d)
             h = e.to_horizontal_with_latitude(l)
             equ.add(e)
             hor.add(h)
     self.assertEqual(len(equ), len(hor))
Beispiel #2
0
 def test_init(self, a, d):
     v = Equatorial(a, d)
     self.assertEqual(cos(radians(a)),
                      cos(radians(v.a)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(a)),
                      sin(radians(v.a)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(d)),
                      sin(radians(v.d)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(d)),
                      sin(radians(v.d)),
                      epsilon=EquatorialTest.EPS)
Beispiel #3
0
 def test_apply_time_rotation(self, s, a, d):
     v = Equatorial(a, d).apply_time_rotation(s)
     a += s
     self.assertEqual(cos(radians(a)),
                      cos(radians(v.a)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(a)),
                      sin(radians(v.a)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(d)),
                      sin(radians(v.d)),
                      epsilon=EquatorialTest.EPS)
     self.assertEqual(sin(radians(d)),
                      sin(radians(v.d)),
                      epsilon=EquatorialTest.EPS)
Beispiel #4
0
 def _draw_point_and_direction(self, pos: Equatorial, color, size,
                               apply_latitude):
     self.settings.apply_color(color, self._painter)
     if apply_latitude:
         horizontal = pos.to_horizontal_with_latitude(
             self.watcher.position.h)
     elif isinstance(pos, Equatorial):
         horizontal = Horizontal(pos.a, pos.d)
     else:
         horizontal = pos
     p_lat = self.project_star(horizontal, Star(pos, '', size, '', ''),
                               True)
     if p_lat is not None and p_lat.in_eye:
         self._draw_object(p_lat, False)
     self._painter.drawLine(p_lat.cx, p_lat.cy, self.centre[0],
                            self.centre[1])
Beispiel #5
0
 def parse_star(self, pair) -> Star:
     try:
         parsed = self._regexp.match(pair[0].replace('\n', '')).groupdict()
         a_h, a_m, a_s = extract_nums(parsed, 'alf', 3)
         d_d, d_m, d_s = extract_nums(parsed, 'del', 3)
         a = time_to_degree(a_h, a_m, a_s)
         d = dtime_to_degree(d_d, d_m, d_s)
         cls = parsed['cls'] if parsed['cls'] in SPECTRAL_MAP.keys() else ''
         name = parsed['name']
         if name is None:
             name = ''
         if name[0:3] in EN2LAT_MAP:
             name = EN2LAT_MAP[name]
         return Star(Equatorial(a, d), pair[1], float(parsed['mag']), cls,
                     name)
     except Exception as ex:
         print('Can`t parse line ({}) in {}: {}'.format(
             pair[0].rstrip('\n'), pair[1], ex))
Beispiel #6
0
 def setUp(self):
     self.v = Equatorial(3, 4)
     self.a = Equatorial(1, 2)
Beispiel #7
0
 def to_horizontal(self, equ: Equatorial):
     return equ.to_horizontal_with_time(self.star_time.total_degree % 360,
                                        self.position.h)
Beispiel #8
0
 def _draw_see_points(self):
     self._draw_point_and_direction(self.watcher.position, 'up', -1, False)
     self._draw_point_and_direction(Equatorial(0, 90), 'up_border', -1,
                                    False)
     self._draw_point_and_direction(Equatorial(0, -90), 'up_border', -1,
                                    False)
Beispiel #9
0
 def _draw_compass(self):
     self._draw_point_and_direction(Equatorial(0, 90), 'north', -3, True)
     self._draw_point_and_direction(Equatorial(0, -90), 'south', -3, True)