Skip to content

Commit

Permalink
clock coherency / interpolation logic
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Mar 6, 2024
1 parent 586ffd9 commit 4873a56
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
13 changes: 13 additions & 0 deletions rinex-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ pub struct Context {
/// 1. manually defined by CLI
/// 2. determined from dataset
pub rx_ecef: Option<(f64, f64, f64)>,
/// True if (high precision) CLK product needs to be interpolated.
/// False if both CLK and OBS products are not present.
/// False if both are present but this is a high quality/state of the art context.
pub needs_clock_interpolation: bool,
}

impl Context {
Expand Down Expand Up @@ -148,8 +152,17 @@ impl Context {
}
let data_stem = Self::context_stem(&data);
let data_position = data.ground_position();

let needs_clock_interpolation = data.needs_clock_interpolation();
if !needs_clock_interpolation {
info!("coherent precise products detected: interpolation is not required");
} else {
warn!("incoherent CLK/OBS products: interpolation will be needed");
}

Ok(Self {
data,
needs_clock_interpolation,
quiet: cli.matches.get_flag("quiet"),
workspace: {
let path = match std::env::var("RINEX_WORKSPACE") {
Expand Down
33 changes: 31 additions & 2 deletions rinex-cli/src/positioning/ppp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! PPP solver
use crate::cli::Context;
use crate::positioning::{bd_model, kb_model, ng_model, tropo_components};
use hifitime::TimeScale;
use rinex::carrier::Carrier;
use rinex::navigation::Ephemeris;
use rinex::prelude::SV;
Expand Down Expand Up @@ -59,13 +60,15 @@ where

// determine TOE
let (toe, sv_eph) = sv_eph.unwrap();

/*
* Clock state
* 1. Prefer CLK product
* 2. Prefer SP3 product
* 3. Radio last option: always feasible
*/
let clock_state = if let Some(clk) = clk_data {
//if ctx.needs_clock_interpolation {
if let Some((_, profile)) = clk.precise_sv_clock_interpolate(*t, *sv) {
(
profile.bias,
Expand All @@ -74,15 +77,41 @@ where
)
} else {
/*
* do not interpolate other products: abort
* interpolation failure.
* Do not interpolate other products: SV will not be presented.
*/
continue;
}
//} else {
// if let Some(profile) = clk.precise_sv_clock()
// .filter_map(|(clk_t, clk_sv, _, profile)| {
// if clk_t == *t && clk_sv == *sv {
// Some(profile)
// } else {
// None
// }
// }).reduce(|k, _| k)
// {
// (
// profile.bias,
// profile.drift.unwrap_or(0.0),
// profile.drift_change.unwrap_or(0.0),
// )
// } else {
// /*
// * When using high precision products it's better not to attempt
// * this in other products, which would mix high and low precision products
// * in the solution. We simply abort.
// */
// continue;
// }
//}
} else if sp3_has_clock {
panic!("sp3 (clock) interpolation not ready yet: prefer broadcast or clk product");
panic!("sp3 (clock) not ready yet: prefer broadcast or clk product");
} else {
sv_eph.sv_clock() // BRDC case
};

// determine clock correction
let clock_corr = Ephemeris::sv_clock_corr(*sv, clock_state, *t, toe);

Expand Down
8 changes: 4 additions & 4 deletions rinex/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ impl RnxContext {
if let Ok(rnx) = Rinex::from_path(path) {
if rnx.is_observation_rinex() {
self.load_obs(path, &rnx)?;
trace!("loaded observations \"{}\"", filename);
trace!("loaded signal observations \"{}\"", filename);
} else if rnx.is_navigation_rinex() {
self.load_nav(path, &rnx)?;
trace!("loaded brdc nav \"{}\"", filename);
trace!("loaded broadcast nav \"{}\"", filename);
} else if rnx.is_meteo_rinex() {
self.load_meteo(path, &rnx)?;
trace!("loaded meteo observations \"{}\"", filename);
} else if rnx.is_clock_rinex() {
self.load_clock(path, &rnx)?;
trace!("loaded clock data \"{}\"", filename);
trace!("loaded high precision clock product \"{}\"", filename);
} else if rnx.is_ionex() {
self.load_ionex(path, &rnx)?;
trace!("loaded ionex \"{}\"", filename);
Expand All @@ -151,7 +151,7 @@ impl RnxContext {
}
} else if let Ok(sp3) = SP3::from_file(&fullpath) {
self.load_sp3(path, &sp3)?;
trace!("loaded sp3 \"{}\"", filename);
trace!("loaded high precision oribits \"{}\"", filename);
}
Ok(())
}
Expand Down

0 comments on commit 4873a56

Please sign in to comment.