Struct nyx_space::md::prelude::Almanac

pub struct Almanac {
    pub spk_data: [Option<GenericDAF<SPKSummaryRecord, Bytes>>; 32],
    pub bpc_data: [Option<GenericDAF<BPCSummaryRecord, Bytes>>; 8],
    pub planetary_data: DataSet<PlanetaryData, anise::::structure::PlanetaryDataSet::{constant#0}>,
    pub spacecraft_data: DataSet<SpacecraftData, anise::::structure::SpacecraftDataSet::{constant#0}>,
    pub euler_param_data: DataSet<EulerParameter, anise::::structure::EulerParameterDataSet::{constant#0}>,
}
Expand description

An Almanac contains all of the loaded SPICE and ANISE data.

§Limitations

The stack space required depends on the maximum number of each type that can be loaded.

Fields§

§spk_data: [Option<GenericDAF<SPKSummaryRecord, Bytes>>; 32]

NAIF SPK is kept unchanged

§bpc_data: [Option<GenericDAF<BPCSummaryRecord, Bytes>>; 8]

NAIF BPC is kept unchanged

§planetary_data: DataSet<PlanetaryData, anise::::structure::PlanetaryDataSet::{constant#0}>

Dataset of planetary data

§spacecraft_data: DataSet<SpacecraftData, anise::::structure::SpacecraftDataSet::{constant#0}>

Dataset of spacecraft data

§euler_param_data: DataSet<EulerParameter, anise::::structure::EulerParameterDataSet::{constant#0}>

Dataset of euler parameters

Implementations§

§

impl Almanac

pub fn azimuth_elevation_range_sez( &self, rx: CartesianState, tx: CartesianState ) -> Result<AzElRange, AlmanacError>

Computes the azimuth (in degrees), elevation (in degrees), and range (in kilometers) of the receiver state (rx) seen from the transmitter state (tx), once converted into the SEZ frame of the transmitter.

§Algorithm
  1. Compute the SEZ (South East Zenith) frame of the transmitter.
  2. Rotate the receiver position vector into the transmitter SEZ frame.
  3. Rotate the transmitter position vector into that same SEZ frame.
  4. Compute the range as the norm of the difference between these two position vectors.
  5. Compute the elevation, and ensure it is between +/- 180 degrees.
  6. Compute the azimuth with a quadrant check, and ensure it is between 0 and 360 degrees.
§

impl Almanac

pub fn from_bpc( bpc: GenericDAF<BPCSummaryRecord, Bytes> ) -> Result<Almanac, OrientationError>

pub fn with_bpc( &self, bpc: GenericDAF<BPCSummaryRecord, Bytes> ) -> Result<Almanac, OrientationError>

Loads a Binary Planetary Constants kernel.

pub fn num_loaded_bpc(&self) -> usize

pub fn bpc_summary_from_name_at_epoch( &self, name: &str, epoch: Epoch ) -> Result<(&BPCSummaryRecord, usize, usize), OrientationError>

Returns the summary given the name of the summary record if that summary has data defined at the requested epoch and the BPC where this name was found to be valid at that epoch.

pub fn bpc_summary_at_epoch( &self, id: i32, epoch: Epoch ) -> Result<(&BPCSummaryRecord, usize, usize), OrientationError>

Returns the summary given the name of the summary record if that summary has data defined at the requested epoch

pub fn bpc_summary_from_name( &self, name: &str ) -> Result<(&BPCSummaryRecord, usize, usize), OrientationError>

Returns the summary given the name of the summary record.

pub fn bpc_summary( &self, id: i32 ) -> Result<(&BPCSummaryRecord, usize, usize), OrientationError>

Returns the summary given the name of the summary record if that summary has data defined at the requested epoch

§

impl Almanac

pub fn bpc_summaries( &self, id: i32 ) -> Result<Vec<BPCSummaryRecord>, OrientationError>

Returns a vector of the summaries whose ID matches the desired id, in the order in which they will be used, i.e. in reverse loading order.

pub fn bpc_domain(&self, id: i32) -> Result<(Epoch, Epoch), OrientationError>

Returns the applicable domain of the request id, i.e. start and end epoch that the provided id has loaded data.

pub fn bpc_domains( &self ) -> Result<HashMap<i32, (Epoch, Epoch)>, OrientationError>

Returns a map of each loaded BPC ID to its domain validity.

§Warning

This function performs a memory allocation.

§

impl Almanac

pub fn frame_from_uid<U>(&self, uid: U) -> Result<Frame, PlanetaryDataError>
where U: Into<FrameUid>,

Given the frame UID (or something that can be transformed into it), attempt to retrieve the full frame information, if that frame is loaded

pub fn with_planetary_data( &self, planetary_data: DataSet<PlanetaryData, anise::::structure::PlanetaryDataSet::{constant#0}> ) -> Almanac

Loads the provided planetary data into a clone of this original Almanac.

§

impl Almanac

pub fn sun_angle_deg( &self, target_id: i32, observer_id: i32, epoch: Epoch ) -> Result<f64, EphemerisError>

Returns the angle (between 0 and 180 degrees) between the observer and the Sun, and the observer and the target body ID. This computes the Sun Probe Earth angle (SPE) if the probe is in a loaded SPK, its ID is the “observer_id”, and the target is set to its central body.

§Geometry

If the SPE is greater than 90 degrees, then the celestial object below the probe is in sunlight.

§Sunrise at nadir
Sun
 |  \      
 |   \
 |    \
 Obs. -- Target
§Sun high at nadir
Sun
 \        
  \  __ θ > 90
   \     \
    Obs. ---------- Target
§Sunset at nadir
         Sun
       /  
      /  __ θ < 90
     /    /
 Obs. -- Target
§Algorithm
  1. Compute the position of the Sun as seen from the observer
  2. Compute the position of the target as seen from the observer
  3. Return the arccosine of the dot product of the norms of these vectors.

pub fn sun_angle_deg_from_frame( &self, target: Frame, observer: Frame, epoch: Epoch ) -> Result<f64, EphemerisError>

Convenience function that calls sun_angle_deg with the provided frames instead of the ephemeris ID.

§

impl Almanac

pub fn from_spk( spk: GenericDAF<SPKSummaryRecord, Bytes> ) -> Result<Almanac, EphemerisError>

pub fn with_spk( &self, spk: GenericDAF<SPKSummaryRecord, Bytes> ) -> Result<Almanac, EphemerisError>

Loads a new SPK file into a new context. This new context is needed to satisfy the unloading of files. In fact, to unload a file, simply let the newly loaded context drop out of scope and Rust will clean it up.

§

impl Almanac

pub fn num_loaded_spk(&self) -> usize

pub fn spk_summary_from_name_at_epoch( &self, name: &str, epoch: Epoch ) -> Result<(&SPKSummaryRecord, usize, usize), EphemerisError>

Returns the summary given the name of the summary record if that summary has data defined at the requested epoch and the SPK where this name was found to be valid at that epoch.

pub fn spk_summary_at_epoch( &self, id: i32, epoch: Epoch ) -> Result<(&SPKSummaryRecord, usize, usize), EphemerisError>

Returns the summary given the name of the summary record if that summary has data defined at the requested epoch

pub fn spk_summary_from_name( &self, name: &str ) -> Result<(&SPKSummaryRecord, usize, usize), EphemerisError>

Returns the most recently loaded summary by its name, if any with that ID are available

pub fn spk_summary( &self, id: i32 ) -> Result<(&SPKSummaryRecord, usize, usize), EphemerisError>

Returns the most recently loaded summary by its ID, if any with that ID are available

§

impl Almanac

pub fn spk_summaries( &self, id: i32 ) -> Result<Vec<SPKSummaryRecord>, EphemerisError>

Returns a vector of the summaries whose ID matches the desired id, in the order in which they will be used, i.e. in reverse loading order.

§Warning

This function performs a memory allocation.

pub fn spk_domain(&self, id: i32) -> Result<(Epoch, Epoch), EphemerisError>

Returns the applicable domain of the request id, i.e. start and end epoch that the provided id has loaded data.

pub fn spk_domains( &self ) -> Result<HashMap<i32, (Epoch, Epoch)>, EphemerisError>

Returns a map of each loaded SPK ID to its domain validity.

§Warning

This function performs a memory allocation.

§

impl Almanac

pub fn transform( &self, target_frame: Frame, observer_frame: Frame, epoch: Epoch, ab_corr: Option<Aberration> ) -> Result<CartesianState, AlmanacError>

Returns the Cartesian state needed to transform the from_frame to the to_frame.

§SPICE Compatibility

This function is the SPICE equivalent of spkezr: spkezr(TARGET_ID, EPOCH_TDB_S, ORIENTATION_ID, ABERRATION, OBSERVER_ID) In ANISE, the TARGET_ID and ORIENTATION are provided in the first argument (TARGET_FRAME), as that frame includes BOTH the target ID and the orientation of that target. The EPOCH_TDB_S is the epoch in the TDB time system, which is computed in ANISE using Hifitime. THe ABERRATION is computed by providing the optional Aberration flag. Finally, the OBSERVER argument is replaced by OBSERVER_FRAME: if the OBSERVER_FRAME argument has the same orientation as the TARGET_FRAME, then this call will return exactly the same data as the spkerz SPICE call.

§Note

The units will be those of the underlying ephemeris data (typically km and km/s)

pub fn transform_to( &self, state: CartesianState, observer_frame: Frame, ab_corr: Option<Aberration> ) -> Result<CartesianState, AlmanacError>

Translates a state with its origin (to_frame) and given its units (distance_unit, time_unit), returns that state with respect to the requested frame

WARNING: This function only performs the translation and no rotation whatsoever. Use the transform_state_to function instead to include rotations.

pub fn state_of( &self, object: i32, observer: Frame, epoch: Epoch, ab_corr: Option<Aberration> ) -> Result<CartesianState, AlmanacError>

Returns the Cartesian state of the object as seen from the provided observer frame (essentially spkezr).

§Note

The units will be those of the underlying ephemeris data (typically km and km/s)

§

impl Almanac

pub fn transform_state_to( &self, position: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, velocity: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, from_frame: Frame, to_frame: Frame, epoch: Epoch, ab_corr: Option<Aberration>, distance_unit: LengthUnit, time_unit: Unit ) -> Result<CartesianState, AlmanacError>

Translates a state with its origin (to_frame) and given its units (distance_unit, time_unit), returns that state with respect to the requested frame

WARNING: This function only performs the translation and no rotation whatsoever. Use the transform_state_to function instead to include rotations.

§

impl Almanac

pub fn load_from_metafile( &self, metafile: MetaFile ) -> Result<Almanac, AlmanacError>

Load from the provided MetaFile, downloading it if necessary.

§

impl Almanac

pub fn new(path: &str) -> Result<Almanac, AlmanacError>

Initializes a new Almanac from the provided file path, guessing at the file type

pub fn with_spacecraft_data( &self, spacecraft_data: DataSet<SpacecraftData, anise::::structure::SpacecraftDataSet::{constant#0}> ) -> Almanac

Loads the provided spacecraft data into a clone of this original Almanac.

pub fn with_euler_parameters( &self, ep_dataset: DataSet<EulerParameter, anise::::structure::EulerParameterDataSet::{constant#0}> ) -> Almanac

Loads the provided Euler parameter data into a clone of this original Almanac.

pub fn load_from_bytes(&self, bytes: Bytes) -> Result<Almanac, AlmanacError>

§

impl Almanac

pub fn load(&self, path: &str) -> Result<Almanac, AlmanacError>

Generic function that tries to load the provided path guessing to the file type.

pub fn describe( &self, spk: Option<bool>, bpc: Option<bool>, planetary: Option<bool>, time_scale: Option<TimeScale>, round_time: Option<bool> )

Pretty prints the description of this Almanac, showing everything by default. Default time scale is TDB. If any parameter is set to true, then nothing other than that will be printed.

§

impl Almanac

pub fn try_find_ephemeris_root(&self) -> Result<i32, EphemerisError>

Returns the root of all of the loaded ephemerides, typically this should be the Solar System Barycenter.

§Algorithm
  1. For each loaded SPK, iterated in reverse order (to mimic SPICE behavior)
  2. For each summary record in each SPK, follow the ephemeris branch all the way up until the end of this SPK or until the SSB.

pub fn ephemeris_path_to_root( &self, source: Frame, epoch: Epoch ) -> Result<(usize, [Option<i32>; 8]), EphemerisError>

Try to construct the path from the source frame all the way to the root ephemeris of this context.

pub fn common_ephemeris_path( &self, from_frame: Frame, to_frame: Frame, epoch: Epoch ) -> Result<(usize, [Option<i32>; 8], i32), EphemerisError>

Returns the ephemeris path between two frames and the common node. This may return a DisjointRoots error if the frames do not share a common root, which is considered a file integrity error.

§Example

If the “from” frame is Earth Barycenter whose path to the ANISE root is the following:

Solar System barycenter
╰─> Earth Moon Barycenter
    ╰─> Earth

And the “to” frame is Moon, whose path is:

Solar System barycenter
╰─> Earth Moon Barycenter
    ╰─> Moon
        ╰─> LRO

Then this function will return the path an array of hashes of up to [MAX_TREE_DEPTH] items. In this example, the array with the hashes of the “Earth Moon Barycenter” and “Moon”.

§Note

A proper ANISE file should only have a single root and if two paths are empty, then they should be the same frame. If a DisjointRoots error is reported here, it means that the ANISE file is invalid.

§Time complexity

This can likely be simplified as this as a time complexity of O(n×m) where n, m are the lengths of the paths from the ephemeris up to the root. This can probably be optimized to avoid rewinding the entire frame path up to the root frame

§

impl Almanac

pub fn translate_to_parent( &self, source: Frame, epoch: Epoch ) -> Result<CartesianState, EphemerisError>

Performs the GEOMETRIC translation to the parent. Use translate_from_to for aberration.

§

impl Almanac

pub fn translate( &self, target_frame: Frame, observer_frame: Frame, epoch: Epoch, ab_corr: Option<Aberration> ) -> Result<CartesianState, EphemerisError>

Returns the Cartesian state of the target frame as seen from the observer frame at the provided epoch, and optionally given the aberration correction.

§SPICE Compatibility

This function is the SPICE equivalent of spkezr: spkezr(TARGET_ID, EPOCH_TDB_S, ORIENTATION_ID, ABERRATION, OBSERVER_ID) In ANISE, the TARGET_ID and ORIENTATION are provided in the first argument (TARGET_FRAME), as that frame includes BOTH the target ID and the orientation of that target. The EPOCH_TDB_S is the epoch in the TDB time system, which is computed in ANISE using Hifitime. THe ABERRATION is computed by providing the optional Aberration flag. Finally, the OBSERVER argument is replaced by OBSERVER_FRAME: if the OBSERVER_FRAME argument has the same orientation as the TARGET_FRAME, then this call will return exactly the same data as the spkerz SPICE call.

§Warning

This function only performs the translation and no rotation whatsoever. Use the transform function instead to include rotations.

§Note

This function performs a recursion of no more than twice the [MAX_TREE_DEPTH].

pub fn translate_geometric( &self, target_frame: Frame, observer_frame: Frame, epoch: Epoch ) -> Result<CartesianState, EphemerisError>

Returns the geometric position vector, velocity vector, and acceleration vector needed to translate the from_frame to the to_frame, where the distance is in km, the velocity in km/s, and the acceleration in km/s^2.

pub fn translate_to( &self, state: CartesianState, observer_frame: Frame, ab_corr: Option<Aberration> ) -> Result<CartesianState, EphemerisError>

Translates the provided Cartesian state into the requested observer frame

WARNING: This function only performs the translation and no rotation whatsoever. Use the transform_to function instead to include rotations.

§

impl Almanac

pub fn translate_state_to( &self, position: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, velocity: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, from_frame: Frame, observer_frame: Frame, epoch: Epoch, ab_corr: Option<Aberration>, distance_unit: LengthUnit, time_unit: Unit ) -> Result<CartesianState, EphemerisError>

Translates a state with its origin (to_frame) and given its units (distance_unit, time_unit), returns that state with respect to the requested frame

WARNING: This function only performs the translation and no rotation whatsoever. Use the transform_state_to function instead to include rotations.

§

impl Almanac

pub fn try_find_orientation_root(&self) -> Result<i32, OrientationError>

Returns the root of all of the loaded orientations (BPC or planetary), typically this should be J2000.

§Algorithm
  1. For each loaded BPC, iterated in reverse order (to mimic SPICE behavior)
  2. For each summary record in each BPC, follow the orientation branch all the way up until the end of this BPC or until the J2000.

pub fn orientation_path_to_root( &self, source: Frame, epoch: Epoch ) -> Result<(usize, [Option<i32>; 8]), OrientationError>

Try to construct the path from the source frame all the way to the root orientation of this context.

pub fn common_orientation_path( &self, from_frame: Frame, to_frame: Frame, epoch: Epoch ) -> Result<(usize, [Option<i32>; 8], i32), OrientationError>

Returns the orientation path between two frames and the common node. This may return a DisjointRoots error if the frames do not share a common root, which is considered a file integrity error.

§

impl Almanac

pub fn rotation_to_parent( &self, source: Frame, epoch: Epoch ) -> Result<DCM, OrientationError>

Returns the direct cosine matrix (DCM) to rotate from the source to its parent in the orientation hierarchy at the provided epoch,

§Example

If the ephemeris stores position interpolation coefficients in kilometer but this function is called with millimeters as a distance unit, the output vectors will be in mm, mm/s, mm/s^2 respectively.

§Errors
  • As of now, some interpolation types are not supported, and if that were to happen, this would return an error.

WARNING: This function only performs the rotation and no translation whatsoever. Use the transform_to_parent_from function instead to include rotations.

§

impl Almanac

pub fn rotate_from_to( &self, from_frame: Frame, to_frame: Frame, epoch: Epoch ) -> Result<DCM, OrientationError>

Returns the 6x6 DCM needed to rotation the from_frame to the to_frame.

§Warning

This function only performs the rotation and no translation whatsoever. Use the transform_from_to function instead to include rotations.

§Note

This function performs a recursion of no more than twice the MAX_TREE_DEPTH.

pub fn rotate_state_to( &self, position: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, velocity: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, from_frame: Frame, to_frame: Frame, epoch: Epoch, distance_unit: LengthUnit, time_unit: Unit ) -> Result<CartesianState, OrientationError>

Translates a state with its origin (to_frame) and given its units (distance_unit, time_unit), returns that state with respect to the requested frame

WARNING: This function only performs the translation and no rotation whatsoever. Use the transform_state_to function instead to include rotations.

Trait Implementations§

§

impl Clone for Almanac

§

fn clone(&self) -> Almanac

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Default for Almanac

§

fn default() -> Almanac

Returns the “default value” for a type. Read more
§

impl Display for Almanac

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,