18
18
AngularVelocity ,
19
19
)
20
20
21
- CANONICAL_FORMAT : str = r"(r|v)_(.*?)_(x|y|z)"
21
+ POS_VEL_CANONICAL_FORMAT : str = r"(r|v)_(.*?)_(x|y|z)"
22
22
23
23
24
24
def custom_class_generator (frame : Frame , coordinate_subsets : list ) -> type :
@@ -68,6 +68,7 @@ def from_dict(data: dict) -> State:
68
68
- 'drag_coefficient'/'cd': The drag coefficient. Optional.
69
69
- 'cross_sectional_area'/'surface_area': The cross-sectional area. Optional.
70
70
- 'mass': The mass. Optional.
71
+ - 'ballistic_coefficient'/'bc': The ballistic coefficient. Optional.
71
72
72
73
Args:
73
74
data (dict): The dictionary.
@@ -76,7 +77,7 @@ def from_dict(data: dict) -> State:
76
77
State: The State.
77
78
"""
78
79
79
- instant : Instant = coerce_to_instant ( data [ "timestamp" ])
80
+ # Position and velocity subsets
80
81
81
82
eci_columns : list [str ] = [
82
83
"rx_eci" ,
@@ -123,7 +124,7 @@ def from_dict(data: dict) -> State:
123
124
]
124
125
125
126
match_groups : list [re .Match ] = [
126
- re .match (CANONICAL_FORMAT , column ) for column in data .keys ()
127
+ re .match (POS_VEL_CANONICAL_FORMAT , column ) for column in data .keys ()
127
128
]
128
129
129
130
if len (matches := [match for match in match_groups if match is not None ]) == 6 :
@@ -188,6 +189,8 @@ def from_dict(data: dict) -> State:
188
189
else :
189
190
raise ValueError ("Invalid state data." )
190
191
192
+ # Attitude and angular velocity subsets
193
+
191
194
if all (
192
195
column in data for column in ["q_B_ECI_x" , "q_B_ECI_y" , "q_B_ECI_z" , "q_B_ECI_s" ]
193
196
):
@@ -216,6 +219,8 @@ def from_dict(data: dict) -> State:
216
219
],
217
220
)
218
221
222
+ # Extra subsets
223
+
219
224
if (data .get ("drag_coefficient" ) is not None ) or (data .get ("cd" ) is not None ):
220
225
coordinate_subsets .append (CoordinateSubset .drag_coefficient ())
221
226
coordinates = np .append (
@@ -239,8 +244,15 @@ def from_dict(data: dict) -> State:
239
244
data ["mass" ],
240
245
)
241
246
247
+ if (data .get ("ballistic_coefficient" ) is not None ) or (data .get ("bc" ) is not None ):
248
+ coordinate_subsets .append (CoordinateSubset .ballistic_coefficient ())
249
+ coordinates = np .append (
250
+ coordinates ,
251
+ data .get ("ballistic_coefficient" , data .get ("bc" )),
252
+ )
253
+
242
254
return State (
243
- instant = instant ,
255
+ instant = coerce_to_instant ( data [ "timestamp" ]) ,
244
256
coordinates = coordinates ,
245
257
frame = frame ,
246
258
coordinate_subsets = coordinate_subsets ,
0 commit comments