Skip to content

Commit

Permalink
Rename EpochRange to Strand
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Dec 23, 2023
1 parent 5dce943 commit c2845b4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/od/simulator/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use crate::dynamics::{Dynamics, NyxError};
use crate::io::ConfigError;
use crate::md::trajectory::Interpolatable;
use crate::od::msr::{RangeDoppler, TrackingArc};
use crate::od::prelude::EpochRanges;
use crate::od::prelude::Strand;
use crate::od::simulator::Cadence;
use crate::od::{GroundStation, Measurement};
pub use crate::{cosmic::Cosm, State, TimeTagged};
Expand Down Expand Up @@ -322,7 +322,7 @@ impl TrackingArcSim<Orbit, RangeDoppler, GroundStation> {
continue;
}

let mut strand_range = EpochRanges {
let mut strand_range = Strand {
start: strand_start,
end: strand_end,
};
Expand Down Expand Up @@ -464,7 +464,7 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
traj.find_bracketed(start_at + 1.0_f64.seconds(), end_at, &device)
{
let strand_end = visibility_event.state.epoch();
let mut strand_range = EpochRanges {
let mut strand_range = Strand {
start: start_at,
end: strand_end,
};
Expand Down
2 changes: 1 addition & 1 deletion src/od/simulator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pub use scheduler::{Cadence, Handoff, Scheduler};
mod trackdata;
pub use trackdata::TrackingDeviceSim;
mod trkconfig;
pub use trkconfig::{EpochRanges, TrkConfig};
pub use trkconfig::{Strand, TrkConfig};
14 changes: 7 additions & 7 deletions src/od/simulator/trkconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct TrkConfig {
pub sampling: Duration,
/// List of tracking strands during which the given tracker will be tracking
#[builder(default, setter(strip_option))]
pub strands: Option<Vec<EpochRanges>>,
pub strands: Option<Vec<Strand>>,
}

impl ConfigRepr for TrkConfig {}
Expand Down Expand Up @@ -133,18 +133,18 @@ impl Default for TrkConfig {
}
}

/// Stores an epoch range for tracking.
/// Stores a tracking strand with a start and end epoch
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "python", pyclass)]
#[cfg_attr(feature = "python", pyo3(module = "nyx_space.orbit_determination"))]
pub struct EpochRanges {
pub struct Strand {
#[serde(serialize_with = "epoch_to_str", deserialize_with = "epoch_from_str")]
pub start: Epoch,
#[serde(serialize_with = "epoch_to_str", deserialize_with = "epoch_from_str")]
pub end: Epoch,
}

impl EpochRanges {
impl Strand {
/// Returns whether the provided epoch is within the range
pub fn contains(&self, epoch: Epoch) -> bool {
(self.start..=self.end).contains(&epoch)
Expand Down Expand Up @@ -179,21 +179,21 @@ mod trkconfig_ut {

let start = Epoch::now().unwrap();
let end = start + 10.seconds();
cfg.strands = Some(vec![EpochRanges { start, end }]);
cfg.strands = Some(vec![Strand { start, end }]);
assert!(
cfg.sanity_check().is_err(),
"strand of too short of a duration should mark this insane"
);

let end = start + cfg.sampling;
cfg.strands = Some(vec![EpochRanges { start, end }]);
cfg.strands = Some(vec![Strand { start, end }]);
assert!(
cfg.sanity_check().is_ok(),
"strand allowing for a single measurement should be OK"
);

// An anti-chronological strand should be invalid
cfg.strands = Some(vec![EpochRanges {
cfg.strands = Some(vec![Strand {
start: end,
end: start,
}]);
Expand Down
2 changes: 1 addition & 1 deletion src/python/orbit_determination/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
pub use crate::io::ConfigError;
pub use crate::od::simulator::{Cadence, EpochRanges, Handoff, Scheduler};
pub use crate::od::simulator::{Cadence, Handoff, Scheduler, Strand};
use crate::NyxError;
use hifitime::Duration;
use pyo3::basic::CompareOp;
Expand Down
4 changes: 2 additions & 2 deletions src/python/orbit_determination/trkconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
pub use crate::io::ConfigError;
pub use crate::od::simulator::{EpochRanges, Scheduler, TrkConfig};
pub use crate::od::simulator::{Scheduler, Strand, TrkConfig};
use crate::{io::ConfigRepr, NyxError};
use hifitime::Duration;
use pyo3::basic::CompareOp;
Expand Down Expand Up @@ -47,7 +47,7 @@ impl TrkConfig {
#[pyo3(text_signature = "(sampling=None, strands=None, scheduler=None)")]
fn py_new(
sampling: Option<String>,
strands: Option<Vec<EpochRanges>>,
strands: Option<Vec<Strand>>,
scheduler: Option<Scheduler>,
) -> Result<Self, ConfigError> {
let mut me = Self::default();
Expand Down
2 changes: 1 addition & 1 deletion tests/orbit_determination/resid_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn devices_n_configs(epoch: Epoch) -> (Vec<GroundStation>, HashMap<String, TrkCo
// Define the tracking configurations
let mut configs = HashMap::new();
let cfg = TrkConfig::builder()
.strands(vec![EpochRanges {
.strands(vec![Strand {
start: epoch + 60.seconds(),
end: epoch + 2.hours(),
}])
Expand Down
2 changes: 1 addition & 1 deletion tests/orbit_determination/spacecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn od_val_sc_mb_srp_reals_duals_models() {
// Define the tracking configurations
let mut configs = HashMap::new();
let cfg = TrkConfig::builder()
.strands(vec![EpochRanges {
.strands(vec![Strand {
start: epoch,
end: epoch + prop_time,
}])
Expand Down
8 changes: 4 additions & 4 deletions tests/orbit_determination/trackingarc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nyx_space::md::prelude::*;
use nyx_space::od::msr::RangeDoppler;
use nyx_space::od::prelude::*;
use nyx_space::od::simulator::TrackingArcSim;
use nyx_space::od::simulator::{Cadence, EpochRanges, TrkConfig};
use nyx_space::od::simulator::{Cadence, Strand, TrkConfig};
use rstest::*;
use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -185,7 +185,7 @@ fn trkconfig_zero_inclusion(traj: Traj<Orbit>, devices: Vec<GroundStation>) {

// Build a tracking config that should always see this vehicle.
let trkcfg_always = TrkConfig::builder()
.strands(vec![EpochRanges {
.strands(vec![Strand {
start: traj.first().epoch(),
end: traj.last().epoch(),
}])
Expand Down Expand Up @@ -216,7 +216,7 @@ fn trkconfig_zero_inclusion(traj: Traj<Orbit>, devices: Vec<GroundStation>) {
fn trkconfig_invalid(traj: Traj<Orbit>, devices: Vec<GroundStation>) {
// Build a tracking config where the exclusion range is less than the sampling rate
let trkcfg = TrkConfig::builder()
.strands(vec![EpochRanges {
.strands(vec![Strand {
start: traj.first().epoch(),
end: traj.first().epoch(),
}])
Expand All @@ -237,7 +237,7 @@ fn trkconfig_delayed_start(traj: Traj<Orbit>, devices: Vec<GroundStation>) {
let cosm = Cosm::de438();

let trkcfg = TrkConfig::builder()
.strands(vec![EpochRanges {
.strands(vec![Strand {
start: traj.first().epoch() + 2.hours(),
end: traj.last().epoch(),
}])
Expand Down

0 comments on commit c2845b4

Please sign in to comment.