Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ exclude = [
]

[workspace.dependencies]
hifitime = { version = "3.9.0", default-features = true }
hifitime = { git = "https://github.com/nyx-space/hifitime.git", features = [
"std",
], branch = "master" }
memmap2 = "=0.9.4"
crc32fast = "=1.4.2"
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }
Expand All @@ -44,8 +46,8 @@ snafu = { version = "0.8.0", features = ["backtrace"] }
lexical-core = "0.8.5"
heapless = "0.8.0"
rstest = "0.19.0"
pyo3 = { version = "0.20.0", features = ["multiple-pymethods"] }
pyo3-log = "0.9.0"
pyo3 = { version = "0.21", features = ["multiple-pymethods"] }
pyo3-log = "0.10"
serde = "1"
serde_derive = "1"
serde_dhall = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion anise/src/almanac/metaload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use snafu::prelude::*;
#[cfg(feature = "python")]
use pyo3::prelude::*;

#[derive(Debug, Snafu)]
#[derive(Debug, PartialEq, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum MetaAlmanacError {
#[snafu(display("could not create the cache folder for ANISE, please use a relative path"))]
Expand Down
4 changes: 2 additions & 2 deletions anise/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::almanac::metaload::MetaAlmanacError;
#[cfg(feature = "metaload")]
use crate::almanac::metaload::MetaFile;

#[derive(Debug, Snafu)]
#[derive(Debug, PartialEq, Snafu)]
#[snafu(visibility(pub))]
pub enum AlmanacError {
#[snafu(display("{action} encountered an error with ephemeris computation {source}"))]
Expand Down Expand Up @@ -62,7 +62,7 @@ pub enum AlmanacError {

pub type AlmanacResult<T> = Result<T, AlmanacError>;

#[derive(Debug, Snafu)]
#[derive(Debug, PartialEq, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum InputOutputError {
/// Raised for an error in reading or writing the file(s)
Expand Down
17 changes: 17 additions & 0 deletions anise/src/math/cartesian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ impl CartesianState {
}
}

/// Creates a new Cartesian state in the provided frame at the provided Epoch (shortcut to `new`).
///
/// **Units:** km, km, km, km/s, km/s, km/s
#[allow(clippy::too_many_arguments)]
pub fn cartesian(
x_km: f64,
y_km: f64,
z_km: f64,
vx_km_s: f64,
vy_km_s: f64,
vz_km_s: f64,
epoch: Epoch,
frame: Frame,
) -> Self {
Self::new(x_km, y_km, z_km, vx_km_s, vy_km_s, vz_km_s, epoch, frame)
}

/// Creates a new Cartesian in the provided frame at the provided Epoch in time with 0.0 velocity.
///
/// **Units:** km, km, km
Expand Down
4 changes: 3 additions & 1 deletion anise/src/naif/daf/datatypes/chebyshev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ impl<'a> Type2ChebyshevSet<'a> {
epoch: Epoch,
summary: &S,
) -> Result<usize, InterpolationError> {
if epoch < summary.start_epoch() || epoch > summary.end_epoch() {
if epoch < summary.start_epoch() - 1_i64.nanoseconds()
|| epoch > summary.end_epoch() + 1_i64.nanoseconds()
{
// No need to go any further.
return Err(InterpolationError::NoInterpolationData {
req: epoch,
Expand Down
4 changes: 2 additions & 2 deletions anise/src/naif/daf/datatypes/hermite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ impl<'a> NAIFDataSet<'a> for HermiteSetType13<'a> {
// Start by doing a binary search on the epoch registry to limit the search space in the total number of epochs.
// TODO: use the epoch registry to reduce the search space
// Check that we even have interpolation data for that time
if epoch.to_et_seconds() < self.epoch_data[0]
|| epoch.to_et_seconds() > *self.epoch_data.last().unwrap()
if epoch.to_et_seconds() + 1e-9 < self.epoch_data[0]
|| epoch.to_et_seconds() - 1e-9 > *self.epoch_data.last().unwrap()
{
return Err(InterpolationError::NoInterpolationData {
req: epoch,
Expand Down
6 changes: 3 additions & 3 deletions anise/src/naif/spk/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

use core::fmt;
use hifitime::Epoch;
use hifitime::{Epoch, TimeUnits};
use zerocopy::{AsBytes, FromBytes, FromZeroes};

#[cfg(feature = "python")]
Expand Down Expand Up @@ -169,11 +169,11 @@ impl NAIFSummaryRecord for SPKSummaryRecord {
}

fn start_epoch(&self) -> Epoch {
Epoch::from_et_seconds(self.start_epoch_et_s)
Epoch::from_et_seconds(self.start_epoch_et_s) + 1_i64.nanoseconds()
}

fn end_epoch(&self) -> Epoch {
Epoch::from_et_seconds(self.end_epoch_et_s)
Epoch::from_et_seconds(self.end_epoch_et_s) - 1_i64.nanoseconds()
}

fn id(&self) -> i32 {
Expand Down
21 changes: 9 additions & 12 deletions anise/tests/ephemerides/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn hermite_query() {
.unwrap();

// This tests that we've loaded the frame info from the Almanac, otherwise we cannot compute the orbital elements.
assert_eq!(format!("{state:x}"), "[Earth J2000] 2000-01-01T13:39:27.999998123 UTC\tsma = 7192.041350 km\tecc = 0.024628\tinc = 12.851841 deg\traan = 306.170038 deg\taop = 315.085528 deg\tta = 96.135384 deg");
assert_eq!(format!("{state:x}"), "[Earth J2000] 2000-01-01T13:40:32.183929398 ET\tsma = 7192.041350 km\tecc = 0.024628\tinc = 12.851841 deg\traan = 306.170038 deg\taop = 315.085528 deg\tta = 96.135384 deg");

// Fetch the state at the start of this spline to make sure we don't glitch.
assert!(ctx
Expand All @@ -440,17 +440,14 @@ fn hermite_query() {
)
.is_ok());

// The very last state may fail because of a rounding difference in hifitime when going to/from TDB
// For example, in this exact case, the end_epoch is shown to be 12032.183931521 seconds but the epoch
// data in the BSP is 12032.1839315118(27), or 30 ns. This fix is in progress in hifitime v4.
// assert!(ctx
// .translate_from_to(
// summary.target_frame(),
// to_frame,
// summary.end_epoch(),
// Aberration::None,
// )
// .is_ok());
assert!(ctx
.translate(
summary.target_frame(),
summary.center_frame(),
summary.end_epoch(),
Aberration::NONE,
)
.is_ok());
}

/// This tests that the rotation from Moon to Earth matches SPICE with different aberration corrections.
Expand Down
8 changes: 6 additions & 2 deletions anise/tests/ephemerides/validation/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl CompareEphem {
// will cause us to seek out of the definition bounds.

let bound_offset = match self.aberration {
None => 0.0_f64.seconds(),
None => 0.01_f64.microseconds(),
Some(_) => 36.0_f64.hours(),
};

Expand Down Expand Up @@ -230,7 +230,11 @@ impl CompareEphem {
/ (self.num_queries_per_pair as f64))
.seconds();

let time_it = TimeSeries::exclusive(*start_epoch, *end_epoch - time_step, time_step);
let time_it = TimeSeries::exclusive(
*start_epoch + bound_offset,
*end_epoch - time_step - bound_offset,
time_step,
);

info!("{time_it} for {from_frame} -> {to_frame} ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn validate_jplde_de440s_aberration_lt() {

let err_count = comparator.run();

assert_eq!(err_count, 10, "A few are expected to fail");
assert!(err_count <= 10, "A few are expected to fail");

let validator = Validation {
file_name: output_file_name,
Expand Down