Skip to content

Commit

Permalink
Add the PCK08.pca file as an embedded file
Browse files Browse the repository at this point in the history
You must copy add the DE440s.bsp file to the data folder for rinex.
Rinex expects that this file be available in the AstroData structure.
I could not add it myself because Github doesn't allow adding git lfs to public forks
WARNING: The DE440s.bsp file is large. Once nyx-space/anise#262 is fixed, you should truncate this DE file to only contain a few years and a few planetary ephemerides instead of the whole solar system
  • Loading branch information
ChristopherRabotin committed Jun 23, 2024
1 parent b53e106 commit af9cfc8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/de440s.bsp filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ hifitime = { git = "https://github.com/nyx-space/hifitime.git", branch = "master
"std",
] }
anise = { git = "https://github.com/nyx-space/anise", branch = "master" }
rust-embed = { version = "8.4.0", features = ["interpolate-folder-path"] }
Binary file added data/pck08.pca
Binary file not shown.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
extern crate gnss_rs as gnss;
extern crate nyx_space as nyx;

use rust_embed::Embed;

// private modules
mod ambiguity;
mod bancroft;
Expand All @@ -15,6 +17,10 @@ mod navigation;
mod position;
mod solver;

#[derive(Embed)]
#[folder = "$CARGO_MANIFEST_DIR/data/"]
pub struct AstroData;

// mod tracker;
// pub(crate) mod utils;

Expand All @@ -32,6 +38,8 @@ pub mod prelude {
pub use crate::position::Position;
pub use crate::solver::{Error, InterpolationResult, Solver};
// re-export
pub use anise::constants::frames::{EARTH_J2000, SUN_J2000};
pub use anise::naif::SPK;
pub use anise::prelude::{Aberration, Almanac, Frame};
pub use gnss::prelude::{Constellation, SV};
pub use hifitime::{Duration, Epoch, TimeScale};
Expand Down
22 changes: 11 additions & 11 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use anise::{
},
errors::{AlmanacError, PhysicsError},
prelude::{Almanac, Frame, Orbit},
structure::{planetocentric::PlanetaryData, PlanetaryDataSet},
};

use crate::{
Expand All @@ -34,6 +35,7 @@ use crate::{
},
position::Position,
prelude::{Duration, Epoch, SV},
AstroData,
};

#[derive(Debug, PartialEq, Error)]
Expand Down Expand Up @@ -78,6 +80,8 @@ pub enum Error {
Almanac(AlmanacError),
#[error("physics issue: {0}")]
Physics(PhysicsError),
#[error("issue loading Almanac: {0}")]
LoadingAlmanac(&'static str),
}

/// Interpolation result (state vector) that needs to be
Expand Down Expand Up @@ -212,18 +216,14 @@ impl<I: std::ops::Fn(Epoch, SV, usize) -> Option<InterpolationResult>> Solver<I>
/// in Fixed Altitude or Time Only modes.
/// - interpolator: function pointer to external method to provide 3D interpolation results.
pub fn new(cfg: &Config, initial: Option<Position>, interpolator: I) -> Result<Self, Error> {
// Question: Should the Almanac be provided by the caller? This would allow customization of the data that's loaded.
// For example, I _think_ that only the planetary constants need to be loaded for all of this functionality (hence line 219)
// to work, but the `latest` almanac contains planetary positions for 100 years, the latest high precision Earth rotation parameters,
// the high precision Moon body frame parameters, and the planetary constants.
// let almanac = MetaAlmanac::latest().map_err(Error::Almanac)?;
let almanac = Almanac::default()
.load_from_metafile(MetaFile {
uri: "http://public-data.nyxspace.com/anise/v0.4/pck08.pca".to_string(),
crc32: Some(3072159656), // Specifying the CRC allows only downloading the data once.
})
.map_err(Error::Almanac)?;
// 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 pck08 = AstroData::get("pck08.pca").ok_or(Error::LoadingAlmanac(
"could not find pck08.pca in embedded files",
))?;
let almanac = Almanac {
planetary_data: PlanetaryDataSet::try_from_bytes(pck08.data.as_ref()).unwrap(),
..Default::default()
};

/*
* print more infos
Expand Down

0 comments on commit af9cfc8

Please sign in to comment.