nrl-tracker 0.22.5__py3-none-any.whl → 1.7.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nrl_tracker-0.22.5.dist-info → nrl_tracker-1.7.5.dist-info}/METADATA +57 -10
- {nrl_tracker-0.22.5.dist-info → nrl_tracker-1.7.5.dist-info}/RECORD +84 -69
- pytcl/__init__.py +4 -3
- pytcl/assignment_algorithms/__init__.py +28 -0
- pytcl/assignment_algorithms/gating.py +10 -10
- pytcl/assignment_algorithms/jpda.py +40 -40
- pytcl/assignment_algorithms/nd_assignment.py +379 -0
- pytcl/assignment_algorithms/network_flow.py +371 -0
- pytcl/assignment_algorithms/three_dimensional/assignment.py +3 -3
- pytcl/astronomical/__init__.py +104 -3
- pytcl/astronomical/ephemerides.py +14 -11
- pytcl/astronomical/reference_frames.py +865 -56
- pytcl/astronomical/relativity.py +6 -5
- pytcl/astronomical/sgp4.py +710 -0
- pytcl/astronomical/special_orbits.py +532 -0
- pytcl/astronomical/tle.py +558 -0
- pytcl/atmosphere/__init__.py +43 -1
- pytcl/atmosphere/ionosphere.py +512 -0
- pytcl/atmosphere/nrlmsise00.py +809 -0
- pytcl/clustering/dbscan.py +2 -2
- pytcl/clustering/gaussian_mixture.py +3 -3
- pytcl/clustering/hierarchical.py +15 -15
- pytcl/clustering/kmeans.py +4 -4
- pytcl/containers/__init__.py +24 -0
- pytcl/containers/base.py +219 -0
- pytcl/containers/cluster_set.py +12 -2
- pytcl/containers/covertree.py +26 -29
- pytcl/containers/kd_tree.py +94 -29
- pytcl/containers/rtree.py +200 -1
- pytcl/containers/vptree.py +21 -28
- pytcl/coordinate_systems/conversions/geodetic.py +272 -5
- pytcl/coordinate_systems/jacobians/jacobians.py +2 -2
- pytcl/coordinate_systems/projections/__init__.py +1 -1
- pytcl/coordinate_systems/projections/projections.py +2 -2
- pytcl/coordinate_systems/rotations/rotations.py +10 -6
- pytcl/core/__init__.py +18 -0
- pytcl/core/validation.py +333 -2
- pytcl/dynamic_estimation/__init__.py +26 -0
- pytcl/dynamic_estimation/gaussian_sum_filter.py +434 -0
- pytcl/dynamic_estimation/imm.py +14 -14
- pytcl/dynamic_estimation/kalman/__init__.py +30 -0
- pytcl/dynamic_estimation/kalman/constrained.py +382 -0
- pytcl/dynamic_estimation/kalman/extended.py +8 -8
- pytcl/dynamic_estimation/kalman/h_infinity.py +613 -0
- pytcl/dynamic_estimation/kalman/square_root.py +60 -573
- pytcl/dynamic_estimation/kalman/sr_ukf.py +302 -0
- pytcl/dynamic_estimation/kalman/ud_filter.py +410 -0
- pytcl/dynamic_estimation/kalman/unscented.py +8 -6
- pytcl/dynamic_estimation/particle_filters/bootstrap.py +15 -15
- pytcl/dynamic_estimation/rbpf.py +589 -0
- pytcl/gravity/egm.py +13 -0
- pytcl/gravity/spherical_harmonics.py +98 -37
- pytcl/gravity/tides.py +6 -6
- pytcl/logging_config.py +328 -0
- pytcl/magnetism/__init__.py +7 -0
- pytcl/magnetism/emm.py +10 -3
- pytcl/magnetism/wmm.py +260 -23
- pytcl/mathematical_functions/combinatorics/combinatorics.py +5 -5
- pytcl/mathematical_functions/geometry/geometry.py +5 -5
- pytcl/mathematical_functions/numerical_integration/quadrature.py +6 -6
- pytcl/mathematical_functions/signal_processing/detection.py +24 -24
- pytcl/mathematical_functions/signal_processing/filters.py +14 -14
- pytcl/mathematical_functions/signal_processing/matched_filter.py +12 -12
- pytcl/mathematical_functions/special_functions/bessel.py +15 -3
- pytcl/mathematical_functions/special_functions/debye.py +136 -26
- pytcl/mathematical_functions/special_functions/error_functions.py +3 -1
- pytcl/mathematical_functions/special_functions/gamma_functions.py +4 -4
- pytcl/mathematical_functions/special_functions/hypergeometric.py +81 -15
- pytcl/mathematical_functions/transforms/fourier.py +8 -8
- pytcl/mathematical_functions/transforms/stft.py +12 -12
- pytcl/mathematical_functions/transforms/wavelets.py +9 -9
- pytcl/navigation/geodesy.py +246 -160
- pytcl/navigation/great_circle.py +101 -19
- pytcl/plotting/coordinates.py +7 -7
- pytcl/plotting/tracks.py +2 -2
- pytcl/static_estimation/maximum_likelihood.py +16 -14
- pytcl/static_estimation/robust.py +5 -5
- pytcl/terrain/loaders.py +5 -5
- pytcl/trackers/hypothesis.py +1 -1
- pytcl/trackers/mht.py +9 -9
- pytcl/trackers/multi_target.py +1 -1
- {nrl_tracker-0.22.5.dist-info → nrl_tracker-1.7.5.dist-info}/LICENSE +0 -0
- {nrl_tracker-0.22.5.dist-info → nrl_tracker-1.7.5.dist-info}/WHEEL +0 -0
- {nrl_tracker-0.22.5.dist-info → nrl_tracker-1.7.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Network flow solutions for assignment problems.
|
|
3
|
+
|
|
4
|
+
This module provides min-cost flow formulations for assignment problems,
|
|
5
|
+
offering an alternative to Hungarian algorithm and relaxation methods.
|
|
6
|
+
|
|
7
|
+
A min-cost flow approach:
|
|
8
|
+
1. Models assignment as flow network
|
|
9
|
+
2. Uses cost edges for penalties
|
|
10
|
+
3. Enforces supply/demand constraints
|
|
11
|
+
4. Finds minimum-cost flow solution
|
|
12
|
+
5. Extracts assignment from flow
|
|
13
|
+
|
|
14
|
+
References
|
|
15
|
+
----------
|
|
16
|
+
.. [1] Ahuja, R. K., Magnanti, T. L., & Orlin, J. B. (1993). Network Flows:
|
|
17
|
+
Theory, Algorithms, and Applications. Prentice-Hall.
|
|
18
|
+
.. [2] Costain, G., & Liang, H. (2012). An Auction Algorithm for the
|
|
19
|
+
Minimum Cost Flow Problem. CoRR, abs/1208.4859.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from enum import Enum
|
|
23
|
+
from typing import Any, NamedTuple, Tuple
|
|
24
|
+
|
|
25
|
+
import numpy as np
|
|
26
|
+
from numpy.typing import NDArray
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class FlowStatus(Enum):
|
|
30
|
+
"""Status of min-cost flow computation."""
|
|
31
|
+
|
|
32
|
+
OPTIMAL = 0
|
|
33
|
+
UNBOUNDED = 1
|
|
34
|
+
INFEASIBLE = 2
|
|
35
|
+
TIMEOUT = 3
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class MinCostFlowResult(NamedTuple):
|
|
39
|
+
"""Result of min-cost flow computation.
|
|
40
|
+
|
|
41
|
+
Attributes
|
|
42
|
+
----------
|
|
43
|
+
flow : ndarray
|
|
44
|
+
Flow values on each edge, shape (n_edges,).
|
|
45
|
+
cost : float
|
|
46
|
+
Total flow cost.
|
|
47
|
+
status : FlowStatus
|
|
48
|
+
Optimization status.
|
|
49
|
+
iterations : int
|
|
50
|
+
Number of iterations used.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
flow: NDArray[np.float64]
|
|
54
|
+
cost: float
|
|
55
|
+
status: FlowStatus
|
|
56
|
+
iterations: int
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class FlowEdge(NamedTuple):
|
|
60
|
+
"""Edge in a flow network.
|
|
61
|
+
|
|
62
|
+
Attributes
|
|
63
|
+
----------
|
|
64
|
+
from_node : int
|
|
65
|
+
Source node index.
|
|
66
|
+
to_node : int
|
|
67
|
+
Destination node index.
|
|
68
|
+
capacity : float
|
|
69
|
+
Maximum flow on edge (default 1.0 for assignment).
|
|
70
|
+
cost : float
|
|
71
|
+
Cost per unit flow.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
from_node: int
|
|
75
|
+
to_node: int
|
|
76
|
+
capacity: float
|
|
77
|
+
cost: float
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def assignment_to_flow_network(
|
|
81
|
+
cost_matrix: NDArray[np.float64],
|
|
82
|
+
) -> Tuple[list[FlowEdge], NDArray[np.floating], NDArray[Any]]:
|
|
83
|
+
"""
|
|
84
|
+
Convert 2D assignment problem to min-cost flow network.
|
|
85
|
+
|
|
86
|
+
Network structure:
|
|
87
|
+
- Source node (0) supplies all workers
|
|
88
|
+
- Worker nodes (1 to m) demand 1 unit each
|
|
89
|
+
- Task nodes (m+1 to m+n) supply 1 unit each
|
|
90
|
+
- Sink node (m+n+1) collects all completed tasks
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
cost_matrix : ndarray
|
|
95
|
+
Cost matrix of shape (m, n) where cost[i,j] is cost of
|
|
96
|
+
assigning worker i to task j.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
edges : list[FlowEdge]
|
|
101
|
+
List of edges in the flow network.
|
|
102
|
+
supplies : ndarray
|
|
103
|
+
Supply/demand at each node (shape n_nodes,).
|
|
104
|
+
Positive = supply, negative = demand.
|
|
105
|
+
node_names : ndarray
|
|
106
|
+
Names of nodes for reference.
|
|
107
|
+
"""
|
|
108
|
+
m, n = cost_matrix.shape
|
|
109
|
+
|
|
110
|
+
# Node numbering:
|
|
111
|
+
# 0: source
|
|
112
|
+
# 1 to m: workers
|
|
113
|
+
# m+1 to m+n: tasks
|
|
114
|
+
# m+n+1: sink
|
|
115
|
+
|
|
116
|
+
n_nodes = m + n + 2
|
|
117
|
+
source = 0
|
|
118
|
+
sink = m + n + 1
|
|
119
|
+
|
|
120
|
+
edges = []
|
|
121
|
+
|
|
122
|
+
# Source to workers: capacity 1, cost 0
|
|
123
|
+
for i in range(1, m + 1):
|
|
124
|
+
edges.append(FlowEdge(from_node=source, to_node=i, capacity=1.0, cost=0.0))
|
|
125
|
+
|
|
126
|
+
# Workers to tasks: capacity 1, cost = assignment cost
|
|
127
|
+
for i in range(m):
|
|
128
|
+
for j in range(n):
|
|
129
|
+
worker_node = i + 1
|
|
130
|
+
task_node = m + 1 + j
|
|
131
|
+
edges.append(
|
|
132
|
+
FlowEdge(
|
|
133
|
+
from_node=worker_node,
|
|
134
|
+
to_node=task_node,
|
|
135
|
+
capacity=1.0,
|
|
136
|
+
cost=cost_matrix[i, j],
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Tasks to sink: capacity 1, cost 0
|
|
141
|
+
for j in range(1, n + 1):
|
|
142
|
+
task_node = m + j
|
|
143
|
+
edges.append(
|
|
144
|
+
FlowEdge(from_node=task_node, to_node=sink, capacity=1.0, cost=0.0)
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
# Supply/demand: source supplies m units, sink demands m units
|
|
148
|
+
supplies = np.zeros(n_nodes)
|
|
149
|
+
supplies[source] = float(m)
|
|
150
|
+
supplies[sink] = float(-m)
|
|
151
|
+
|
|
152
|
+
node_names = np.array(
|
|
153
|
+
["source"]
|
|
154
|
+
+ [f"worker_{i}" for i in range(m)]
|
|
155
|
+
+ [f"task_{j}" for j in range(n)]
|
|
156
|
+
+ ["sink"]
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
return edges, supplies, node_names
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def min_cost_flow_successive_shortest_paths(
|
|
163
|
+
edges: list[FlowEdge],
|
|
164
|
+
supplies: NDArray[np.float64],
|
|
165
|
+
max_iterations: int = 1000,
|
|
166
|
+
) -> MinCostFlowResult:
|
|
167
|
+
"""
|
|
168
|
+
Solve min-cost flow using successive shortest paths.
|
|
169
|
+
|
|
170
|
+
Algorithm:
|
|
171
|
+
1. While there is excess supply:
|
|
172
|
+
- Find shortest path from a supply node to a demand node
|
|
173
|
+
- Push maximum feasible flow along path
|
|
174
|
+
- Update supplies and residual capacities
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
edges : list[FlowEdge]
|
|
179
|
+
List of edges with capacities and costs.
|
|
180
|
+
supplies : ndarray
|
|
181
|
+
Supply/demand at each node.
|
|
182
|
+
max_iterations : int, optional
|
|
183
|
+
Maximum iterations (default 1000).
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
MinCostFlowResult
|
|
188
|
+
Solution with flow values, cost, status, and iterations.
|
|
189
|
+
|
|
190
|
+
Notes
|
|
191
|
+
-----
|
|
192
|
+
This is a simplified implementation using Bellman-Ford for shortest
|
|
193
|
+
paths. Production code would use more efficient implementations.
|
|
194
|
+
"""
|
|
195
|
+
n_nodes = len(supplies)
|
|
196
|
+
n_edges = len(edges)
|
|
197
|
+
|
|
198
|
+
# Build adjacency lists for residual graph
|
|
199
|
+
graph: list[list[tuple[int, int, float]]] = [[] for _ in range(n_nodes)]
|
|
200
|
+
flow = np.zeros(n_edges)
|
|
201
|
+
residual_capacity = np.array([e.capacity for e in edges])
|
|
202
|
+
|
|
203
|
+
for edge_idx, edge in enumerate(edges):
|
|
204
|
+
graph[edge.from_node].append((edge.to_node, edge_idx, edge.cost))
|
|
205
|
+
# Add reverse edge with negative cost
|
|
206
|
+
graph[edge.to_node].append((edge.from_node, edge_idx, -edge.cost))
|
|
207
|
+
|
|
208
|
+
current_supplies = supplies.copy()
|
|
209
|
+
iteration = 0
|
|
210
|
+
|
|
211
|
+
while iteration < max_iterations:
|
|
212
|
+
# Find a node with excess supply
|
|
213
|
+
excess_node = None
|
|
214
|
+
for node in range(n_nodes):
|
|
215
|
+
if current_supplies[node] > 1e-10:
|
|
216
|
+
excess_node = node
|
|
217
|
+
break
|
|
218
|
+
|
|
219
|
+
if excess_node is None:
|
|
220
|
+
break
|
|
221
|
+
|
|
222
|
+
# Find a node with deficit
|
|
223
|
+
deficit_node = None
|
|
224
|
+
for node in range(n_nodes):
|
|
225
|
+
if current_supplies[node] < -1e-10:
|
|
226
|
+
deficit_node = node
|
|
227
|
+
break
|
|
228
|
+
|
|
229
|
+
if deficit_node is None:
|
|
230
|
+
break
|
|
231
|
+
|
|
232
|
+
# Find shortest path using Bellman-Ford relaxation
|
|
233
|
+
dist = np.full(n_nodes, np.inf)
|
|
234
|
+
dist[excess_node] = 0.0
|
|
235
|
+
parent = np.full(n_nodes, -1, dtype=int)
|
|
236
|
+
parent_edge = np.full(n_nodes, -1, dtype=int)
|
|
237
|
+
|
|
238
|
+
for _ in range(n_nodes - 1):
|
|
239
|
+
for u in range(n_nodes):
|
|
240
|
+
if dist[u] == np.inf:
|
|
241
|
+
continue
|
|
242
|
+
for v, edge_idx, cost in graph[u]:
|
|
243
|
+
if residual_capacity[edge_idx] > 1e-10:
|
|
244
|
+
new_dist = dist[u] + cost
|
|
245
|
+
if new_dist < dist[v]:
|
|
246
|
+
dist[v] = new_dist
|
|
247
|
+
parent[v] = u
|
|
248
|
+
parent_edge[v] = edge_idx
|
|
249
|
+
|
|
250
|
+
if dist[deficit_node] == np.inf:
|
|
251
|
+
# No path found
|
|
252
|
+
break
|
|
253
|
+
|
|
254
|
+
# Extract path and find bottleneck capacity
|
|
255
|
+
path_edges = []
|
|
256
|
+
node = deficit_node
|
|
257
|
+
while parent[node] != -1:
|
|
258
|
+
path_edges.append(parent_edge[node])
|
|
259
|
+
node = parent[node]
|
|
260
|
+
|
|
261
|
+
path_edges.reverse()
|
|
262
|
+
|
|
263
|
+
# Find minimum capacity along path
|
|
264
|
+
min_flow = min(residual_capacity[e] for e in path_edges)
|
|
265
|
+
min_flow = min(
|
|
266
|
+
min_flow, current_supplies[excess_node], -current_supplies[deficit_node]
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
# Push flow along path
|
|
270
|
+
total_cost = 0.0
|
|
271
|
+
for edge_idx in path_edges:
|
|
272
|
+
flow[edge_idx] += min_flow
|
|
273
|
+
residual_capacity[edge_idx] -= min_flow
|
|
274
|
+
total_cost += min_flow * edges[edge_idx].cost
|
|
275
|
+
|
|
276
|
+
current_supplies[excess_node] -= min_flow
|
|
277
|
+
current_supplies[deficit_node] += min_flow
|
|
278
|
+
|
|
279
|
+
iteration += 1
|
|
280
|
+
|
|
281
|
+
# Compute total cost
|
|
282
|
+
total_cost = float(np.sum(flow[i] * edges[i].cost for i in range(n_edges)))
|
|
283
|
+
|
|
284
|
+
# Determine status
|
|
285
|
+
if np.allclose(current_supplies, 0):
|
|
286
|
+
status = FlowStatus.OPTIMAL
|
|
287
|
+
elif iteration >= max_iterations:
|
|
288
|
+
status = FlowStatus.TIMEOUT
|
|
289
|
+
else:
|
|
290
|
+
status = FlowStatus.INFEASIBLE
|
|
291
|
+
|
|
292
|
+
return MinCostFlowResult(
|
|
293
|
+
flow=flow,
|
|
294
|
+
cost=total_cost,
|
|
295
|
+
status=status,
|
|
296
|
+
iterations=iteration,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def assignment_from_flow_solution(
|
|
301
|
+
flow: NDArray[np.float64],
|
|
302
|
+
edges: list[FlowEdge],
|
|
303
|
+
cost_matrix_shape: Tuple[int, int],
|
|
304
|
+
) -> Tuple[NDArray[np.intp], float]:
|
|
305
|
+
"""
|
|
306
|
+
Extract assignment from flow network solution.
|
|
307
|
+
|
|
308
|
+
Parameters
|
|
309
|
+
----------
|
|
310
|
+
flow : ndarray
|
|
311
|
+
Flow values on each edge.
|
|
312
|
+
edges : list[FlowEdge]
|
|
313
|
+
List of edges used in network.
|
|
314
|
+
cost_matrix_shape : tuple
|
|
315
|
+
Shape of original cost matrix (m, n).
|
|
316
|
+
|
|
317
|
+
Returns
|
|
318
|
+
-------
|
|
319
|
+
assignment : ndarray
|
|
320
|
+
Assignment array of shape (n_assignments, 2) with [worker, task].
|
|
321
|
+
cost : float
|
|
322
|
+
Total assignment cost.
|
|
323
|
+
"""
|
|
324
|
+
m, n = cost_matrix_shape
|
|
325
|
+
assignment = []
|
|
326
|
+
|
|
327
|
+
for edge_idx, edge in enumerate(edges):
|
|
328
|
+
# Worker-to-task edges: from_node in [1, m], to_node in [m+1, m+n]
|
|
329
|
+
if 1 <= edge.from_node <= m and m + 1 <= edge.to_node <= m + n:
|
|
330
|
+
if flow[edge_idx] > 0.5: # Flow > 0 (allowing for numerical tolerance)
|
|
331
|
+
worker_idx = edge.from_node - 1
|
|
332
|
+
task_idx = edge.to_node - m - 1
|
|
333
|
+
assignment.append([worker_idx, task_idx])
|
|
334
|
+
|
|
335
|
+
assignment = np.array(assignment, dtype=np.intp)
|
|
336
|
+
cost = 0.0
|
|
337
|
+
if len(assignment) > 0:
|
|
338
|
+
cost = float(
|
|
339
|
+
np.sum(
|
|
340
|
+
flow[edge_idx] * edges[edge_idx].cost for edge_idx in range(len(edges))
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
return assignment, cost
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def min_cost_assignment_via_flow(
|
|
348
|
+
cost_matrix: NDArray[np.float64],
|
|
349
|
+
) -> Tuple[NDArray[np.intp], float]:
|
|
350
|
+
"""
|
|
351
|
+
Solve 2D assignment problem via min-cost flow network.
|
|
352
|
+
|
|
353
|
+
Parameters
|
|
354
|
+
----------
|
|
355
|
+
cost_matrix : ndarray
|
|
356
|
+
Cost matrix of shape (m, n).
|
|
357
|
+
|
|
358
|
+
Returns
|
|
359
|
+
-------
|
|
360
|
+
assignment : ndarray
|
|
361
|
+
Assignment array of shape (n_assignments, 2).
|
|
362
|
+
total_cost : float
|
|
363
|
+
Total assignment cost.
|
|
364
|
+
"""
|
|
365
|
+
edges, supplies, _ = assignment_to_flow_network(cost_matrix)
|
|
366
|
+
result = min_cost_flow_successive_shortest_paths(edges, supplies)
|
|
367
|
+
assignment, cost = assignment_from_flow_solution(
|
|
368
|
+
result.flow, edges, cost_matrix.shape
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
return assignment, cost
|
|
@@ -11,7 +11,7 @@ cost subject to the constraint that each index appears in at most one
|
|
|
11
11
|
selected tuple.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
from typing import List, NamedTuple, Optional, Tuple
|
|
14
|
+
from typing import Any, List, NamedTuple, Optional, Tuple
|
|
15
15
|
|
|
16
16
|
import numpy as np
|
|
17
17
|
from numpy.typing import ArrayLike, NDArray
|
|
@@ -511,7 +511,7 @@ def assign3d_auction(
|
|
|
511
511
|
assign_i: List[Optional[Tuple[int, int]]] = [None] * n1
|
|
512
512
|
|
|
513
513
|
# Reverse: which i is assigned to (j, k)
|
|
514
|
-
reverse: dict = {}
|
|
514
|
+
reverse: dict[tuple[int, int], int] = {}
|
|
515
515
|
|
|
516
516
|
converged = False
|
|
517
517
|
|
|
@@ -585,7 +585,7 @@ def assign3d(
|
|
|
585
585
|
cost_tensor: ArrayLike,
|
|
586
586
|
method: str = "lagrangian",
|
|
587
587
|
maximize: bool = False,
|
|
588
|
-
**kwargs,
|
|
588
|
+
**kwargs: Any,
|
|
589
589
|
) -> Assignment3DResult:
|
|
590
590
|
"""
|
|
591
591
|
Solve 3D assignment problem.
|
pytcl/astronomical/__init__.py
CHANGED
|
@@ -77,30 +77,46 @@ from pytcl.astronomical.orbital_mechanics import (
|
|
|
77
77
|
vis_viva,
|
|
78
78
|
)
|
|
79
79
|
from pytcl.astronomical.reference_frames import (
|
|
80
|
-
earth_rotation_angle, # Time utilities; Precession; Nutation
|
|
80
|
+
earth_rotation_angle, # Time utilities; Precession; Nutation
|
|
81
81
|
)
|
|
82
|
+
from pytcl.astronomical.reference_frames import ecef_to_eci # Time utilities
|
|
82
83
|
from pytcl.astronomical.reference_frames import (
|
|
83
|
-
ecef_to_eci,
|
|
84
84
|
eci_to_ecef,
|
|
85
85
|
ecliptic_to_equatorial,
|
|
86
86
|
equation_of_equinoxes,
|
|
87
87
|
equatorial_to_ecliptic,
|
|
88
88
|
gast_iau82,
|
|
89
89
|
gcrf_to_itrf,
|
|
90
|
+
gcrf_to_mod,
|
|
91
|
+
gcrf_to_teme,
|
|
92
|
+
gcrf_to_tod,
|
|
90
93
|
gmst_iau82,
|
|
91
94
|
itrf_to_gcrf,
|
|
95
|
+
itrf_to_teme,
|
|
96
|
+
itrf_to_teme_with_velocity,
|
|
97
|
+
itrf_to_tod,
|
|
92
98
|
julian_centuries_j2000,
|
|
93
99
|
mean_obliquity_iau80,
|
|
100
|
+
mod_to_gcrf,
|
|
101
|
+
mod_to_tod,
|
|
94
102
|
nutation_angles_iau80,
|
|
95
103
|
nutation_matrix,
|
|
104
|
+
pef_to_teme,
|
|
96
105
|
polar_motion_matrix,
|
|
97
106
|
precession_angles_iau76,
|
|
98
107
|
precession_matrix_iau76,
|
|
99
108
|
sidereal_rotation_matrix,
|
|
109
|
+
teme_to_gcrf,
|
|
110
|
+
teme_to_itrf,
|
|
111
|
+
teme_to_itrf_with_velocity,
|
|
112
|
+
teme_to_pef,
|
|
113
|
+
tod_to_gcrf,
|
|
114
|
+
tod_to_itrf,
|
|
115
|
+
tod_to_mod,
|
|
100
116
|
true_obliquity,
|
|
101
117
|
)
|
|
102
118
|
from pytcl.astronomical.relativity import (
|
|
103
|
-
C_LIGHT, # Physical constants; Schwarzschild metric; Time dilation
|
|
119
|
+
C_LIGHT, # Physical constants; Schwarzschild metric; Time dilation
|
|
104
120
|
)
|
|
105
121
|
from pytcl.astronomical.relativity import (
|
|
106
122
|
G_GRAV,
|
|
@@ -114,6 +130,30 @@ from pytcl.astronomical.relativity import (
|
|
|
114
130
|
schwarzschild_radius,
|
|
115
131
|
shapiro_delay,
|
|
116
132
|
)
|
|
133
|
+
from pytcl.astronomical.sgp4 import (
|
|
134
|
+
SGP4Satellite,
|
|
135
|
+
SGP4State,
|
|
136
|
+
sgp4_propagate,
|
|
137
|
+
sgp4_propagate_batch,
|
|
138
|
+
)
|
|
139
|
+
from pytcl.astronomical.special_orbits import (
|
|
140
|
+
OrbitType,
|
|
141
|
+
classify_orbit,
|
|
142
|
+
eccentricity_vector,
|
|
143
|
+
escape_velocity_at_radius,
|
|
144
|
+
hyperbolic_anomaly_to_true_anomaly,
|
|
145
|
+
hyperbolic_asymptote_angle,
|
|
146
|
+
hyperbolic_deflection_angle,
|
|
147
|
+
hyperbolic_excess_velocity,
|
|
148
|
+
mean_to_parabolic_anomaly,
|
|
149
|
+
mean_to_true_anomaly_parabolic,
|
|
150
|
+
parabolic_anomaly_to_true_anomaly,
|
|
151
|
+
radius_parabolic,
|
|
152
|
+
semi_major_axis_from_energy,
|
|
153
|
+
true_anomaly_to_hyperbolic_anomaly,
|
|
154
|
+
true_anomaly_to_parabolic_anomaly,
|
|
155
|
+
velocity_parabolic,
|
|
156
|
+
)
|
|
117
157
|
from pytcl.astronomical.time_systems import (
|
|
118
158
|
JD_GPS_EPOCH, # Julian dates; Time scales; Unix time; GPS week; Sidereal time; Leap seconds; Constants
|
|
119
159
|
)
|
|
@@ -145,6 +185,17 @@ from pytcl.astronomical.time_systems import (
|
|
|
145
185
|
utc_to_tai,
|
|
146
186
|
utc_to_tt,
|
|
147
187
|
)
|
|
188
|
+
from pytcl.astronomical.tle import (
|
|
189
|
+
TLE,
|
|
190
|
+
format_tle,
|
|
191
|
+
is_deep_space,
|
|
192
|
+
orbital_period_from_tle,
|
|
193
|
+
parse_tle,
|
|
194
|
+
parse_tle_3line,
|
|
195
|
+
semi_major_axis_from_mean_motion,
|
|
196
|
+
tle_epoch_to_datetime,
|
|
197
|
+
tle_epoch_to_jd,
|
|
198
|
+
)
|
|
148
199
|
|
|
149
200
|
__all__ = [
|
|
150
201
|
# Time systems - Julian dates
|
|
@@ -251,6 +302,39 @@ __all__ = [
|
|
|
251
302
|
# Reference frames - Ecliptic/equatorial
|
|
252
303
|
"ecliptic_to_equatorial",
|
|
253
304
|
"equatorial_to_ecliptic",
|
|
305
|
+
# Reference frames - TEME (for SGP4/SDP4)
|
|
306
|
+
"teme_to_pef",
|
|
307
|
+
"pef_to_teme",
|
|
308
|
+
"teme_to_itrf",
|
|
309
|
+
"itrf_to_teme",
|
|
310
|
+
"teme_to_gcrf",
|
|
311
|
+
"gcrf_to_teme",
|
|
312
|
+
"teme_to_itrf_with_velocity",
|
|
313
|
+
"itrf_to_teme_with_velocity",
|
|
314
|
+
# Reference frames - TOD/MOD (legacy conventions)
|
|
315
|
+
"gcrf_to_mod",
|
|
316
|
+
"mod_to_gcrf",
|
|
317
|
+
"gcrf_to_tod",
|
|
318
|
+
"tod_to_gcrf",
|
|
319
|
+
"mod_to_tod",
|
|
320
|
+
"tod_to_mod",
|
|
321
|
+
"tod_to_itrf",
|
|
322
|
+
"itrf_to_tod",
|
|
323
|
+
# TLE parsing
|
|
324
|
+
"TLE",
|
|
325
|
+
"parse_tle",
|
|
326
|
+
"parse_tle_3line",
|
|
327
|
+
"tle_epoch_to_jd",
|
|
328
|
+
"tle_epoch_to_datetime",
|
|
329
|
+
"format_tle",
|
|
330
|
+
"is_deep_space",
|
|
331
|
+
"semi_major_axis_from_mean_motion",
|
|
332
|
+
"orbital_period_from_tle",
|
|
333
|
+
# SGP4/SDP4 propagation
|
|
334
|
+
"SGP4State",
|
|
335
|
+
"SGP4Satellite",
|
|
336
|
+
"sgp4_propagate",
|
|
337
|
+
"sgp4_propagate_batch",
|
|
254
338
|
# Ephemerides - Classes
|
|
255
339
|
"DEEphemeris",
|
|
256
340
|
# Ephemerides - Functions
|
|
@@ -271,4 +355,21 @@ __all__ = [
|
|
|
271
355
|
"geodetic_precession",
|
|
272
356
|
"lense_thirring_precession",
|
|
273
357
|
"relativistic_range_correction",
|
|
358
|
+
# Special orbits - Parabolic and hyperbolic
|
|
359
|
+
"OrbitType",
|
|
360
|
+
"classify_orbit",
|
|
361
|
+
"mean_to_parabolic_anomaly",
|
|
362
|
+
"parabolic_anomaly_to_true_anomaly",
|
|
363
|
+
"true_anomaly_to_parabolic_anomaly",
|
|
364
|
+
"mean_to_true_anomaly_parabolic",
|
|
365
|
+
"radius_parabolic",
|
|
366
|
+
"velocity_parabolic",
|
|
367
|
+
"hyperbolic_anomaly_to_true_anomaly",
|
|
368
|
+
"true_anomaly_to_hyperbolic_anomaly",
|
|
369
|
+
"escape_velocity_at_radius",
|
|
370
|
+
"hyperbolic_excess_velocity",
|
|
371
|
+
"semi_major_axis_from_energy",
|
|
372
|
+
"hyperbolic_asymptote_angle",
|
|
373
|
+
"hyperbolic_deflection_angle",
|
|
374
|
+
"eccentricity_vector",
|
|
274
375
|
]
|
|
@@ -49,9 +49,10 @@ References
|
|
|
49
49
|
|
|
50
50
|
"""
|
|
51
51
|
|
|
52
|
-
from typing import Literal, Optional, Tuple
|
|
52
|
+
from typing import Any, Literal, Optional, Tuple
|
|
53
53
|
|
|
54
54
|
import numpy as np
|
|
55
|
+
from numpy.typing import NDArray
|
|
55
56
|
|
|
56
57
|
# Constants for unit conversion
|
|
57
58
|
AU_PER_KM = 1.0 / 149597870.7 # 1 AU in km
|
|
@@ -152,10 +153,10 @@ class DEEphemeris:
|
|
|
152
153
|
self.version = version
|
|
153
154
|
self._jplephem = jplephem
|
|
154
155
|
self._kernel: Optional[object] = None
|
|
155
|
-
self._cache: dict = {}
|
|
156
|
+
self._cache: dict[str, Any] = {}
|
|
156
157
|
|
|
157
158
|
@property
|
|
158
|
-
def kernel(self):
|
|
159
|
+
def kernel(self) -> Optional[object]:
|
|
159
160
|
"""Lazy-load ephemeris kernel on first access.
|
|
160
161
|
|
|
161
162
|
Note: This requires jplephem to be installed and the kernel file
|
|
@@ -204,7 +205,7 @@ class DEEphemeris:
|
|
|
204
205
|
|
|
205
206
|
def sun_position(
|
|
206
207
|
self, jd: float, frame: Literal["icrf", "ecliptic"] = "icrf"
|
|
207
|
-
) -> Tuple[np.
|
|
208
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
208
209
|
"""Compute Sun position and velocity.
|
|
209
210
|
|
|
210
211
|
Parameters
|
|
@@ -253,7 +254,7 @@ class DEEphemeris:
|
|
|
253
254
|
|
|
254
255
|
def moon_position(
|
|
255
256
|
self, jd: float, frame: Literal["icrf", "ecliptic", "earth_centered"] = "icrf"
|
|
256
|
-
) -> Tuple[np.
|
|
257
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
257
258
|
"""Compute Moon position and velocity.
|
|
258
259
|
|
|
259
260
|
Parameters
|
|
@@ -323,7 +324,7 @@ class DEEphemeris:
|
|
|
323
324
|
],
|
|
324
325
|
jd: float,
|
|
325
326
|
frame: Literal["icrf", "ecliptic"] = "icrf",
|
|
326
|
-
) -> Tuple[np.ndarray, np.ndarray]:
|
|
327
|
+
) -> Tuple[np.ndarray[Any, Any], np.ndarray[Any, Any]]:
|
|
327
328
|
"""Compute planet position and velocity.
|
|
328
329
|
|
|
329
330
|
Parameters
|
|
@@ -379,7 +380,7 @@ class DEEphemeris:
|
|
|
379
380
|
|
|
380
381
|
def barycenter_position(
|
|
381
382
|
self, body: str, jd: float
|
|
382
|
-
) -> Tuple[np.
|
|
383
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
383
384
|
"""Compute position of any body relative to Solar System Barycenter.
|
|
384
385
|
|
|
385
386
|
Parameters
|
|
@@ -424,7 +425,7 @@ def _get_default_ephemeris() -> DEEphemeris:
|
|
|
424
425
|
|
|
425
426
|
def sun_position(
|
|
426
427
|
jd: float, frame: Literal["icrf", "ecliptic"] = "icrf"
|
|
427
|
-
) -> Tuple[np.
|
|
428
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
428
429
|
"""Convenience function: Compute Sun position and velocity.
|
|
429
430
|
|
|
430
431
|
Parameters
|
|
@@ -451,7 +452,7 @@ def sun_position(
|
|
|
451
452
|
|
|
452
453
|
def moon_position(
|
|
453
454
|
jd: float, frame: Literal["icrf", "ecliptic", "earth_centered"] = "icrf"
|
|
454
|
-
) -> Tuple[np.
|
|
455
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
455
456
|
"""Convenience function: Compute Moon position and velocity.
|
|
456
457
|
|
|
457
458
|
Parameters
|
|
@@ -482,7 +483,7 @@ def planet_position(
|
|
|
482
483
|
],
|
|
483
484
|
jd: float,
|
|
484
485
|
frame: Literal["icrf", "ecliptic"] = "icrf",
|
|
485
|
-
) -> Tuple[np.ndarray, np.ndarray]:
|
|
486
|
+
) -> Tuple[np.ndarray[Any, Any], np.ndarray[Any, Any]]:
|
|
486
487
|
"""Convenience function: Compute planet position and velocity.
|
|
487
488
|
|
|
488
489
|
Parameters
|
|
@@ -509,7 +510,9 @@ def planet_position(
|
|
|
509
510
|
return _get_default_ephemeris().planet_position(planet, jd, frame=frame)
|
|
510
511
|
|
|
511
512
|
|
|
512
|
-
def barycenter_position(
|
|
513
|
+
def barycenter_position(
|
|
514
|
+
body: str, jd: float
|
|
515
|
+
) -> Tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
513
516
|
"""Convenience function: Position relative to Solar System Barycenter.
|
|
514
517
|
|
|
515
518
|
Parameters
|