Exemple #1
0
def test_equality_operator():
    dec = NumCpp.Dec()
    assert dec

    randDegrees = np.random.rand(1).item() * 180 - 90
    dec2 = NumCpp.Dec(randDegrees)
    assert dec != dec2
Exemple #2
0
def test_dec_degree_constructor():
    randDegrees = np.random.rand(1).item() * 180 - 90
    dec = NumCpp.Dec(randDegrees)
    decPy = Latitude(randDegrees, unit=u.deg)  # noqa
    sign = NumCpp.Sign.NEGATIVE if randDegrees < 0 else NumCpp.Sign.POSITIVE
    assert round(dec.degrees(), 8) == round(randDegrees, 8)
    assert dec.sign() == sign
    assert dec.degreesWhole() == abs(decPy.dms.d)
    assert dec.minutes() == abs(decPy.dms.m)
    assert round(dec.seconds(), 8) == round(abs(decPy.dms.s), 8)
    assert round(dec.radians(), 8) == round(np.deg2rad(randDegrees), 8)
Exemple #3
0
def test_coord_cartesian_constructor():
    raDegrees = np.random.rand(1).item() * 360
    ra = NumCpp.Ra(raDegrees)
    decDegrees = np.random.rand(1).item() * 180 - 90
    dec = NumCpp.Dec(decDegrees)
    pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg)  # noqa
    cCoord = NumCpp.Coordinate(pyCoord.cartesian.x.value, pyCoord.cartesian.y.value, pyCoord.cartesian.z.value)
    assert round(cCoord.ra().degrees(), 9) == round(ra.degrees(), 9)
    assert round(cCoord.dec().degrees(), 9) == round(dec.degrees(), 9)
    assert round(cCoord.x(), 9) == round(pyCoord.cartesian.x.value, 9)
    assert round(cCoord.y(), 9) == round(pyCoord.cartesian.y.value, 9)
    assert round(cCoord.z(), 9) == round(pyCoord.cartesian.z.value, 9)
Exemple #4
0
def test_coord_radec_constructor():
    raDegrees = np.random.rand(1).item() * 360
    ra = NumCpp.Ra(raDegrees)
    decDegrees = np.random.rand(1).item() * 180 - 90
    dec = NumCpp.Dec(decDegrees)

    pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg)  # noqa
    cCoord = NumCpp.Coordinate(ra, dec)
    assert cCoord.ra() == ra
    assert cCoord.dec() == dec
    assert round(cCoord.x(), 10) == round(pyCoord.cartesian.x.value, 10)
    assert round(cCoord.y(), 10) == round(pyCoord.cartesian.y.value, 10)
    assert round(cCoord.z(), 10) == round(pyCoord.cartesian.z.value, 10)
Exemple #5
0
def test_dec_hms_constructor():
    sign = NumCpp.Sign.POSITIVE if np.random.randint(-1, 1) == 0 else NumCpp.Sign.NEGATIVE
    degrees = np.random.randint(0, 91, [1, ], dtype=np.uint8).item()
    minutes = np.random.randint(0, 60, [1, ], dtype=np.uint8).item()
    seconds = np.random.rand(1).astype(np.double).item() * 60
    dec = NumCpp.Dec(sign, degrees, minutes, seconds)
    degreesPy = degrees + minutes / 60 + seconds / 3600
    if sign == NumCpp.Sign.NEGATIVE:
        degreesPy *= -1
    assert dec.sign() == sign
    assert round(dec.degrees(), 9) == round(degreesPy, 9)
    assert dec.degreesWhole() == degrees
    assert dec.minutes() == minutes
    assert round(dec.seconds(), 9) == round(seconds, 9)
    assert round(dec.radians(), 8) == round(np.deg2rad(degreesPy), 8)
Exemple #6
0
def test_coord_cartesian_vector_constructor():
    raDegrees = np.random.rand(1).item() * 360
    ra = NumCpp.Ra(raDegrees)
    decDegrees = np.random.rand(1).item() * 180 - 90
    dec = NumCpp.Dec(decDegrees)
    pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg)  # noqa
    vec = np.asarray([pyCoord.cartesian.x.value, pyCoord.cartesian.y.value, pyCoord.cartesian.z.value])
    cVec = NumCpp.NdArray(1, 3)
    cVec.setArray(vec)
    cCoord = NumCpp.Coordinate(cVec)
    assert round(cCoord.ra().degrees(), 9) == round(ra.degrees(), 9)
    assert round(cCoord.dec().degrees(), 9) == round(dec.degrees(), 9)
    assert round(cCoord.x(), 9) == round(pyCoord.cartesian.x.value, 9)
    assert round(cCoord.y(), 9) == round(pyCoord.cartesian.y.value, 9)
    assert round(cCoord.z(), 9) == round(pyCoord.cartesian.z.value, 9)
Exemple #7
0
def test_dec_default_constructor():
    dec = NumCpp.Dec()
    assert dec
Exemple #8
0
def test_dec_print():
    dec = NumCpp.Dec()
    dec.print()
Exemple #9
0
def test_dec_copy_constructor():
    dec = NumCpp.Dec()
    assert dec

    dec2 = NumCpp.Dec(dec)
    assert dec == dec2