Skip to content

Commit

Permalink
Merge pull request #153 from nyx-space/26-support-of-aberration-corre…
Browse files Browse the repository at this point in the history
…ctions

Add support of aberration corrections
  • Loading branch information
ChristopherRabotin committed Jan 9, 2024
2 parents 94c7653 + 72b0d47 commit edb43c7
Show file tree
Hide file tree
Showing 31 changed files with 948 additions and 196 deletions.
4 changes: 0 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
data/*.bsp filter=lfs diff=lfs merge=lfs -text
data/*.bpc filter=lfs diff=lfs merge=lfs -text
data/de421.anise filter=lfs diff=lfs merge=lfs -text
data/de430.anise filter=lfs diff=lfs merge=lfs -text
data/de438s.anise filter=lfs diff=lfs merge=lfs -text
data/de440.anise filter=lfs diff=lfs merge=lfs -text
data/*.pca filter=lfs diff=lfs merge=lfs -text
13 changes: 11 additions & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
wget -O data/gmat-hermite.bsp http://public-data.nyxspace.com/anise/ci/gmat-hermite.bsp
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ jobs:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
- uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -172,8 +178,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
- name: Build sdist
uses: PyO3/maturin-action@v1
Expand Down
53 changes: 41 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
wget -O data/gmat-hermite.bsp http://public-data.nyxspace.com/anise/ci/gmat-hermite.bsp
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -93,8 +102,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
wget -O data/gmat-hermite.bsp http://public-data.nyxspace.com/anise/ci/gmat-hermite.bsp
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -150,8 +168,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true

- name: Download data
run: |
wget -O data/de421.bsp http://public-data.nyxspace.com/anise/de421.bsp
wget -O data/de430.bsp http://public-data.nyxspace.com/anise/de430.bsp
wget -O data/de440s.bsp http://public-data.nyxspace.com/anise/de440s.bsp
wget -O data/de440.bsp http://public-data.nyxspace.com/anise/de440.bsp
wget -O data/pck08.pca http://public-data.nyxspace.com/anise/pck08.pca
wget -O data/gmat-hermite.bsp http://public-data.nyxspace.com/anise/ci/gmat-hermite.bsp
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -169,13 +196,15 @@ jobs:

- name: Generate coverage report
run: |
cd anise # Prevent the workspace flag
cargo llvm-cov clean --workspace
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report -- --test-threads=1
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report --tests -- compile_fail
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_iau_rotation_to_parent -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_bpc_to_iau_rotations -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_jplde_de440s --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_hermite_type13_from_gmat --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report -- --test-threads=1
cargo llvm-cov test --no-report --tests -- compile_fail
cargo llvm-cov test --no-report validate_iau_rotation_to_parent -- --nocapture --ignored
cargo llvm-cov test --no-report validate_bpc_to_iau_rotations -- --nocapture --ignored
cargo llvm-cov test --no-report validate_jplde_de440s_no_aberration --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report validate_jplde_de440s_aberration_lt --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report validate_hermite_type13_from_gmat --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov report --lcov > lcov.txt
env:
RUSTFLAGS: --cfg __ui_tests
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["anise", "anise-cli", "anise-gui", "anise-py"]

[workspace.package]
version = "0.1.0"
version = "0.2.0"
edition = "2021"
authors = ["Christopher Rabotin <[email protected]>"]
description = "ANISE provides a toolkit and files for Attitude, Navigation, Instrument, Spacecraft, and Ephemeris data. It's a modern replacement of NAIF SPICE file."
Expand All @@ -26,7 +26,7 @@ exclude = [
]

[workspace.dependencies]
hifitime = { version = "3.8.6", default-features = true }
hifitime = { version = "3.9.0", default-features = true }
memmap2 = "=0.9.3"
crc32fast = "=1.3.2"
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }
Expand All @@ -45,7 +45,7 @@ rstest = "0.18.2"
pyo3 = { version = "0.20.0", features = ["multiple-pymethods"] }
pyo3-log = "0.9.0"

anise = { version = "0.1.0", path = "anise", default-features = false }
anise = { version = "0.2.0", path = "anise", default-features = false }

[profile.bench]
debug = true
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let orig_state = Orbit::keplerian(

// Transform that orbit into another frame.
let state_itrf93 = almanac
.transform_to(orig_state, EARTH_ITRF93, Aberration::NotSet)
.transform_to(orig_state, EARTH_ITRF93, None)
.unwrap();

// The `:x` prints this orbit's Keplerian elements
Expand All @@ -109,7 +109,7 @@ println!("{state_itrf93:X}");

// Convert back
let from_state_itrf93_to_eme2k = almanac
.transform_to(state_itrf93, EARTH_J2000, Aberration::NotSet)
.transform_to(state_itrf93, EARTH_J2000, Aberration::NONE)
.unwrap();

println!("{from_state_itrf93_to_eme2k}");
Expand Down Expand Up @@ -181,11 +181,11 @@ let ctx = Almanac::from_spk(spk).unwrap();
let epoch = Epoch::from_str("2020-11-15 12:34:56.789 TDB").unwrap();

let state = ctx
.translate_from_to(
VENUS_J2000,
EARTH_MOON_BARYCENTER_J2000,
.translate(
VENUS_J2000, // Target
EARTH_MOON_BARYCENTER_J2000, // Observer
epoch,
Aberration::NotSet,
None,
)
.unwrap();

Expand Down Expand Up @@ -242,7 +242,7 @@ def test_state_transformation():
assert orig_state.tlong_deg() == 0.6916999999999689

state_itrf93 = ctx.transform_to(
orig_state, Frames.EARTH_ITRF93, Aberration.NotSet
orig_state, Frames.EARTH_ITRF93, None
)

print(orig_state)
Expand All @@ -254,7 +254,7 @@ def test_state_transformation():

# Convert back
from_state_itrf93_to_eme2k = ctx.transform_to(
state_itrf93, Frames.EARTH_J2000, Aberration.NotSet
state_itrf93, Frames.EARTH_J2000, None
)

print(from_state_itrf93_to_eme2k)
Expand Down
3 changes: 2 additions & 1 deletion anise-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Documentation: https://nyxspace.com/
*/

use ::anise::almanac::meta::MetaAlmanac;
use ::anise::almanac::meta::{MetaAlmanac, MetaFile};
use ::anise::almanac::Almanac;
use ::anise::astro::Aberration;
use hifitime::leap_seconds::{LatestLeapSeconds, LeapSecondsFile};
Expand All @@ -28,6 +28,7 @@ fn anise(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Almanac>()?;
m.add_class::<Aberration>()?;
m.add_class::<MetaAlmanac>()?;
m.add_class::<MetaFile>()?;
Ok(())
}

Expand Down
42 changes: 31 additions & 11 deletions anise-py/tests/test_almanac.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
from pathlib import Path
import pickle

from anise import Aberration, Almanac, MetaAlmanac
from anise import Almanac, MetaAlmanac
from anise.astro import *
from anise.astro.constants import Frames
from anise.time import Epoch

from os import environ


def test_state_transformation():
"""
This is the Python equivalent to anise/tests/almanac/mod.rs
but the data is loaded from the remote servers
"""
data_path = Path(__file__).parent.joinpath("..", "..", "data")
# Must ensure that the path is a string
ctx = Almanac(str(data_path.joinpath("de440s.bsp")))
# Let's add another file here -- note that the Almanac will load into a NEW variable, so we must overwrite it!
# This prevents memory leaks (yes, I promise)
ctx = ctx.load(str(data_path.joinpath("pck08.pca"))).load(
str(data_path.joinpath("earth_latest_high_prec.bpc"))
)

if environ.get("CI", False):
# # Load from meta kernel to not use Git LFS quota
# data_path = Path(__file__).parent.joinpath("..", "..", "data", "default_meta.dhall")
# meta = MetaAlmanac(str(data_path))
# print(meta)
# # Process the files to be loaded
# ctx = meta.process()
print("I don't know where the files are in the Python CI")

return
else:
data_path = Path(__file__).parent.joinpath("..", "..", "data")
# Must ensure that the path is a string
ctx = Almanac(str(data_path.joinpath("de440s.bsp")))
# Let's add another file here -- note that the Almanac will load into a NEW variable, so we must overwrite it!
# This prevents memory leaks (yes, I promise)
ctx = ctx.load(str(data_path.joinpath("pck08.pca"))).load(
str(data_path.joinpath("earth_latest_high_prec.bpc"))
)

eme2k = ctx.frame_info(Frames.EME2000)
assert eme2k.mu_km3_s2() == 398600.435436096
assert eme2k.shape.polar_radius_km == 6356.75
Expand All @@ -43,7 +59,10 @@ def test_state_transformation():
assert abs(orig_state.raan_deg() - 306.614) < 1e-10
assert abs(orig_state.tlong_deg() - 0.6916999999999689) < 1e-10

state_itrf93 = ctx.transform_to(orig_state, Frames.EARTH_ITRF93, Aberration.NotSet)
# In Python, we can set the aberration to None
aberration = None

state_itrf93 = ctx.transform_to(orig_state, Frames.EARTH_ITRF93, aberration)

print(orig_state)
print(state_itrf93)
Expand All @@ -54,7 +73,7 @@ def test_state_transformation():

# Convert back
from_state_itrf93_to_eme2k = ctx.transform_to(
state_itrf93, Frames.EARTH_J2000, Aberration.NotSet
state_itrf93, Frames.EARTH_J2000, aberration
)

print(from_state_itrf93_to_eme2k)
Expand Down Expand Up @@ -102,6 +121,7 @@ def test_meta_load():
assert eme2k.shape.polar_radius_km == 6356.75
assert abs(eme2k.shape.flattening() - 0.0033536422844278) < 2e-16


def test_exports():
for cls in [Frame, Ellipsoid, Orbit]:
print(f"{cls} OK")
Expand Down
2 changes: 1 addition & 1 deletion anise/benches/crit_jpl_ephemerides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn benchmark_spice_single_hop_type2_cheby(time_it: TimeSeries) {
fn benchmark_anise_single_hop_type2_cheby(ctx: &Almanac, time_it: TimeSeries) {
for epoch in time_it {
black_box(
ctx.translate_from_to_geometric(EARTH_J2000, LUNA_J2000, epoch)
ctx.translate_geometric(EARTH_J2000, LUNA_J2000, epoch)
.unwrap(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion anise/benches/crit_spacecraft_ephemeris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn benchmark_anise_single_hop_type13_hermite(ctx: &Almanac, time_it: TimeSeries)
let my_sc_j2k = Frame::from_ephem_j2000(-10000001);
for epoch in time_it {
black_box(
ctx.translate_from_to_geometric(my_sc_j2k, EARTH_J2000, epoch)
ctx.translate_geometric(my_sc_j2k, EARTH_J2000, epoch)
.unwrap(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion anise/benches/iai_jpl_ephemerides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn benchmark_anise_single_hop_type2_cheby() {

for epoch in time_it {
black_box(
ctx.translate_from_to_geometric(EARTH_J2000, LUNA_J2000, epoch)
ctx.translate_geometric(EARTH_J2000, LUNA_J2000, epoch)
.unwrap(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion anise/benches/iai_spacecraft_ephemeris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn benchmark_anise_single_hop_type13_hermite() {
let my_sc_j2k = Frame::from_ephem_j2000(-10000001);

black_box(
ctx.translate_from_to_geometric(my_sc_j2k, EARTH_J2000, epoch)
ctx.translate_geometric(my_sc_j2k, EARTH_J2000, epoch)
.unwrap(),
);
}
Expand Down
Loading

0 comments on commit edb43c7

Please sign in to comment.