Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1583 from valdaarhun/ephem_epochs_calculation
Browse files Browse the repository at this point in the history
Bug fix: Fixes #1563
  • Loading branch information
astrojuanlu committed Sep 14, 2022
2 parents 0583b33 + 2329b70 commit 90fb27a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/poliastro/twobody/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def sample(self, orbit):
delta_ts = (
np.unwrap(delta_ts, period=orbit.period.to_value(u.s)) << u.s
)
epochs = orbit.epoch + (orbit.t_p + delta_ts)
epochs = orbit.epoch + (delta_ts - orbit.t_p)

n = nu_values.shape[0]
rr, vv = coe2rv_many(
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_twobody/test_orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,23 @@ def test_from_ephem_has_expected_properties():
assert_quantity_allclose(ss.v, expected_v)


def test_to_ephem_samples_correct_epochs_and_coordinates():
epoch = Time("2022-2-3 1:42:0")
orbit = Orbit.from_vectors(
Earth,
r=[6045.0, 3490.0, -2500.0] * u.km,
v=[-3.457, 6.618, 2.533] * u.km / u.s,
epoch=epoch,
)

ephem = orbit.to_ephem()
assert ephem.epochs[0].value == orbit.epoch

ephem_initial_coordinates = [coord[0] for coord in ephem.sample(epoch).xyz]

assert_quantity_allclose(ephem_initial_coordinates, orbit.r)


def test_from_vectors_wrong_dimensions_fails():
bad_r = [[1000, 0, 0]] * u.km
bad_v = [[[0, 10, 0]]] * u.km / u.s
Expand Down

0 comments on commit 90fb27a

Please sign in to comment.