Exemplo n.º 1
0
def test_coord_not_equality_operator():
    cCoord = NumCpp.Coordinate()

    raDegrees = np.random.rand(1).item() * 360
    decDegrees = np.random.rand(1).item() * 180 - 90
    cCoord2 = NumCpp.Coordinate(raDegrees, decDegrees)
    assert cCoord2 != cCoord
Exemplo n.º 2
0
def test_coord_degreeSeperation():
    cCoord = NumCpp.Coordinate()

    raDegrees = np.random.rand(1).item() * 360
    decDegrees = np.random.rand(1).item() * 180 - 90
    cCoord2 = NumCpp.Coordinate(raDegrees, decDegrees)

    pyCoord = SkyCoord(cCoord.ra().degrees(), cCoord.dec().degrees(), unit=u.deg)  # noqa
    pyCoord2 = SkyCoord(cCoord2.ra().degrees(), cCoord2.dec().degrees(), unit=u.deg)  # noqa

    cDegSep = cCoord.degreeSeperation(cCoord2)
    pyDegSep = pyCoord.separation(pyCoord2).value
    assert round(cDegSep, 9) == round(pyDegSep, 9)
Exemplo n.º 3
0
def test_coord_radianSeperation_vec():
    cCoord = NumCpp.Coordinate()

    raDegrees = np.random.rand(1).item() * 360
    decDegrees = np.random.rand(1).item() * 180 - 90
    cCoord2 = NumCpp.Coordinate(raDegrees, decDegrees)

    pyCoord = SkyCoord(cCoord.ra().degrees(), cCoord.dec().degrees(), unit=u.deg)  # noqa
    pyCoord2 = SkyCoord(cCoord2.ra().degrees(), cCoord2.dec().degrees(), unit=u.deg)  # noqa

    vec2 = np.asarray([pyCoord2.cartesian.x, pyCoord2.cartesian.y, pyCoord2.cartesian.z])
    cArray = NumCpp.NdArray(1, 3)
    cArray.setArray(vec2)
    cRadSep = cCoord.radianSeperation(cArray)
    pyRadSep = np.radians(pyCoord.separation(pyCoord2).value)
    assert round(cRadSep, 9) == round(pyRadSep, 9)  # noqa
Exemplo n.º 4
0
def test_coord_rms_constructor():
    raHours = np.random.randint(0, 24, [1, ], dtype=np.uint8).item()
    raMinutes = np.random.randint(0, 60, [1, ], dtype=np.uint8).item()
    raSeconds = np.random.rand(1).astype(np.double).item() * 60
    raDegreesPy = (raHours + raMinutes / 60 + raSeconds / 3600) * 15

    decSign = NumCpp.Sign.POSITIVE if np.random.randint(-1, 1) == 0 else NumCpp.Sign.NEGATIVE
    decDegrees = np.random.randint(0, 90, [1, ], dtype=np.uint8).item()
    decMinutes = np.random.randint(0, 60, [1, ], dtype=np.uint8).item()
    decSeconds = np.random.rand(1).astype(np.double).item() * 60
    decDegreesPy = decDegrees + decMinutes / 60 + decSeconds / 3600
    if decSign == NumCpp.Sign.NEGATIVE:
        decDegreesPy *= -1

    cCoord = NumCpp.Coordinate(raHours, raMinutes, raSeconds, decSign, decDegrees, decMinutes, decSeconds)
    cRa = cCoord.ra()
    cDec = cCoord.dec()
    pyCoord = SkyCoord(raDegreesPy, decDegreesPy, unit=u.deg)  # noqa
    assert round(cRa.degrees(), 9) == round(raDegreesPy, 9)
    assert cRa.hours() == raHours
    assert cRa.minutes() == raMinutes
    assert round(cRa.seconds(), 9) == round(raSeconds, 9)
    assert cDec.sign() == decSign
    assert round(cDec.degrees(), 9) == round(decDegreesPy, 9)
    assert cDec.degreesWhole() == decDegrees
    assert cDec.minutes() == decMinutes
    assert round(cDec.seconds(), 9) == round(decSeconds, 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)
Exemplo n.º 5
0
def test_coord_radianSeperation():
    cCoord = NumCpp.Coordinate()

    raDegrees = np.random.rand(1).item() * 360
    decDegrees = np.random.rand(1).item() * 180 - 90
    cCoord2 = NumCpp.Coordinate(raDegrees, decDegrees)

    pyCoord = SkyCoord(cCoord.ra().degrees(),
                       cCoord.dec().degrees(),
                       unit=u.deg)
    pyCoord2 = SkyCoord(cCoord2.ra().degrees(),
                        cCoord2.dec().degrees(),
                        unit=u.deg)

    cRadSep = cCoord.radianSeperation(cCoord2)
    pyRadSep = np.deg2rad(pyCoord.separation(pyCoord2).value)

    assert round(cRadSep, 9) == round(pyRadSep, 9)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
def test_coorc_print():
    cCoord = NumCpp.Coordinate()
    cCoord.print()
Exemplo n.º 10
0
def test_coord_xyz():
    cCoord = NumCpp.Coordinate()
    xyz = [cCoord.x(), cCoord.y(), cCoord.z()]
    assert np.array_equal(cCoord.xyz().getNumpyArray().flatten(), xyz)
Exemplo n.º 11
0
def test_coord_copy_constructor_and_equality_operator():
    cCoord = NumCpp.Coordinate()
    assert cCoord
    cCoord2 = NumCpp.Coordinate(cCoord)
    assert cCoord2 == cCoord
Exemplo n.º 12
0
def test_coord_default_constructor():
    coord = NumCpp.Coordinate()
    assert coord