Skip to content

Commit 749ffed

Browse files
committed
Add additional test epoch in test_propagate.py, make use of to_pandas()
1 parent 5d2c4f7 commit 749ffed

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

thor/orbits/propagate/tests/test_propagate.py

+23-15
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,30 @@
66
from ..universal import propagateUniversal
77

88
MU = c.G * c.M_SUN
9+
MAX_ITER = 100
10+
TOL = 1e-15
11+
12+
TARGETS = [
13+
"Amor",
14+
"Eros",
15+
"Eugenia",
16+
"C/2019 Q4" # Borisov
17+
]
18+
EPOCHS = [57257.0, 59000.0]
919

1020
def test_propagateUniversal():
1121
"""
1222
Using a selection of 4 asteroids, this function queries Horizons for an initial state vector at one epoch, then propagates
1323
that state to 1000 different times and compares each propagation to the SPICE 2-body propagator.
1424
"""
15-
targets = [
16-
"Amor",
17-
"Eros",
18-
"Eugenia",
19-
"C/2019 Q4" #Borisov
20-
]
21-
22-
epochs = [57257.0]
2325
dts = np.linspace(0.01, 500, num=1000)
2426

25-
for name in targets:
26-
for epoch in epochs:
27+
for name in TARGETS:
28+
for epoch in EPOCHS:
2729
# Grab vectors from Horizons at epoch
2830
target = Horizons(id=name, epochs=epoch, location="@sun")
29-
vectors = target.vectors()
30-
vectors = np.array(vectors["x", "y", "z", "vx", "vy", "vz"]).view("float64")
31-
vectors = vectors.reshape(-1, 6)
31+
vectors = target.vectors().to_pandas()
32+
vectors = vectors[["x", "y", "z", "vx", "vy", "vz"]].values
3233

3334
# Propagate vector to each new epoch (epoch + dt)
3435
spice_elements = []
@@ -37,15 +38,22 @@ def test_propagateUniversal():
3738
spice_elements = np.array(spice_elements)
3839

3940
# Repeat but now using THOR's universal propagator
40-
vectors_new = propagateUniversal(vectors[0:1, :], np.array(epochs), dts + epochs[0], mu=MU, max_iter=1000, tol=1e-15)
41+
vectors_new = propagateUniversal(
42+
vectors[0:1, :],
43+
np.array([epoch]),
44+
dts + epoch,
45+
mu=MU,
46+
max_iter=MAX_ITER,
47+
tol=TOL
48+
)
4149

4250
orbit_id = vectors_new[:, 0]
4351
new_epochs = vectors_new[:, 1]
4452

4553
# Make sure the first column is a bunch of 0s since only one orbit was passed
4654
np.testing.assert_allclose(orbit_id, np.zeros(len(dts)))
4755
# Make sure the second column has all the new epochs
48-
np.testing.assert_allclose(new_epochs, dts + epochs[0])
56+
np.testing.assert_allclose(new_epochs, dts + epoch)
4957

5058
# Extract position and velocity components and compare them
5159
r = vectors_new[:, 2:5]

0 commit comments

Comments
 (0)