Skip to content

Commit 35d2ac7

Browse files
committed
improving cli application
Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent cedb4ef commit 35d2ac7

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

cggtts-cli/src/main.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use plot::PlotContext;
66

77
mod processing;
88

9+
use std::io::Write;
910
use std::path::Path;
11+
use std::process::Command;
1012

1113
#[macro_use]
1214
extern crate log;
@@ -16,9 +18,7 @@ use walkdir::WalkDir;
1618

1719
use cggtts::prelude::CGGTTS;
1820

19-
use std::io::Write;
20-
21-
use std::process::Command;
21+
use itertools::Itertools;
2222

2323
#[cfg(target_os = "linux")]
2424
pub fn open_with_web_browser(path: &str) {
@@ -109,16 +109,30 @@ pub fn main() {
109109

110110
if cli.identification() {
111111
for p in pool {
112-
info!("station: {}", p.station);
113-
info!("number of tracks: {}", p.tracks.len());
112+
info!("STATION \"{}\"", p.station);
113+
info!("NUMBER OF TRACKS {}", p.tracks.len());
114+
info!(
115+
"CODES {:?}",
116+
p.tracks()
117+
.map(|trk| trk.frc.clone())
118+
.unique()
119+
.collect::<Vec<_>>()
120+
);
121+
info!(
122+
"SV {:?}",
123+
p.tracks()
124+
.map(|trk| trk.sv.to_string())
125+
.unique()
126+
.collect::<Vec<_>>()
127+
);
114128
}
115129
return;
116130
}
117131

118132
if pool.len() == 1 {
119133
processing::single_clock(&pool[0], &mut plot_ctx);
120134
} else {
121-
processing::clock_comparison(&pool, &mut plot_ctx);
135+
processing::clock_comparison(&workspace_path, &pool, &mut plot_ctx);
122136
}
123137

124138
/*

cggtts-cli/src/processing.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ use cggtts::prelude::{Epoch, CGGTTS};
22
use itertools::Itertools;
33
use plotly::common::Mode;
44
use std::collections::HashMap;
5+
use std::fs::File;
6+
use std::io::Write;
7+
use std::path::Path;
58

69
use crate::plot::{
710
//build_timedomain_plot,
@@ -180,7 +183,7 @@ pub fn single_clock(cggtts: &CGGTTS, ctx: &mut PlotContext) {
180183
}
181184
}
182185

183-
pub fn clock_comparison(pool: &Vec<CGGTTS>, ctx: &mut PlotContext) {
186+
pub fn clock_comparison(workspace: &Path, pool: &Vec<CGGTTS>, ctx: &mut PlotContext) {
184187
let ref_clock = &pool[0];
185188
info!("{} is considered reference clock", ref_clock.station);
186189

@@ -241,4 +244,42 @@ pub fn clock_comparison(pool: &Vec<CGGTTS>, ctx: &mut PlotContext) {
241244
}
242245
}
243246
}
247+
248+
let mut fd = File::create(workspace.join(&pool[0].station))
249+
.expect("failed to create textfile: permission denied");
250+
251+
writeln!(fd, "{}", "t, CLOCK(A), CLOCK(B), SV, (elev[°], azi[°]) @REF, (elev[°], azi[°]) @CLOCK, SIGNAL, CLOCK(A) - CLOCK(B) [s]")
252+
.expect("failed to generate textfile");
253+
254+
for trk in ref_clock.tracks() {
255+
let ref_t = trk.epoch;
256+
let ref_sv = trk.sv;
257+
let (ref_elev, ref_azim) = (trk.elevation, trk.azimuth);
258+
let ref_frc = &trk.frc;
259+
for i in 1..pool.len() {
260+
let track = pool[i]
261+
.tracks()
262+
.filter(|trk| trk.epoch == ref_t && trk.sv == ref_sv && trk.frc == *ref_frc)
263+
.reduce(|trk, _| trk);
264+
if let Some(b_trk) = track {
265+
let (b_elev, b_azim) = (b_trk.elevation, b_trk.azimuth);
266+
let dt = b_trk.data.refsys - trk.data.refsys;
267+
writeln!(
268+
fd,
269+
"{:?}, {}, {}, {}, ({:.2E}, {:.2E}), ({:.2E}, {:.2E}), {}, {:.3E}",
270+
ref_t,
271+
pool[i].station,
272+
pool[0].station,
273+
ref_sv,
274+
ref_elev,
275+
ref_azim,
276+
b_elev,
277+
b_azim,
278+
ref_frc,
279+
dt
280+
)
281+
.expect("failed to generate textfile");
282+
}
283+
}
284+
}
244285
}

0 commit comments

Comments
 (0)