Skip to content

Commit

Permalink
Fix clock offset scaling, especially in sp3 interpolation (#222)
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres authored Mar 28, 2024
1 parent d481068 commit 484d8db
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 deletions.
4 changes: 2 additions & 2 deletions crx2rnx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "crx2rnx"
version = "2.3.1"
version = "2.3.2"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "RINEX data decompressor"
Expand All @@ -12,4 +12,4 @@ readme = "README.md"

[dependencies]
clap = { version = "4.4.13", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.6", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.7", features = ["serde"] }
8 changes: 4 additions & 4 deletions rinex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ horrorshow = "0.8"
clap = { version = "4.4.13", features = ["derive", "color"] }
hifitime = { version = "3.9.0", features = ["serde", "std"] }
gnss-rs = { version = "2.1.3" , features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.6", features = ["full"] }
rinex-qc = { path = "../rinex-qc", version = "=0.1.11", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.7", features = ["serde", "flate2"] }
rinex = { path = "../rinex", version = "=0.15.7", features = ["full"] }
rinex-qc = { path = "../rinex-qc", version = "=0.1.12", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde", "flate2"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }

# plotly
plotly = "0.8.4"
# plotly = { git = "https://github.com/gwbres/plotly", branch = "density-mapbox" }

# solver
gnss-rtk = { version = "0.4.2", features = ["serde"] }
gnss-rtk = { version = "0.4.3", features = ["serde"] }
# gnss-rtk = { path = "../../rtk-rs/gnss-rtk", features = ["serde"] }

# cggtts
Expand Down
20 changes: 10 additions & 10 deletions rinex-cli/src/graph/record/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn ctx_sv_clock_corrections(
obs: &Rinex,
nav: &Rinex,
clk: Option<&Rinex>,
_sp3: Option<&SP3>,
sp3: Option<&SP3>,
) -> CtxClockCorrections {
let mut clock_corr = CtxClockCorrections::new();
for ((t, flag), (_, vehicles)) in obs.observation() {
Expand All @@ -215,8 +215,15 @@ fn ctx_sv_clock_corrections(
let clock_state: Option<(f64, f64, f64)> = match product {
ProductType::Radio => Some(sv_eph.sv_clock()),
ProductType::HighPrecisionSp3 => {
//TODO: sv_clock interpolate please
None
if let Some(sp3) = sp3 {
if let Some(bias) = sp3.sv_clock_interpolate(*t, *sv) {
Some((bias, 0.0_f64, 0.0_f64))
} else {
None
}
} else {
None
}
},
ProductType::HighPrecisionClk => {
if let Some(clk) = clk {
Expand All @@ -233,13 +240,6 @@ fn ctx_sv_clock_corrections(
}
})
.reduce(|k, _| k)
//if let Some((_, profile)) = clk
// .precise_sv_clock_interpolate(*t, *sv)
//{
// Some((profile.bias, profile.drift.unwrap_or(0.0_f64), profile.drift_change.unwrap_or(0.0_f64)))
//} else {
// None
//}
} else {
None
}
Expand Down
6 changes: 3 additions & 3 deletions rinex-qc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rinex-qc"
version = "0.1.11"
version = "0.1.12"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "RINEX data analysis"
Expand All @@ -26,9 +26,9 @@ strum_macros = "0.26"
horrorshow = "0.8"
itertools = "0.12.0"
statrs = "0.16"
sp3 = { path = "../sp3", version = "=1.0.7", features = ["serde"] }
sp3 = { path = "../sp3", version = "=1.0.8", features = ["serde"] }
rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1" }
rinex = { path = "../rinex", version = "=0.15.6", features = ["full"] }
rinex = { path = "../rinex", version = "=0.15.7", features = ["full"] }
gnss-rs = { version = "2.1.3", features = ["serde"] }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions rinex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rinex"
version = "0.15.6"
version = "0.15.7"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "Package to parse and analyze RINEX data"
Expand Down Expand Up @@ -101,7 +101,7 @@ rinex-qc-traits = { path = "../qc-traits", version = "=0.1.1", optional = true }

# RINEX Context dependencies
walkdir = { version = "2.4.0", optional = true }
sp3 = { path = "../sp3", version = "=1.0.7", optional = true }
sp3 = { path = "../sp3", version = "=1.0.8", optional = true }

[dev-dependencies]
serde_json = "1"
Expand Down
4 changes: 2 additions & 2 deletions rnx2crx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rnx2crx"
version = "1.2.1"
version = "1.2.2"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "RINEX data compressor"
Expand All @@ -14,4 +14,4 @@ readme = "README.md"
[dependencies]
thiserror = "1"
clap = { version = "4.4.13", features = ["derive", "color"] }
rinex = { path = "../rinex", version = "=0.15.6", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.7", features = ["serde"] }
2 changes: 1 addition & 1 deletion sp3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sp3"
version = "1.0.7"
version = "1.0.8"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "IGS SP3 file parser"
Expand Down
7 changes: 3 additions & 4 deletions sp3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct SP3 {
pub sv: Vec<SV>,
/// Positions expressed in km, with 1mm precision, per Epoch and SV.
pub position: PositionRecord,
/// Clock estimates in microseconds, with 1E-12 precision per Epoch and SV.
/// Clock offsets with 1E-12 precision per Epoch and SV.
pub clock: ClockRecord,
/// Velocities (Position derivative estimates) in 10^-1 m/s with 0.1 um/s precision.
pub velocities: VelocityRecord,
Expand Down Expand Up @@ -518,8 +518,7 @@ impl SP3 {
.iter()
.flat_map(|(e, sv)| sv.iter().map(|(sv, vel)| (*e, *sv, *vel)))
}
/// Returns an Iterator over Clock error estimates, in microseconds
/// with 1E-12 precision.
/// Returns an Iterator over Clock offsets with theoretical 1E-12 precision.
pub fn sv_clock(&self) -> impl Iterator<Item = (Epoch, SV, f64)> + '_ {
self.clock
.iter()
Expand All @@ -532,7 +531,7 @@ impl SP3 {
.iter()
.flat_map(|(e, sv)| sv.iter().map(|(sv, clk)| (*e, *sv, *clk)))
}
/// Interpolate Clock state at desired "t" expressed in the timescale you want.
/// Interpolate Clock (offset) at desired "t" expressed in the timescale you want.
/// SP3 files usually have a 15' sampling interval which makes this operation
/// most likely incorrect. You should either use higher sample rate to reduce
/// the error generated by interpolation, or use different products like
Expand Down
2 changes: 1 addition & 1 deletion sp3/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl std::str::FromStr for PositionEntry {
*/
let clk_data = f64::from_str(line[46..60].trim())
.or(Err(ParsingError::Clock(line[46..60].to_string())))?;
clock = Some(clk_data);
clock = Some(clk_data * 1.0E-6);
}
Ok(Self {
sv,
Expand Down
10 changes: 5 additions & 5 deletions sp3/src/tests/parser_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ mod test {
for (epoch, sv, clock) in sp3.sv_clock() {
assert_eq!(epoch, Epoch::from_str("2019-10-27T00:00:00 GPST").unwrap());
if sv == sv!("C01") {
assert_eq!(clock, 63.035497, "bad clock data");
assert!((clock - 63.035497E-6).abs() < 1E-9, "bad clock data");
} else if sv == sv!("E01") {
assert_eq!(clock, -718.927492, "bad clock data");
assert!((clock - -718.927492E-6).abs() < 1E-9, "bad clock data");
} else if sv == sv!("G01") {
assert_eq!(clock, -176.397152, "bad clock data");
assert!((clock - -176.397152E-6).abs() < 1E-9, "bad clock data");
} else if sv == sv!("J01") {
assert_eq!(clock, -336.145158, "bad clock data");
assert!((clock - -336.145158E-6).abs() < 1E-9, "bad clock data");
} else if sv == sv!("R01") {
assert_eq!(clock, 51.759894, "bad clock data");
assert!((clock - 51.759894E-6).abs() < 1E-9, "bad clock data");
} else {
panic!("identified wrong sv");
}
Expand Down
4 changes: 2 additions & 2 deletions ublox-rnx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ublox-rnx"
version = "0.1.5"
version = "0.1.6"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "Efficient RINEX production from a Ublox GNSS receiver"
Expand All @@ -22,4 +22,4 @@ serialport = "4.2.0"
ublox = "0.4.4"
clap = { version = "4.4.10", features = ["derive", "color"] }
gnss-rs = { version = "2.1.3", features = ["serde"] }
rinex = { path = "../rinex", version = "=0.15.6", features = ["serde", "nav", "obs"] }
rinex = { path = "../rinex", version = "=0.15.7", features = ["serde", "nav", "obs"] }

0 comments on commit 484d8db

Please sign in to comment.