6
6
from ..universal import propagateUniversal
7
7
8
8
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 ]
9
19
10
20
def test_propagateUniversal ():
11
21
"""
12
22
Using a selection of 4 asteroids, this function queries Horizons for an initial state vector at one epoch, then propagates
13
23
that state to 1000 different times and compares each propagation to the SPICE 2-body propagator.
14
24
"""
15
- targets = [
16
- "Amor" ,
17
- "Eros" ,
18
- "Eugenia" ,
19
- "C/2019 Q4" #Borisov
20
- ]
21
-
22
- epochs = [57257.0 ]
23
25
dts = np .linspace (0.01 , 500 , num = 1000 )
24
26
25
- for name in targets :
26
- for epoch in epochs :
27
+ for name in TARGETS :
28
+ for epoch in EPOCHS :
27
29
# Grab vectors from Horizons at epoch
28
30
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
32
33
33
34
# Propagate vector to each new epoch (epoch + dt)
34
35
spice_elements = []
@@ -37,15 +38,22 @@ def test_propagateUniversal():
37
38
spice_elements = np .array (spice_elements )
38
39
39
40
# 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
+ )
41
49
42
50
orbit_id = vectors_new [:, 0 ]
43
51
new_epochs = vectors_new [:, 1 ]
44
52
45
53
# Make sure the first column is a bunch of 0s since only one orbit was passed
46
54
np .testing .assert_allclose (orbit_id , np .zeros (len (dts )))
47
55
# 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 )
49
57
50
58
# Extract position and velocity components and compare them
51
59
r = vectors_new [:, 2 :5 ]
0 commit comments