Skip to content

Commit 81ca703

Browse files
Merge pull request #496 from nyx-space/feat/spk-type1-modified-diff
Implement SPK Type 01 Modified Differences
2 parents b6308d6 + 1f4632f commit 81ca703

File tree

17 files changed

+458
-24
lines changed

17 files changed

+458
-24
lines changed

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[env]
22
CSPICE_DIR = {value = "./cspice/", relative = true}
3+
4+
# [target.x86_64-unknown-linux-gnu]
5+
# For flamegraph -- https://github.com/flamegraph-rs/flamegraph
6+
# linker = "/usr/bin/clang"
7+
# rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]

.github/workflows/python.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
# Source: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145
4747
# If we're running on rhel centos, install needed packages.
4848
if command -v yum &> /dev/null; then
49+
echo "CENTOS"
4950
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic
5051
5152
# If we're running on i686 we need to symlink libatomic
@@ -55,6 +56,7 @@ jobs:
5556
fi
5657
else
5758
# If we're running on debian-based system.
59+
echo "DEBIAN LIKE"
5860
apt update -y && apt-get install -y libssl-dev openssl pkg-config
5961
fi
6062

.github/workflows/rust.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
5555
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
5656
wget -O data/lro.bsp http://public-data.nyxspace.com/nyx/examples/lrorg_2023349_2024075_v01_LE.bsp
57+
wget -O data/mro.bsp https://naif.jpl.nasa.gov/pub/naif/MRO/kernels/spk/spk_psp_rec89118_89113_89888_p-v1.bsp
5758
5859
- name: Install stable toolchain
5960
uses: dtolnay/rust-toolchain@stable
@@ -119,6 +120,7 @@ jobs:
119120
wget -O data/variable-seg-size-hermite.bsp http://public-data.nyxspace.com/anise/ci/variable-seg-size-hermite.bsp
120121
wget -O data/earth_latest_high_prec.bpc http://public-data.nyxspace.com/anise/ci/earth_latest_high_prec-2023-09-08.bpc
121122
wget -O data/lro.bsp http://public-data.nyxspace.com/nyx/examples/lrorg_2023349_2024075_v01_LE.bsp
123+
wget -O data/mro.bsp https://naif.jpl.nasa.gov/pub/naif/MRO/kernels/spk/spk_psp_rec89118_89113_89888_p-v1.bsp
122124
123125
- name: Install stable toolchain
124126
uses: dtolnay/rust-toolchain@stable
@@ -146,6 +148,9 @@ jobs:
146148
LAGRANGE_BSP: gmat-lagrange.bsp
147149
run: RUST_BACKTRACE=1 cargo test validate_lagrange_type9_with_varying_segment_sizes --features validation --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1
148150

151+
- name: Rust-SPICE Modified Difference validation
152+
run: RUST_BACKTRACE=1 cargo test validate_modified_diff_type01 --features validation --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1
153+
149154
- name: Rust-SPICE PCK validation
150155
run: RUST_BACKTRACE=1 cargo test validate_iau_rotation_to_parent --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --ignored
151156

@@ -195,6 +200,7 @@ jobs:
195200
wget -O data/lro.bsp http://public-data.nyxspace.com/nyx/examples/lrorg_2023349_2024075_v01_LE.bsp
196201
wget -O data/moon_fk_de440.epa http://public-data.nyxspace.com/anise/v0.5/moon_fk_de440.epa
197202
wget -O data/moon_pa_de440_200625.bpc http://public-data.nyxspace.com/anise/moon_pa_de440_200625.bpc
203+
wget -O data/mro.bsp https://naif.jpl.nasa.gov/pub/naif/MRO/kernels/spk/spk_psp_rec89118_89113_89888_p-v1.bsp
198204
199205
- name: Install stable toolchain
200206
uses: dtolnay/rust-toolchain@stable
@@ -224,6 +230,7 @@ jobs:
224230
cargo llvm-cov test --no-report validate_jplde_de440_type3_no_aberration --features validation -- --nocapture --ignored
225231
cargo llvm-cov test --no-report validate_hermite_type13_from_gmat --features validation -- --nocapture --ignored
226232
cargo llvm-cov test --no-report validate_lagrange_type9_with_varying_segment_sizes --features validation -- --nocapture --ignored
233+
cargo llvm-cov test --no-report validate_modified_diff_type01 --features validation -- --nocapture --ignored
227234
cargo llvm-cov test --no-report ut_embed --features embed_ephem
228235
cargo llvm-cov report --lcov > ../lcov.txt
229236

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ cspice.tar.Z
1313
*.epa
1414
anise-gui/dist/
1515
anise-py/notebooks/.ipynb_checkpoints/ANISE Tutorial for querying SPK files-checkpoint.ipynb
16-
data/lro.bsp
16+
data/lro.bsp
17+
data/mro.bsp

anise/src/ephemerides/translate_to_parent.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::ephemerides::EphemInterpolationSnafu;
1717
use crate::hifitime::Epoch;
1818
use crate::math::cartesian::CartesianState;
1919
use crate::math::Vector3;
20+
use crate::naif::daf::datatypes::modified_diff::ModifiedDiffType1;
2021
use crate::naif::daf::datatypes::{
2122
HermiteSetType13, LagrangeSetType9, Type2ChebyshevSet, Type3ChebyshevSet,
2223
};
@@ -56,6 +57,16 @@ impl Almanac {
5657
// Now let's simply evaluate the data
5758

5859
let (pos_km, vel_km_s) = match summary.data_type()? {
60+
DafDataType::Type1ModifiedDifferenceArray => {
61+
let data =
62+
spk_data
63+
.nth_data::<ModifiedDiffType1>(idx_in_spk)
64+
.context(SPKSnafu {
65+
action: "fetching data for interpolation",
66+
})?;
67+
data.evaluate(epoch, summary)
68+
.context(EphemInterpolationSnafu)?
69+
}
5970
DafDataType::Type2ChebyshevTriplet => {
6071
let data =
6172
spk_data

anise/src/naif/daf/datatypes/hermite.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ impl fmt::Display for HermiteSetType13<'_> {
160160
write!(
161161
f,
162162
"Hermite Type 13 from {:E} to {:E} with degree {} ({} items, {} epoch directories)",
163-
Epoch::from_et_seconds(*self.epoch_data.first().unwrap()),
164-
Epoch::from_et_seconds(*self.epoch_data.last().unwrap()),
163+
Epoch::from_et_seconds(*self.epoch_data.first().unwrap_or(&0.0)),
164+
Epoch::from_et_seconds(*self.epoch_data.last().unwrap_or(&0.0)),
165165
self.degree(),
166166
self.epoch_data.len(),
167167
self.epoch_registry.len()
@@ -268,11 +268,7 @@ impl<'a> NAIFDataSet<'a> for HermiteSetType13<'a> {
268268
) -> Result<Self::StateKind, InterpolationError> {
269269
// Start by doing a binary search on the epoch registry to limit the search space in the total number of epochs.
270270
if self.epoch_data.is_empty() {
271-
return Err(InterpolationError::NoInterpolationData {
272-
req: epoch,
273-
start: Epoch::from_et_seconds(self.epoch_data[0]),
274-
end: Epoch::from_et_seconds(*self.epoch_data.last().unwrap()),
275-
});
271+
return Err(InterpolationError::MissingInterpolationData { epoch });
276272
}
277273
// Check that we even have interpolation data for that time
278274
if epoch.to_et_seconds() < self.epoch_data[0] - 1e-7

anise/src/naif/daf/datatypes/lagrange.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ impl<'a> NAIFDataSet<'a> for LagrangeSetType9<'a> {
215215
// Start by doing a binary search on the epoch registry to limit the search space in the total number of epochs.
216216
// TODO: use the epoch registry to reduce the search space
217217
// Check that we even have interpolation data for that time
218+
if self.epoch_data.is_empty() {
219+
return Err(InterpolationError::MissingInterpolationData { epoch });
220+
}
218221
if epoch.to_et_seconds() < self.epoch_data[0] - 1e-7
219222
|| epoch.to_et_seconds() > *self.epoch_data.last().unwrap() + 1e-7
220223
{

anise/src/naif/daf/datatypes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod chebyshev;
1212
pub mod chebyshev3;
1313
pub mod hermite;
1414
pub mod lagrange;
15+
pub mod modified_diff;
1516
pub mod posvel;
1617

1718
pub use chebyshev::*;

0 commit comments

Comments
 (0)