Skip to content

Commit d3e1032

Browse files
authored
bump to v4.1.1 (#8)
* bump to v4.1.1 * scheduler: fit the measure ionospheric delay when feasible * run clippy --------- Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent 35d2ac7 commit d3e1032

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-29
lines changed

cggtts-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cggtts-cli"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
license = "MIT OR Apache-2.0"
55
authors = ["Guillaume W. Bres <[email protected]>"]
66
description = "Command line tool parse and analyze CGGTTS data"
@@ -17,6 +17,6 @@ itertools = "0.11.0"
1717
env_logger = "0.10"
1818
clap = { version = "4.4.6", features = ["derive", "color"] }
1919
serde = { version = "1.0", default-features = false, features = ["derive"] }
20-
cggtts = { path = "../cggtts", version = "=4.1.0" }
20+
cggtts = { path = "../cggtts", version = "=4.1.1" }
2121
plotly = "0.8.4"
2222
# plotly = { git = "https://github.com/gwbres/plotly", branch = "density-mapbox" }

cggtts-cli/src/processing.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn clock_comparison(workspace: &Path, pool: &Vec<CGGTTS>, ctx: &mut PlotCont
209209
.tracks()
210210
.filter_map(|trk| {
211211
if trk.sv == *sv && &trk.frc == code {
212-
if let Some(_) = refsys.get(&trk.epoch) {
212+
if refsys.get(&trk.epoch).is_some() {
213213
Some(trk.epoch)
214214
} else {
215215
None
@@ -223,11 +223,9 @@ pub fn clock_comparison(workspace: &Path, pool: &Vec<CGGTTS>, ctx: &mut PlotCont
223223
.tracks()
224224
.filter_map(|trk| {
225225
if trk.sv == *sv && &trk.frc == code {
226-
if let Some(refsys) = refsys.get(&trk.epoch) {
227-
Some(trk.data.refsys - refsys)
228-
} else {
229-
None
230-
}
226+
refsys
227+
.get(&trk.epoch)
228+
.map(|refsys| trk.data.refsys - refsys)
231229
} else {
232230
None
233231
}
@@ -248,7 +246,7 @@ pub fn clock_comparison(workspace: &Path, pool: &Vec<CGGTTS>, ctx: &mut PlotCont
248246
let mut fd = File::create(workspace.join(&pool[0].station))
249247
.expect("failed to create textfile: permission denied");
250248

251-
writeln!(fd, "{}", "t, CLOCK(A), CLOCK(B), SV, (elev[°], azi[°]) @REF, (elev[°], azi[°]) @CLOCK, SIGNAL, CLOCK(A) - CLOCK(B) [s]")
249+
writeln!(fd, "t, CLOCK(A), CLOCK(B), SV, (elev[°], azi[°]) @REF, (elev[°], azi[°]) @CLOCK, SIGNAL, CLOCK(A) - CLOCK(B) [s]")
252250
.expect("failed to generate textfile");
253251

254252
for trk in ref_clock.tracks() {

cggtts/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cggtts"
3-
version = "4.1.0"
3+
version = "4.1.1"
44
license = "MIT OR Apache-2.0"
55
authors = ["Guillaume W. Bres <[email protected]>"]
66
description = "Package to analyze and create CGGTTS data"

cggtts/src/tests/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mod test {
147147

148148
let _dumped = cggtts.to_string();
149149
let _compare = std::fs::read_to_string(
150-
(env!("CARGO_MANIFEST_DIR").to_owned() + "/../data/single/GZSY8259.568"),
150+
env!("CARGO_MANIFEST_DIR").to_owned() + "/../data/single/GZSY8259.568",
151151
)
152152
.unwrap();
153153
}

cggtts/src/track/scheduler.rs

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::prelude::{Duration, Epoch, TimeScale, TrackData};
1+
use crate::prelude::{Duration, Epoch, IonosphericData, TimeScale, TrackData};
22
use polyfit_rs::polyfit_rs::polyfit;
33
use std::collections::BTreeMap;
44
use thiserror::Error;
@@ -59,14 +59,22 @@ pub struct FitData {
5959
}
6060

6161
impl SVTracker {
62+
/* has msio data */
63+
fn has_msio(&self) -> bool {
64+
self.buffer
65+
.values()
66+
.filter(|data| data.msio.is_some())
67+
.count()
68+
> 0
69+
}
6270
/// Try to fit a track. You need to provide the ongoing IOE.
6371
pub fn fit(
6472
&self,
6573
ioe: u16,
6674
trk_duration: Duration,
6775
sampling_period: Duration,
6876
trk_midpoint: Epoch,
69-
) -> Result<((f64, f64), TrackData), FitError> {
77+
) -> Result<((f64, f64), TrackData, Option<IonosphericData>), FitError> {
7078
// verify tracking completion
7179
// complete if we have enough measurements
7280
let expected_nb =
@@ -209,21 +217,6 @@ impl SVTracker {
209217
let (smdi, smdi_b) = (fit[1], fit[0]);
210218
let mdio = smdi * t_mid_s + smdi_b;
211219

212-
let fit = polyfit(
213-
&t_xs,
214-
&self
215-
.buffer
216-
.values()
217-
.map(|f| f.msio.unwrap_or(0.0_f64))
218-
.collect::<Vec<_>>()
219-
.as_slice(),
220-
1,
221-
)
222-
.map_err(|_| FitError::LinearRegressionFailure)?;
223-
224-
let (smsi, smsi_b) = (fit[1], fit[0]);
225-
let msio = smsi * t_mid_s + smsi_b;
226-
227220
let trk_data = TrackData {
228221
refsv,
229222
srsv,
@@ -237,7 +230,36 @@ impl SVTracker {
237230
smdi,
238231
};
239232

240-
Ok(((elev, azi), trk_data))
233+
let iono_data = match self.has_msio() {
234+
false => None,
235+
true => {
236+
let fit = polyfit(
237+
&t_xs,
238+
&self
239+
.buffer
240+
.values()
241+
.map(|f| f.msio.unwrap())
242+
.collect::<Vec<_>>()
243+
.as_slice(),
244+
1,
245+
)
246+
.map_err(|_| FitError::LinearRegressionFailure)?;
247+
248+
let (smsi, smsi_b) = (fit[1], fit[0]);
249+
let msio = smsi * t_mid_s + smsi_b;
250+
251+
let mut isg = 0.0_f64;
252+
let msio_fit: Vec<_> = t_xs.iter().map(|t_s| smsi * t_s + smsi_b).collect();
253+
for msio_fit in msio_fit {
254+
isg += (msio_fit - msio).powi(2);
255+
}
256+
isg = isg.sqrt();
257+
258+
Some(IonosphericData { msio, smsi, isg })
259+
},
260+
};
261+
262+
Ok(((elev, azi), trk_data, iono_data))
241263
}
242264

243265
/// Latch a new measurement at given UTC Epoch.

0 commit comments

Comments
 (0)