Skip to content

Commit

Permalink
Merge pull request #268 from nyx-space/deps/hifitime-4.0.0-alpha
Browse files Browse the repository at this point in the history
Now using hifitime 4.0.0-alpha
  • Loading branch information
ChristopherRabotin authored Jun 27, 2024
2 parents 8e88d47 + f1c2fb8 commit afaf489
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ jobs:
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 test --no-report ut_embed --features embed_ephem
cargo llvm-cov report --lcov > ../lcov.txt
env:
RUSTFLAGS: --cfg __ui_tests
Expand Down
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ exclude = [
]

[workspace.dependencies]
hifitime = { git = "https://github.com/nyx-space/hifitime.git", features = [
"std",
], branch = "master" }
hifitime = "4.0.0-alpha"
memmap2 = "=0.9.4"
crc32fast = "=1.4.2"
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }
Expand Down
7 changes: 2 additions & 5 deletions anise-gui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,9 @@ impl eframe::App for UiApp {
egui::TopBottomPanel::top("header").show(ctx, |ui| {
ui.horizontal_centered(|ui| {
ui.vertical_centered(|ui| {
ui.heading("ANISE v0.3");
ui.heading("ANISE v0.4");
ui.label("A modern rewrite of NAIF SPICE");
ui.hyperlink_to(
"Take the user survey!",
"https://7ug5imdtt8v.typeform.com/to/qYDB14Hj",
);
ui.hyperlink_to("Contact us", "https://7ug5imdtt8v.typeform.com/to/neFvVW3p");
ui.hyperlink("https://www.nyxspace.com");
ui.label("ANISE is open-sourced under the Mozilla Public License 2.0");
});
Expand Down
5 changes: 5 additions & 0 deletions anise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ serde_dhall = { workspace = true }
reqwest = { version = "0.12.0", optional = true, features = ["blocking"] }
platform-dirs = { version = "0.3.0", optional = true }
tabled = { workspace = true }
rust-embed = { version = "8.4.0", features = [
"interpolate-folder-path",
"include-exclude",
], optional = true }

[dev-dependencies]
rust-spice = "0.7.6"
Expand All @@ -50,6 +54,7 @@ default = ["metaload"]
spkezr_validation = []
python = ["pyo3", "pyo3-log"]
metaload = ["url", "reqwest/blocking", "platform-dirs"]
embed_ephem = ["rust-embed"]

[[bench]]
name = "iai_jpl_ephemerides"
Expand Down
63 changes: 63 additions & 0 deletions anise/src/almanac/embed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::{
almanac::Almanac,
errors::{AlmanacError, AlmanacResult, TLDataSetSnafu},
structure::PlanetaryDataSet,
};
use bytes::Bytes;
use rust_embed::Embed;
use snafu::ResultExt;

#[derive(Embed)]
#[folder = "$CARGO_MANIFEST_DIR/../data/"]
#[include = "de440s.bsp"]
#[include = "pck11.pca"]
struct AstroData;

impl Almanac {
/// Provides planetary ephemerides from 2024-01-01 until 2035-01-01. Also provides planetary constants data (from the PCK11 kernel).
///
/// Until https://github.com/nyx-space/anise/issues/269, this will provide 100 yeras of data
pub fn until_2035() -> AlmanacResult<Self> {
// Regularly refer to https://github.com/nyx-space/anise/blob/master/data/ci_config.dhall for the latest CRC, although it should not change between minor versions!
let pck11 = AstroData::get("pck11.pca").ok_or(AlmanacError::GenericError {
err: "could not find pck11.pca in embedded files".to_string(),
})?;
let almanac = Almanac {
planetary_data: PlanetaryDataSet::try_from_bytes(pck11.data.as_ref()).context(
TLDataSetSnafu {
action: "loading PCK11 from embedded file",
},
)?,
..Default::default()
};

let pl_ephem = AstroData::get("de440s.bsp").ok_or(AlmanacError::GenericError {
err: "could not find de440s.bsp in embedded files".to_string(),
})?;

almanac.load_from_bytes(Bytes::copy_from_slice(pl_ephem.data.as_ref()))
}
}

#[cfg(test)]
mod ut_embed {
use super::{Almanac, AstroData};

#[test]
fn test_embedded_load() {
let almanac = Almanac::until_2035().unwrap();
assert_eq!(almanac.num_loaded_spk(), 1);
assert_eq!(almanac.num_loaded_bpc(), 0);
assert_ne!(almanac.planetary_data.crc32(), 0);
}

#[test]
fn test_limited_set() {
// Check only PCK11 is present
assert!(AstroData::get("pck11.pca").is_some());
assert!(AstroData::get("pck08.pca").is_none());
// Check only one planetary ephem is present
assert!(AstroData::get("de440s.bsp").is_some());
assert!(AstroData::get("de440.bsp").is_none());
}
}
3 changes: 3 additions & 0 deletions anise/src/almanac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub mod metaload;
#[cfg(feature = "python")]
mod python;

#[cfg(feature = "embed_ephem")]
mod embed;

#[cfg(feature = "python")]
use pyo3::prelude::*;

Expand Down

0 comments on commit afaf489

Please sign in to comment.