Struct nyx_space::md::trajectory::Traj
source · pub struct Traj<S: Interpolatable>where
DefaultAllocator: Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,{
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>
impl Traj<Spacecraft>
sourcepub fn to_frame(
&self,
new_frame: Frame,
almanac: Arc<Almanac>
) -> Result<Self, NyxError>
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
sourcepub fn to_parquet_with_step<P: AsRef<Path>>(
&self,
path: P,
step: Duration,
almanac: Arc<Almanac>
) -> Result<(), Box<dyn Error>>
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
sourcepub 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>>
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.
sourcepub fn downcast(&self) -> Self
pub fn downcast(&self) -> Self
Convert this spacecraft trajectory into an Orbit trajectory, loosing all references to the spacecraft
sourcepub fn from_oem_file<P: AsRef<Path>>(
path: P,
template: Spacecraft
) -> Result<Self, NyxError>
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>
impl<S: Interpolatable> Traj<S>
pub fn new() -> Self
sourcepub fn at(&self, epoch: Epoch) -> Result<S, TrajError>
pub fn at(&self, epoch: Epoch) -> Result<S, TrajError>
Evaluate the trajectory at this specific epoch.
sourcepub fn every(&self, step: Duration) -> TrajIterator<'_, S>
pub fn every(&self, step: Duration) -> TrajIterator<'_, S>
Creates an iterator through the trajectory by the provided step size
sourcepub fn every_between(
&self,
step: Duration,
start: Epoch,
end: Epoch
) -> TrajIterator<'_, S>
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
sourcepub fn to_parquet_simple<P: AsRef<Path>>(
&self,
path: P,
almanac: Arc<Almanac>
) -> Result<PathBuf, Box<dyn Error>>
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).
sourcepub fn to_parquet_with_cfg<P: AsRef<Path>>(
&self,
path: P,
cfg: ExportCfg,
almanac: Arc<Almanac>
) -> Result<PathBuf, Box<dyn Error>>
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
sourcepub 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>>
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
sourcepub fn resample(&self, step: Duration) -> Result<Self, NyxError>
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.
sourcepub fn rebuild(&self, epochs: &[Epoch]) -> Result<Self, NyxError>
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.
sourcepub fn ric_diff_to_parquet<P: AsRef<Path>>(
&self,
other: &Self,
path: P,
cfg: ExportCfg
) -> Result<PathBuf, Box<dyn Error>>
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>
impl<S: Interpolatable> Traj<S>
sourcepub fn find_bracketed<E>(
&self,
start: Epoch,
end: Epoch,
event: &E,
almanac: Arc<Almanac>
) -> Result<EventDetails<S>, EventError>where
E: EventEvaluator<S>,
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.
sourcepub fn find<E>(
&self,
event: &E,
almanac: Arc<Almanac>
) -> Result<Vec<EventDetails<S>>, EventError>where
E: EventEvaluator<S>,
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.
sourcepub fn find_minmax<E>(
&self,
event: &E,
precision: Unit,
almanac: Arc<Almanac>
) -> Result<(S, S), EventError>where
E: EventEvaluator<S>,
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
sourcepub fn find_arcs<E>(
&self,
event: &E,
almanac: Arc<Almanac>
) -> Result<Vec<EventArc<S>>, EventError>where
E: EventEvaluator<S>,
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 theEventEvaluator<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 ofEventDetails
(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 for Traj<S>
impl<S: Interpolatable> Add for Traj<S>
source§impl<S: Interpolatable> AddAssign<&Traj<S>> for Traj<S>
impl<S: Interpolatable> AddAssign<&Traj<S>> for Traj<S>
source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Attempt to add two trajectories together and assign it to self
§Warnings
- This will panic if the frames mismatch!
- This is inefficient because both
self
andrhs
are cloned.
source§impl<S: Interpolatable> Debug for Traj<S>
impl<S: Interpolatable> Debug for Traj<S>
source§impl<S: Interpolatable> Default for Traj<S>
impl<S: Interpolatable> Default for Traj<S>
source§impl<S: Interpolatable> Display for Traj<S>
impl<S: Interpolatable> Display for Traj<S>
source§impl<S: PartialEq + Interpolatable> PartialEq for Traj<S>
impl<S: PartialEq + Interpolatable> PartialEq for Traj<S>
impl<S: Interpolatable> StructuralPartialEq for Traj<S>
Auto Trait Implementations§
impl<S> Freeze for Traj<S>where
DefaultAllocator: Sized,
impl<S> RefUnwindSafe for Traj<S>
impl<S> Send for Traj<S>where
DefaultAllocator: Sized,
impl<S> Sync for Traj<S>where
DefaultAllocator: Sized,
impl<S> Unpin for Traj<S>
impl<S> UnwindSafe for Traj<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.