Ejemplo n.º 1
0
def test_saturn_passage_nodes():
    """Tests the passage_nodes() method of Saturn class"""

    epoch = Epoch(2019, 1, 1)
    time, r = Saturn.passage_nodes(epoch)
    y, m, d = time.get_date()
    d = round(d, 1)
    r = round(r, 4)

    assert abs(y - 2034) < TOL, \
        "ERROR: 1st passage_nodes() test doesn't match"

    assert abs(m - 5) < TOL, \
        "ERROR: 2nd passage_nodes() test doesn't match"

    assert abs(d - 30.2) < TOL, \
        "ERROR: 3rd passage_nodes() test doesn't match"

    assert abs(r - 9.0546) < TOL, \
        "ERROR: 4th passage_nodes() test doesn't match"
Ejemplo n.º 2
0
def test_mercury_passage_nodes():
    """Tests the passage_nodes() method of Mercury class"""

    epoch = Epoch(2019, 1, 1)
    time, r = Mercury.passage_nodes(epoch)
    y, m, d = time.get_date()
    d = round(d, 1)
    r = round(r, 4)

    assert abs(y - 2018) < TOL, \
        "ERROR: 1st passage_nodes() test doesn't match"

    assert abs(m - 11) < TOL, \
        "ERROR: 2nd passage_nodes() test doesn't match"

    assert abs(d - 24.7) < TOL, \
        "ERROR: 3rd passage_nodes() test doesn't match"

    assert abs(r - 0.3143) < TOL, \
        "ERROR: 4th passage_nodes() test doesn't match"
Ejemplo n.º 3
0
def test_uranus_passage_nodes():
    """Tests the passage_nodes() method of Uranus class"""

    epoch = Epoch(2019, 1, 1)
    time, r = Uranus.passage_nodes(epoch)
    y, m, d = time.get_date()
    d = round(d, 1)
    r = round(r, 4)

    assert abs(y - 2028) < TOL, \
        "ERROR: 1st passage_nodes() test doesn't match"

    assert abs(m - 8) < TOL, \
        "ERROR: 2nd passage_nodes() test doesn't match"

    assert abs(d - 23.2) < TOL, \
        "ERROR: 3rd passage_nodes() test doesn't match"

    assert abs(r - 19.3201) < TOL, \
        "ERROR: 4th passage_nodes() test doesn't match"
Ejemplo n.º 4
0
def test_earth_passage_nodes():
    """Tests the passage_nodes() method of Earth class"""

    epoch = Epoch(2019, 1, 1)
    time, r = Earth.passage_nodes(epoch)
    y, m, d = time.get_date()
    d = round(d, 1)
    r = round(r, 4)

    assert abs(y - 2019) < TOL, \
        "ERROR: 1st passage_nodes() test doesn't match"

    assert abs(m - 3) < TOL, \
        "ERROR: 2nd passage_nodes() test doesn't match"

    assert abs(d - 15.0) < TOL, \
        "ERROR: 3rd passage_nodes() test doesn't match"

    assert abs(r - 0.9945) < TOL, \
        "ERROR: 4th passage_nodes() test doesn't match"
Ejemplo n.º 5
0
def verifica_feriado_movel(self, ano, mes, dia):
    '''
        Verifica se a data passada é algum feriado móvel.
        Para feriados movéis que não são nacionais, verifica se o feriado
        já está cadastrado para o municipio.
    '''
    data_analisada = datetime(int(ano), int(mes), int(dia))
    pascoa_mes, pascoa_dia = Epoch.easter(int(ano))
    pascoa = datetime(int(ano), pascoa_mes, pascoa_dia)

    if data_analisada == pascoa - timedelta(days=2):
        return {'name': 'Sexta-Feira Santa'}
    elif data_analisada == pascoa:
        feriado_pascoa = Feriado.objects.filter(
            Q(municipio__codigo_ibge=self.kwargs['municipio__codigo_ibge'])
            | Q(estado__codigo_ibge=self.kwargs['municipio__codigo_ibge'][:2]),
            nome='Pascoa')
        if not feriado_pascoa:
            return None
        else:
            return {'name': 'Pascoa'}
    elif data_analisada == pascoa - timedelta(days=47):
        feriado_carnaval = Feriado.objects.filter(
            Q(municipio__codigo_ibge=self.kwargs['municipio__codigo_ibge'])
            | Q(estado__codigo_ibge=self.kwargs['municipio__codigo_ibge'][:2]),
            nome='Carnaval')
        if not feriado_carnaval:
            return None
        else:
            return {'name': 'Carnaval'}
    elif data_analisada == pascoa + timedelta(days=60):
        feriado_corpus_christi = Feriado.objects.filter(
            Q(municipio__codigo_ibge=self.kwargs['municipio__codigo_ibge'])
            | Q(estado__codigo_ibge=self.kwargs['municipio__codigo_ibge'][:2]),
            nome='Corpus Christi')
        if not feriado_corpus_christi:
            return None
        else:
            return {'name': 'Corpus Christi'}
    else:
        return None
Ejemplo n.º 6
0
def gregorian_nawruz(year):
    """
    Return Nawruz in the Gregorian calendar.
    Returns a tuple (month, day), where month is always 3
    """
    if year == 2059:
        return 3, 20

    # Timestamp of spring equinox.
    equinox = Sun.get_equinox_solstice(year, "spring")

    # Get times of sunsets in Tehran near vernal equinox.
    x, y = Angle(TEHRAN[0]), Angle(TEHRAN[1])
    days = trunc(equinox.get_date()[2]), ceil(equinox.get_date()[2])

    for day in days:
        sunset = Epoch(year, 3, day).rise_set(y, x)[1]
        if sunset > equinox:
            return 3, day

    raise ValueError("Couldn't find date of Nawruz.")
Ejemplo n.º 7
0
def test_mercury_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Mercury class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Mercury.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 202.579453) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 0.38709831) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.2056451) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 7.001089) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 48.24873) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - 29.311401) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 8
0
def test_mercury_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Mercury class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Mercury.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 203.494701) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 0.38709831) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.2056451) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 7.006171) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 49.10765) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - 29.367732) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 9
0
def test_venus_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Venus class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Venus.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 337.731227) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 0.72332982) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0067407) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 3.394087) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 76.49782) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - 55.068476) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 10
0
def test_venus_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Venus class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Venus.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 338.646306) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 0.72332982) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0067407) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 3.395319) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 77.27012) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - 55.211257) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 11
0
def test_saturn_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Saturn class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Saturn.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 130.28188) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 9.55490779) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0553209) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 2.490529) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 113.49736) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - (-20.068943)) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 12
0
def test_neptune_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Neptune class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Neptune.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 87.407029) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 30.11038676) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0094597) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 1.770101) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 131.74402) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - (-83.6046)) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 13
0
def test_neptune_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Neptune class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Neptune.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 88.321947) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 30.11038676) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0094597) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 1.763855) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 132.46986) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - (-83.415521)) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 14
0
def test_earth_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Earth class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Earth.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 271.801199) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 1.00000102) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0166811) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 0.008544) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 174.71534) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - (-71.566717)) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 15
0
def test_saturn_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Saturn class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Saturn.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 131.196871) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 9.55490779) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0553209) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 2.486426) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 114.23974) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - (-19.896331)) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 16
0
def test_jupiter_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Jupiter class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Jupiter.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 221.518802) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 5.20260333) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0486046) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 1.30198) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 100.58051) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - (-86.107875)) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 17
0
def test_jupiter_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Jupiter class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Jupiter.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 222.433723) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 5.20260333) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0486046) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 1.29967) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 101.13309) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - (-85.745532)) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 18
0
def test_earth_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Earth class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Earth.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 272.716028) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 1.00000102) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0166811) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 0.0) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 174.71534) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - (-70.651889)) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 19
0
def test_mars_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Mars class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Mars.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 287.94027) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 1.52367934) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0934599) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 1.844381) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 49.36464) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - 286.98617) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 20
0
def test_mars_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Mars class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Mars.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 288.855211) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 1.52367934) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0934599) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 1.849338) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 50.06365) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - 287.202108) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 21
0
def test_uranus_orbital_elements_j2000():
    """Tests the orbital_elements_j2000() method of Uranus class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Uranus.orbital_elements_j2000(epoch)

    assert abs(round(l, 6) - 234.602641) < TOL, \
        "ERROR: 1st orbital_elements_j2000() test doesn't match"

    assert abs(round(a, 8) - 19.21844604) < TOL, \
        "ERROR: 2nd orbital_elements_j2000() test doesn't match"

    assert abs(round(e, 7) - 0.0463634) < TOL, \
        "ERROR: 3rd orbital_elements_j2000() test doesn't match"

    assert abs(round(i, 6) - 0.772094) < TOL, \
        "ERROR: 4th orbital_elements_j2000() test doesn't match"

    assert abs(round(ome, 5) - 74.05468) < TOL, \
        "ERROR: 5th orbital_elements_j2000() test doesn't match"

    assert abs(round(arg, 6) - 99.009058) < TOL, \
        "ERROR: 6th orbital_elements_j2000() test doesn't match"
Ejemplo n.º 22
0
def test_uranus_orbital_elements_mean_equinox():
    """Tests the orbital_elements_mean_equinox() method of Uranus class"""

    epoch = Epoch(2065, 6, 24.0)
    l, a, e, i, ome, arg = Uranus.orbital_elements_mean_equinox(epoch)

    assert abs(round(l, 6) - 235.517526) < TOL, \
        "ERROR: 1st orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(a, 8) - 19.21844604) < TOL, \
        "ERROR: 2nd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(e, 7) - 0.0463634) < TOL, \
        "ERROR: 3rd orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(i, 6) - 0.77372) < TOL, \
        "ERROR: 4th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(ome, 5) - 74.34776) < TOL, \
        "ERROR: 5th orbital_elements_mean_equinox() test doesn't match"

    assert abs(round(arg, 6) - 99.630865) < TOL, \
        "ERROR: 6th orbital_elements_mean_equinox() test doesn't match"
Ejemplo n.º 23
0
def test_coordinates_passage_nodes_elliptic():
    """Tests the passage_nodes_elliptic() function of Coordinates module"""

    omega = Angle(111.84644)
    e = 0.96727426
    a = 17.9400782
    t = Epoch(1986, 2, 9.45891)
    time, r = passage_nodes_elliptic(omega, e, a, t)
    year, month, day = time.get_date()

    assert abs(year - 1985) < TOL, \
        "ERROR: 1st passage_nodes_elliptic() test, value doesn't match"

    assert abs(month - 11) < TOL, \
        "ERROR: 2nd passage_nodes_elliptic() test, value doesn't match"

    assert abs(round(day, 2) - 9.16) < TOL, \
        "ERROR: 3rd passage_nodes_elliptic() test, value doesn't match"

    assert abs(round(r, 4) - 1.8045) < TOL, \
        "ERROR: 4th passage_nodes_elliptic() test, value doesn't match"

    time, r = passage_nodes_elliptic(omega, e, a, t, ascending=False)
    year, month, day = time.get_date()

    assert abs(year - 1986) < TOL, \
        "ERROR: 5th passage_nodes_elliptic() test, value doesn't match"

    assert abs(month - 3) < TOL, \
        "ERROR: 6th passage_nodes_elliptic() test, value doesn't match"

    assert abs(round(day, 2) - 10.37) < TOL, \
        "ERROR: 7th passage_nodes_elliptic() test, value doesn't match"

    assert abs(round(r, 4) - 0.8493) < TOL, \
        "ERROR: 8th passage_nodes_elliptic() test, value doesn't match"
Ejemplo n.º 24
0
def test_epoch_leap_seconds():
    """Tests the leap_seconds() static method of Epoch class"""

    assert Epoch.leap_seconds(1983, 6) == 11, \
        "ERROR: 1st leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(1983, 7) == 12, \
        "ERROR: 2nd leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(2016, 11) == 26, \
        "ERROR: 3rd leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(2017, 1) == 27, \
        "ERROR: 4th leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(1972, 6) == 0, \
        "ERROR: 5th leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(1972, 7) == 1, \
        "ERROR: 6th leap_seconds() test, output doesn't match"

    assert Epoch.leap_seconds(2018, 7) == 27, \
        "ERROR: 7th leap_seconds() test, output doesn't match"
Ejemplo n.º 25
0
def test_epoch_tt2ut():
    """Tests the tt2ut() method of Epoch class"""

    assert abs(round(Epoch.tt2ut(1642, 1), 1) - 62.1) < TOL, \
        "ERROR: 1st tt2ut() test, output doesn't match"

    assert abs(round(Epoch.tt2ut(1680, 1), 1) - 15.3) < TOL, \
        "ERROR: 2nd tt2ut() test, output doesn't match"

    assert abs(round(Epoch.tt2ut(1774, 1), 1) - 16.7) < TOL, \
        "ERROR: 3rd tt2ut() test, output doesn't match"

    assert abs(round(Epoch.tt2ut(1890, 1), 1) - (-6.1)) < TOL, \
        "ERROR: 4th tt2ut() test, output doesn't match"

    assert abs(round(Epoch.tt2ut(1928, 2), 1) - 24.2) < TOL, \
        "ERROR: 5th tt2ut() test, output doesn't match"

    assert abs(round(Epoch.tt2ut(2015, 7), 1) - 69.3) < TOL, \
        "ERROR: 6th tt2ut() test, output doesn't match"
Ejemplo n.º 26
0
def test_epoch_doy2date():
    """Tests the doy2date() static method of Epoch class"""

    assert Epoch.doy2date(2017, 32) == (2017, 2, 1), \
        "ERROR: 1st doy2date() test, output doesn't match"

    assert Epoch.doy2date(-3, 60) == (-3, 3, 1.0), \
        "ERROR: 2nd doy2date() test, output doesn't match"

    assert Epoch.doy2date(-4, 60) == (-4, 2, 29.0), \
        "ERROR: 3rd doy2date() test, output doesn't match"

    t = Epoch.doy2date(2017, 365.7)
    assert t[0] == 2017 and t[1] == 12 and abs(t[2] - 31.7) < TOL, \
        "ERROR: 4th doy2date() test, output doesn't match"

    t = Epoch.doy2date(2012, 63.1)
    assert t[0] == 2012 and t[1] == 3 and abs(t[2] - 3.1) < TOL, \
        "ERROR: 5th doy2date() test, output doesn't match"

    t = Epoch.doy2date(-4, 60)
    assert t[0] == -4 and t[1] == 2 and abs(t[2] - 29) < TOL, \
        "ERROR: 6th doy2date() test, output doesn't match"
Ejemplo n.º 27
0
def test_epoch_float():
    """Tests the 'float()' operation on Epochs"""

    a = Epoch(2434923.85)
    assert abs(float(a) - 2434923.85) < TOL, \
        "ERROR: 1st __float__() test, output doesn't match"
Ejemplo n.º 28
0
def test_epoch_call():
    """Tests the __call__() method of Epoch class"""

    e = Epoch(-122, 1, 1.0)
    assert e() == 1676497.5, "ERROR: 1st __call__() test, output doesn't match"
Ejemplo n.º 29
0
def test_epoch_jde():
    """Tests the jde() method of Epoch class"""

    e = Epoch(-1000, 2, 29.0)
    assert e.jde() == 1355866.5, "ERROR: 1st jde() test, output doesn't match"
Ejemplo n.º 30
0
def test_epoch_mjd():
    """Tests the mjd() method of Epoch class"""

    e = Epoch(1858, 'NOVEMBER', 17)
    assert e.mjd() == 0.0, "ERROR: 1st mjd() test, output doesn't match"