Struct nyx_space::md::trajectory::Traj

source ·
pub struct Traj<S: Interpolatable>{
    pub name: Option<String>,
    pub states: Vec<S>,
}
Expand description

Store a trajectory of any State.

Fields§

§name: Option<String>

Optionally name this trajectory

§states: Vec<S>

We use a vector because we know that the states are produced in a chronological manner (the direction does not matter).

Implementations§

source§

impl Traj<Spacecraft>

source

pub fn to_frame( &self, new_frame: Frame, almanac: Arc<Almanac> ) -> Result<Self, NyxError>

Allows converting the source trajectory into the (almost) equivalent trajectory in another frame

source

pub fn to_parquet_with_step<P: AsRef<Path>>( &self, path: P, step: Duration, almanac: Arc<Almanac> ) -> Result<(), Box<dyn Error>>

A shortcut to to_parquet_with_cfg

source

pub fn to_groundtrack_parquet<P: AsRef<Path>>( &self, path: P, body_fixed_frame: Frame, events: Option<Vec<&dyn EventEvaluator<Spacecraft>>>, metadata: Option<HashMap<String, String>>, almanac: Arc<Almanac> ) -> Result<PathBuf, Box<dyn Error>>

Exports this trajectory to the provided filename in parquet format with only the epoch, the geodetic latitude, longitude, and height at one state per minute. Must provide a body fixed frame to correctly compute the latitude and longitude.

source

pub fn downcast(&self) -> Self

Convert this spacecraft trajectory into an Orbit trajectory, loosing all references to the spacecraft

source

pub fn from_oem_file<P: AsRef<Path>>( path: P, template: Spacecraft ) -> Result<Self, NyxError>

Initialize a new spacecraft trajectory from the path to a CCSDS OEM file.

CCSDS OEM only contains the orbit information, so you must provide a template spacecraft since we’ll upcast the orbit trajectory into a spacecraft trajectory.

source§

impl<S: Interpolatable> Traj<S>

source

pub fn new() -> Self

source

pub fn finalize(&mut self)

Orders the states, can be used to store the states out of order

source

pub fn at(&self, epoch: Epoch) -> Result<S, TrajError>

Evaluate the trajectory at this specific epoch.

source

pub fn first(&self) -> &S

Returns the first state in this ephemeris

source

pub fn last(&self) -> &S

Returns the last state in this ephemeris

source

pub fn every(&self, step: Duration) -> TrajIterator<'_, S>

Creates an iterator through the trajectory by the provided step size

source

pub fn every_between( &self, step: Duration, start: Epoch, end: Epoch ) -> TrajIterator<'_, S>

Creates an iterator through the trajectory by the provided step size between the provided bounds

source

pub fn to_parquet_simple<P: AsRef<Path>>( &self, path: P, almanac: Arc<Almanac> ) -> Result<PathBuf, Box<dyn Error>>

Store this trajectory arc to a parquet file with the default configuration (depends on the state type, search for export_params in the documentation for details).

source

pub fn to_parquet_with_cfg<P: AsRef<Path>>( &self, path: P, cfg: ExportCfg, almanac: Arc<Almanac> ) -> Result<PathBuf, Box<dyn Error>>

Store this trajectory arc to a parquet file with the provided configuration

source

pub fn to_parquet<P: AsRef<Path>>( &self, path: P, events: Option<Vec<&dyn EventEvaluator<S>>>, cfg: ExportCfg, almanac: Arc<Almanac> ) -> Result<PathBuf, Box<dyn Error>>

Store this trajectory arc to a parquet file with the provided configuration and event evaluators

source

pub fn resample(&self, step: Duration) -> Result<Self, NyxError>

Allows resampling this trajectory at a fixed interval instead of using the propagator step size. This may lead to aliasing due to the Nyquist–Shannon sampling theorem.

source

pub fn rebuild(&self, epochs: &[Epoch]) -> Result<Self, NyxError>

Rebuilds this trajectory with the provided epochs. This may lead to aliasing due to the Nyquist–Shannon sampling theorem.

source

pub fn ric_diff_to_parquet<P: AsRef<Path>>( &self, other: &Self, path: P, cfg: ExportCfg ) -> Result<PathBuf, Box<dyn Error>>

Export the difference in RIC from of this trajectory compare to the “other” trajectory in parquet format.

§Notes
  • The RIC frame accounts for the transport theorem by performing a finite differencing of the RIC frame.
source§

impl<S: Interpolatable> Traj<S>

source

pub fn find_bracketed<E>( &self, start: Epoch, end: Epoch, event: &E, almanac: Arc<Almanac> ) -> Result<EventDetails<S>, EventError>
where E: EventEvaluator<S>,

Find the exact state where the request event happens. The event function is expected to be monotone in the provided interval because we find the event using a Brent solver.

source

pub fn find<E>( &self, event: &E, almanac: Arc<Almanac> ) -> Result<Vec<EventDetails<S>>, EventError>
where E: EventEvaluator<S>,

Find all of the states where the event happens

§Limitations

This method uses a Brent solver. If the function that defines the event is not unimodal, the event finder may not converge correctly.

§Heuristic detail

The initial search step is 1% of the duration of the trajectory duration. For example, if the trajectory is 100 days long, then we split the trajectory into 100 chunks of 1 day and see whether the event is in there. If the event happens twice or more times within 1% of the trajectory duration, only the one of such events will be found.

If this heuristic fails to find any such events, then find_minmax is called on the event with a time precision of Unit::Second. Then we search only within the min and max bounds of the provided event.

source

pub fn find_minmax<E>( &self, event: &E, precision: Unit, almanac: Arc<Almanac> ) -> Result<(S, S), EventError>
where E: EventEvaluator<S>,

Find the minimum and maximum of the provided event through the trajectory

source

pub fn find_arcs<E>( &self, event: &E, almanac: Arc<Almanac> ) -> Result<Vec<EventArc<S>>, EventError>
where E: EventEvaluator<S>,

Identifies and pairs rising and falling edge events in a trajectory.

This function processes a sequence of events in a trajectory and pairs each rising edge event with its subsequent falling edge event to form arcs. Each arc represents a complete cycle of an event rising above and then falling below a specified threshold. Use this to analyze a trajectory’s behavior when understanding the complete cycle of an event (from rising to falling) is essential, e.g. ground station passes.

§Arguments
  • event: A reference to an object implementing the EventEvaluator<S> trait, which is used to evaluate and classify events in the trajectory.
§Returns
  • Result<Vec<EventArc>, NyxError>: On success, returns a vector of EventArc, where each struct contains a pair of EventDetails (one for the rising edge and one for the falling edge). Returns an error if any issues occur during the event evaluation process.
§Logic
  • Sorts the events by their epoch to ensure chronological processing.
  • Iterates through the sorted events, identifying transitions from falling to rising edges and vice versa.
  • Pairs a rising edge with the subsequent falling edge to form an arc.
  • Handles edge cases where the trajectory starts or ends with a rising or falling edge.
  • Prints debug information for each event and arc.
§Note

If no zero crossing happens in the trajectory, i.e. the there is “event is true” and “event is false”, then this function checks whether the event is true at the start and end of the trajectory. If so, it means that there is a single arc that spans the whole trajectory.

Trait Implementations§

source§

impl<S: Interpolatable> Add<&Traj<S>> for &Traj<S>

source§

fn add(self, other: &Traj<S>) -> Self::Output

Add one trajectory to another, returns an error if the frames don’t match

§

type Output = Result<Traj<S>, NyxError>

The resulting type after applying the + operator.
source§

impl<S: Interpolatable> Add for Traj<S>

source§

fn add(self, other: Traj<S>) -> Self::Output

Add one trajectory to another. If they do not overlap to within 10ms, a warning will be printed.

§

type Output = Result<Traj<S>, NyxError>

The resulting type after applying the + operator.
source§

impl<S: Interpolatable> AddAssign<&Traj<S>> for Traj<S>

source§

fn add_assign(&mut self, rhs: &Self)

Attempt to add two trajectories together and assign it to self

§Warnings
  1. This will panic if the frames mismatch!
  2. This is inefficient because both self and rhs are cloned.
source§

impl<S: Clone + Interpolatable> Clone for Traj<S>

source§

fn clone(&self) -> Traj<S>

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
source§

impl<S: Interpolatable> Debug for Traj<S>

source§

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

Formats the value using the given formatter. Read more
source§

impl<S: Interpolatable> Default for Traj<S>

source§

fn default() -> Self

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

impl<S: Interpolatable> Display for Traj<S>

source§

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

Formats the value using the given formatter. Read more
source§

impl<S: PartialEq + Interpolatable> PartialEq for Traj<S>

source§

fn eq(&self, other: &Traj<S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<S: Interpolatable> StructuralPartialEq for Traj<S>

Auto Trait Implementations§

§

impl<S> Freeze for Traj<S>

§

impl<S> RefUnwindSafe for Traj<S>

§

impl<S> Send for Traj<S>

§

impl<S> Sync for Traj<S>

§

impl<S> Unpin for Traj<S>

§

impl<S> UnwindSafe for Traj<S>

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,

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,