6
6
from anise .astro import *
7
7
from anise .astro .constants import Frames
8
8
from anise .rotation import DCM
9
- from anise .time import Epoch
9
+ from anise .time import Duration , Epoch , TimeSeries , Unit
10
10
from anise .utils import convert_tpc
11
11
12
12
from os import environ
@@ -27,7 +27,7 @@ def test_state_transformation():
27
27
print (meta )
28
28
# Process the files to be loaded
29
29
try :
30
- ctx = meta .process ()
30
+ almanac = meta .process ()
31
31
except Exception as e :
32
32
if "lfs" in str (e ):
33
33
# Must be some LFS error in the CI again
@@ -36,14 +36,14 @@ def test_state_transformation():
36
36
else :
37
37
data_path = Path (__file__ ).parent .joinpath (".." , ".." , "data" )
38
38
# Must ensure that the path is a string
39
- ctx = Almanac (str (data_path .joinpath ("de440s.bsp" )))
39
+ almanac = Almanac (str (data_path .joinpath ("de440s.bsp" )))
40
40
# Let's add another file here -- note that the Almanac will load into a NEW variable, so we must overwrite it!
41
41
# This prevents memory leaks (yes, I promise)
42
- ctx = ctx .load (str (data_path .joinpath ("pck08.pca" ))).load (
42
+ almanac = almanac .load (str (data_path .joinpath ("pck08.pca" ))).load (
43
43
str (data_path .joinpath ("earth_latest_high_prec.bpc" ))
44
44
)
45
45
46
- eme2k = ctx .frame_info (Frames .EME2000 )
46
+ eme2k = almanac .frame_info (Frames .EME2000 )
47
47
assert eme2k .mu_km3_s2 () == 398600.435436096
48
48
assert eme2k .shape .polar_radius_km == 6356.75
49
49
assert abs (eme2k .shape .flattening () - 0.0033536422844278 ) < 2e-16
@@ -94,7 +94,7 @@ def test_state_transformation():
94
94
# In Python, we can set the aberration to None
95
95
aberration = None
96
96
97
- state_itrf93 = ctx .transform_to (orig_state , Frames .EARTH_ITRF93 , aberration )
97
+ state_itrf93 = almanac .transform_to (orig_state , Frames .EARTH_ITRF93 , aberration )
98
98
99
99
print (orig_state )
100
100
print (state_itrf93 )
@@ -104,7 +104,7 @@ def test_state_transformation():
104
104
assert abs (state_itrf93 .height_km () - 1814.503598063825 ) < 1e-10
105
105
106
106
# Convert back
107
- from_state_itrf93_to_eme2k = ctx .transform_to (state_itrf93 , Frames .EARTH_J2000 )
107
+ from_state_itrf93_to_eme2k = almanac .transform_to (state_itrf93 , Frames .EARTH_J2000 )
108
108
109
109
print (from_state_itrf93_to_eme2k )
110
110
@@ -113,7 +113,7 @@ def test_state_transformation():
113
113
# Demo creation of a ground station
114
114
mean_earth_angular_velocity_deg_s = 0.004178079012116429
115
115
# Grab the loaded frame info
116
- itrf93 = ctx .frame_info (Frames .EARTH_ITRF93 )
116
+ itrf93 = almanac .frame_info (Frames .EARTH_ITRF93 )
117
117
paris = Orbit .from_latlongalt (
118
118
48.8566 ,
119
119
2.3522 ,
@@ -147,7 +147,30 @@ def test_state_transformation():
147
147
"line_of_sight_obstructed" ,
148
148
"azimuth_elevation_range_sez" ,
149
149
]:
150
- assert hasattr (ctx , fname )
150
+ assert hasattr (almanac , fname )
151
+
152
+ # Test the parallel function calls
153
+ start = Epoch ("2021-10-29 12:34:56 TDB" )
154
+ stop = Epoch ("2022-10-29 12:34:56 TDB" )
155
+ time_series = TimeSeries (
156
+ start ,
157
+ stop ,
158
+ Duration ("1 min" ),
159
+ False ,
160
+ )
161
+
162
+ tick = Epoch .system_now ()
163
+
164
+ states = almanac .transform_many (
165
+ Frames .EARTH_J2000 ,
166
+ Frames .SUN_J2000 ,
167
+ time_series ,
168
+ None ,
169
+ )
170
+
171
+ clock_time = Epoch .system_now ().timedelta (tick )
172
+ print (f"Queried { len (states )} states in { clock_time } " )
173
+ assert len (states ) == int (stop .timedelta (start ).to_unit (Unit .Minute ))
151
174
152
175
153
176
def test_convert_tpc ():
@@ -213,5 +236,5 @@ def test_frame_defs():
213
236
# test_meta_load()
214
237
# test_exports()
215
238
# test_frame_defs()
216
- test_convert_tpc ()
239
+ # test_convert_tpc()
217
240
test_state_transformation ()
0 commit comments