コード例 #1
0
def test_ephem_fails_if_dimensions_are_not_correct(epochs, coordinates):
    unused_plane = Planes.EARTH_EQUATOR
    with pytest.raises(ValueError) as excinfo:
        Ephem(epochs[0], coordinates, unused_plane)
    assert (
        "Coordinates and epochs must have dimension 1, got 0 and 1" in excinfo.exconly()
    )
コード例 #2
0
def test_ephem_sample_same_epochs_returns_same_input(epochs, coordinates, method):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    result_coordinates = ephem.sample(epochs, method=method)

    # TODO: Should it return exactly the same?
    assert_coordinates_allclose(result_coordinates, coordinates, atol_scale=1e-17)
コード例 #3
0
def test_ephem_sample_no_arguments_returns_exactly_same_input(
        epochs, coordinates, method):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    result_coordinates = ephem.sample(method=method)

    # Exactly the same
    assert np.all(result_coordinates == coordinates)
コード例 #4
0
def test_ephem_str_matches_expected_representation(epochs, coordinates):
    plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, plane)

    expected_str = (
        "Ephemerides at 4 epochs "
        "from 2020-03-01 12:00:00.000 (TDB) to 2020-03-04 12:00:00.000 (TDB)")

    assert repr(ephem) == str(ephem) == expected_str
コード例 #5
0
def test_ephem_sample_scalar_epoch_returns_1_dimensional_coordinates(
        epochs, coordinates, method):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    result_coordinates = ephem.sample(epochs[0], method=method)

    # Exactly the same
    assert result_coordinates.ndim == 1
コード例 #6
0
def test_ephem_sample_existing_epochs_returns_corresponding_input(
    epochs, coordinates, method
):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    result_coordinates = ephem.sample(epochs[::2], method=method)

    # Exactly the same
    assert_coordinates_allclose(result_coordinates, coordinates[::2], atol_scale=1e-17)
コード例 #7
0
def test_rv_scalar_epoch_returns_scalar_vectors(coordinates, epochs):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    expected_r = coordinates.get_xyz(xyz_axis=1)[0]
    expected_v = coordinates.differentials["s"].get_d_xyz(xyz_axis=1)[0]

    r, v = ephem.rv(epochs[0])

    assert_quantity_allclose(r, expected_r)
    assert_quantity_allclose(v, expected_v)
コード例 #8
0
def test_rv_no_parameters_returns_input_vectors(coordinates, epochs):
    unused_plane = Planes.EARTH_EQUATOR
    ephem = Ephem(coordinates, epochs, unused_plane)

    expected_r = coordinates.get_xyz(xyz_axis=1)
    expected_v = coordinates.differentials["s"].get_d_xyz(xyz_axis=1)

    r, v = ephem.rv()

    assert_quantity_allclose(r, expected_r)
    assert_quantity_allclose(v, expected_v)
コード例 #9
0
def test_ephem_sample_scalar_epoch_and_coordinates_returns_exactly_same_input(
        epochs, coordinates, method):
    unused_plane = Planes.EARTH_EQUATOR
    coordinates = coordinates[0].reshape(-1)
    epochs = epochs[0].reshape(-1)
    ephem = Ephem(coordinates, epochs, unused_plane)

    result_coordinates = ephem.sample(epochs[0], method=method)

    # Exactly the same
    assert result_coordinates == coordinates
コード例 #10
0
def test_plot_ephem_different_plane_raises_error():
    unused_epochs = Time.now().reshape(-1)
    unused_coordinates = CartesianRepresentation(
        [(1, 0, 0)] * u.au,
        xyz_axis=1,
        differentials=CartesianDifferential([(0, 1, 0)] * (u.au / u.day), xyz_axis=1),
    )

    op = StaticOrbitPlotter(plane=Planes.EARTH_ECLIPTIC)
    op.set_attractor(Sun)
    op.set_body_frame(Earth)
    with pytest.raises(ValueError) as excinfo:
        op.plot_ephem(Ephem(unused_epochs, unused_coordinates, Planes.EARTH_EQUATOR))

    assert (
        "sample the ephemerides using a different plane or create a new plotter"
        in excinfo.exconly()
    )
コード例 #11
0
def test_ephem_has_given_plane(epochs, coordinates, plane):
    ephem = Ephem(epochs, coordinates, plane)

    assert ephem.plane is plane