File: test_minor.py

package info (click to toggle)
pymeeus 0.4.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,856 kB
  • sloc: python: 42,407; makefile: 15; sh: 11
file content (72 lines) | stat: -rw-r--r-- 2,374 bytes parent folder | download | duplicates (3)
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
# -*- coding: utf-8 -*-


# PyMeeus: Python module implementing astronomical algorithms.
# Copyright (C) 2018  Dagoberto Salazar
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


from pymeeus.base import TOL
from pymeeus.Angle import Angle
from pymeeus.Minor import Minor
from pymeeus.Epoch import Epoch


# Minor class


def test_minor_geocentric_position():
    """Tests the geocentric_position() method of Minor class"""

    a = 2.2091404
    e = 0.8502196
    q = a * (1.0 - e)
    i = Angle(11.94524)
    omega = Angle(334.75006)
    w = Angle(186.23352)
    t = Epoch(1990, 10, 28.54502)
    epoch = Epoch(1990, 10, 6.0)
    minor = Minor(q, e, i, omega, w, t)
    ra, dec, elong = minor.geocentric_position(epoch)

    assert ra.ra_str(n_dec=1) == "10h 34' 13.7''", \
        "ERROR: 1st geocentric_position() test doesn't match"

    assert dec.dms_str(n_dec=0) == "19d 9' 32.0''", \
        "ERROR: 2nd geocentric_position() test doesn't match"

    assert abs(round(elong, 2) - 40.51) < TOL, \
        "ERROR: 3rd geocentric_position() test doesn't match"


def test_minor_heliocentric_ecliptical_position():
    """Tests the heliocentric_ecliptical_position() method of Minor class"""

    a = 2.2091404
    e = 0.8502196
    q = a * (1.0 - e)
    i = Angle(11.94524)
    omega = Angle(334.75006)
    w = Angle(186.23352)
    t = Epoch(1990, 10, 28.54502)
    epoch = Epoch(1990, 10, 6.0)
    minor = Minor(q, e, i, omega, w, t)
    lon, lat = minor.heliocentric_ecliptical_position(epoch)

    assert lon.dms_str(n_dec=1) == "66d 51' 57.8''", \
        "ERROR: 1st heliocentric_ecliptical_position() test doesn't match"

    assert lat.dms_str(n_dec=1) == "11d 56' 14.4''", \
        "ERROR: 2nd heliocentric_ecliptical_position() test doesn't match"