-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VariantOrbits.collapse -- collapses variants orbits at different …
…epochs and recomputes the covariance matrix
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
|
||
from ...utils.helpers.orbits import make_real_orbits | ||
from ..variants import VariantOrbits | ||
|
||
|
||
def test_VariantOrbits(): | ||
|
||
# Get a sample of real orbits | ||
orbits = make_real_orbits(10) | ||
|
||
# Create a variant orbits object (expands the covariance matrix) | ||
# around the mean state | ||
variant_orbits = VariantOrbits.create(orbits) | ||
|
||
# For these 10 orbits this will select sigma-points so lets | ||
# check that the number of sigma-points is correct | ||
assert len(variant_orbits) == len(orbits) * 13 | ||
|
||
# Now lets collapse the sigma-points back and see if we can reconstruct | ||
# the input covairance matrix | ||
collapsed_orbits = variant_orbits.collapse(orbits) | ||
|
||
# Check that the covariance matrices are close | ||
np.testing.assert_allclose( | ||
collapsed_orbits.coordinates.covariance.to_matrix(), | ||
orbits.coordinates.covariance.to_matrix(), | ||
rtol=0, | ||
atol=1e-14, | ||
) | ||
|
||
# Check that the orbit ids are the same | ||
np.testing.assert_equal( | ||
collapsed_orbits.orbit_id.to_numpy(zero_copy_only=False), | ||
orbits.orbit_id.to_numpy(zero_copy_only=False), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters