예제 #1
0
def test_plot_trajectory_without_attractor_raises_error():
    frame = OrbitPlotter2D()

    with pytest.raises(ValueError) as excinfo:
        frame.plot_trajectory({})
    assert ("An attractor must be set up first, please use "
            "set_attractor(Major_Body)." in excinfo.exconly())
예제 #2
0
def test_plot_sets_attractor():
    frame = OrbitPlotter2D()
    assert frame._attractor is None
    assert frame._attractor_data == {}

    frame.plot(iss)
    assert frame._attractor == iss.attractor
    assert frame._attractor_data["name"] == iss.attractor.name
예제 #3
0
def test_get_figure_has_expected_properties():
    frame = OrbitPlotter2D()
    figure = frame.figure

    assert figure["data"] == [{}]
    assert figure["layout"]["autosize"] is True
    assert "xaxis" in figure["layout"]
    assert "yaxis" in figure["layout"]
예제 #4
0
def test_plot_2d_trajectory_without_frame_raises_error():
    frame = OrbitPlotter2D()

    with pytest.raises(ValueError) as excinfo:
        frame.set_attractor(Sun)
        frame.plot_trajectory({})
    assert ("A frame must be set up first, please use "
            "set_orbit_frame(orbit) or plot(orbit)" in excinfo.exconly())
예제 #5
0
def test_show_calls_prepare_plot(mock_prepare_plot, mock_iplot):
    m = OrbitPlotter2D()
    earth = Orbit.from_body_ephem(Earth)
    m.plot(orbit=earth, label="Obj")
    m.show()

    assert mock_iplot.call_count == 1
    mock_prepare_plot.assert_called_once_with()
예제 #6
0
def test_savefig_calls_prepare_plot(mock_prepare_plot, mock_export):
    m = OrbitPlotter2D()
    earth = Orbit.from_body_ephem(Earth)
    m.plot(orbit=earth, label="Obj")
    with tempfile.NamedTemporaryFile() as fp:
        m.savefig(filename=fp.name + ".jpeg")

    assert mock_export.call_count == 1
    mock_prepare_plot.assert_called_once_with()
예제 #7
0
def test_plot_trajectory_plots_a_trajectory():
    frame = OrbitPlotter2D()
    assert len(frame._data) == 0

    earth = Orbit.from_body_ephem(Earth)
    _, trajectory = earth.sample()
    frame.set_attractor(Sun)
    frame.plot_trajectory(trajectory)
    assert len(frame._data) == 1
    assert frame._attractor == Sun
예제 #8
0
def test_ephem_without_frame_raises_error():
    epochs = time.Time("2020-04-29 10:43", scale="tdb")
    earth = Ephem.from_body(Earth, epochs)
    plotter = OrbitPlotter2D()

    with pytest.raises(ValueError) as excinfo:
        plotter.set_attractor(Sun)
        plotter.plot_ephem(earth)
    assert ("A frame must be set up first, please use "
            "set_orbit_frame(orbit) or plot(orbit)" in excinfo.exconly())
예제 #9
0
def test_savefig_calls_prepare_plot():
    patcher = mock.patch.object(OrbitPlotter2D, '_prepare_plot')
    patched = patcher.start()

    m = OrbitPlotter2D()
    earth = Orbit.from_body_ephem(Earth)
    m.plot(orbit=earth, label="Obj")
    m.savefig(filename="a.jpeg")

    assert patched.call_count == 1
    patched.assert_called_with()
예제 #10
0
def test_set_different_attractor_raises_error():
    body1 = Earth

    body2 = Mars

    frame = OrbitPlotter2D()
    frame.set_attractor(body1)

    with pytest.raises(NotImplementedError) as excinfo:
        frame.set_attractor(body2)
    assert "Attractor has already been set to Earth." in excinfo.exconly()
예제 #11
0
def test_plot_2d_trajectory_plots_a_trajectory():
    frame = OrbitPlotter2D()
    assert len(frame.trajectories) == 0

    trajectory = churi.sample()
    frame.set_attractor(Sun)
    frame.set_orbit_frame(churi)
    frame.plot_trajectory(trajectory)

    assert len(frame.trajectories) == 1
    assert frame._attractor == Sun
예제 #12
0
def test_plot_2d_trajectory_plots_a_trajectory():
    frame = OrbitPlotter2D()
    assert len(frame.trajectories) == 0

    earth = Orbit.from_body_ephem(Earth)
    trajectory = earth.sample()
    frame.set_attractor(Sun)
    frame.set_frame(*earth.pqw())
    frame.plot_trajectory(trajectory)

    assert len(frame.trajectories) == 1
    assert frame._attractor == Sun
예제 #13
0
파일: main.py 프로젝트: ajburjek/sister
 def on_button_clicked():
     #Two body calculation
     aPoli = apogee.value() * u.km
     eccPoli = ecc.value() * u.one
     incPoli = inc.value() * u.deg
     raanPoli = raan.value() * u.deg
     aopPoli = aop.value() * u.deg
     nuPoli = nu.value() * u.deg
     ss = Orbit.from_classical(Earth, aPoli, eccPoli, incPoli,
                               raanPoli, aopPoli, nuPoli)
     op = OrbitPlotter2D()
     op.plot(ss, label="Computed Orbit")
     self.canvas.draw()
예제 #14
0
def test_plot_appends_data():
    frame = OrbitPlotter2D()
    assert len(frame._data) == 0

    frame.plot(iss)
    assert len(frame._data) == 1 + 1
예제 #15
0
                plotOrbit((f_orbit.a.value), (f_orbit.ecc.value),
                          (f_orbit.inc.value), (f_orbit.raan.value),
                          (f_orbit.argp.value), (f_orbit.nu.value))

        elif (opt_1 == '2'):
            print("\n1.Find orbit using-")
            print("1.Name.")
            print("2.SPK id.")
            opt_2 = input()
            if (opt_2 == '1'):
                print("Enter name:")
                str_1 = input()
                orbit = neows.orbit_from_name(str_1)
                print(orbit)
                print(orbit.rv())
                frame = OrbitPlotter2D()
                frame.plot(orbit, label=str_1)
                print(
                    "\nPropagate to(Enter time in format='iso', scale='utc':")
                p_t_s = input()
                p_t_o = Time(p_t_s, format='iso', scale='utc')
                print("")
                final = orbit.propagate(p_t_o)
                #final.plot()
                print("Orbital elements:")
                print(final.classical())
                print("")
                print("Final co-ordinates:")
                print(final.rv())
                print("")
                f_orbit = final
    observations = json.load(json_file)

sd_actual = []
sd_pred = []
es = []
r_actual = []
r_pred = []
ED_actual = []
ED_pred = []
v_actual = []
v_pred = []
ranges = []
speed_actual = []
speed_pred = []
orb = []
op = OrbitPlotter2D()  # Initialiaze orbit plot
for epoch in range(num_epochs):
    # Satellite-debris direction vectors
    sd_actual.append(
        observations['telemetry'][epoch]
        ['directionVector_actual'])  # Actual satellite-debris direction vector
    # Calculate predicted satellite-debris vector
    K = np.array(observations['CameraCalibration'][epoch]
                 ['intrinsics'])  # camera intrinsics matrix
    RT = np.array(observations['CameraCalibration'][epoch]
                  ['extrinsics'])  # camera extrinsics matrix
    # Extract bounding box predictions
    x = observations['bbox'][epoch]['Xcenter']
    y = observations['bbox'][epoch]['Ycenter']
    p = np.array([[x], [y],
                  [1]])  # convert location of bbox center to homogenous vector