rinex-cli 0.15.0

GNSS data post processing and quality control, powered by GNSS-Qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
//! P.V.T solutions (nav command, cggtts --solutions)
use std::collections::BTreeMap;

use gnss_qc::{
    geodesy::{ecef_to_enu_vector, ecef_to_geodetic},
    prelude::{Epoch, QcNavigationReport, QcOutput, QcOutputItem},
};

use crate::{
    engine::SessionContext,
    report::{
        analysis::Analysis, elapsed_s, sky::SkyAccumulator, stats::fmt, Block, Chart, ChartKind,
        Section, Series, Stats, Table,
    },
    sink::RunSummary,
};

#[derive(Debug, Clone, Copy)]
struct Solution {
    epoch: Epoch,
    pos_m: (f64, f64, f64),
    lat_long_alt: (f64, f64, f64),
    clock_offset_s: f64,
    gdop: f64,
    hdop: f64,
    vdop: f64,
    tdop: f64,
    satellites: usize,
}

/// ECEF coordinates (m)
type Ecef = (f64, f64, f64);

pub struct NavigationAnalysis {
    /// Reference position of the rover
    reference_ecef_m: Option<(f64, f64, f64)>,
    rover: Option<String>,
    /// Moving rover: displacements rather than errors
    moving: bool,
    /// RTK base: identity and position
    base: Option<(String, Option<Ecef>)>,
    solutions: BTreeMap<String, Vec<Solution>>,
    reports: BTreeMap<String, QcNavigationReport>,
    /// Satellites used by the solver, per receiver
    skies: BTreeMap<String, SkyAccumulator>,
}

/// Map of the solutions: the track is colored by the elapsed time (minutes),
/// the RTK base (if any) is marked
fn trajectory_map(
    title: &str,
    receiver: &str,
    origin: Epoch,
    solutions: &[Solution],
    base: Option<(&str, Ecef)>,
    baseline_end: Option<Ecef>,
) -> Chart {
    let mut chart = Chart::xy(title, "Longitude (°)", "Latitude (°)")
        .with_kind(ChartKind::Map)
        .with_color_label("minutes");

    if let (Some((_, base_ecef_m)), Some(end)) = (base, baseline_end) {
        let (base_lat, base_long, _) = degrees(base_ecef_m);
        let (lat, long, _) = degrees(end);
        let mut baseline = Series::new("baseline").connected();
        baseline.push(base_long, base_lat);
        baseline.push(long, lat);
        chart.push(baseline);
    }

    let mut track = Series::new(receiver);
    let mut minutes = Vec::with_capacity(solutions.len());
    for s in solutions.iter() {
        track.push(s.lat_long_alt.1, s.lat_long_alt.0);
        minutes.push(elapsed_s(origin, s.epoch) / 60.0);
    }
    chart.push(track.with_colors(minutes));

    if let Some((name, base_ecef_m)) = base {
        let (lat, long, _) = degrees(base_ecef_m);
        let mut point = Series::new(&format!("base: {}", name)).anchor();
        point.push(long, lat);
        chart.push(point);
    }

    chart
}

/// Distance travelled, speed, altitude range of a moving rover
fn trajectory_summary(solutions: &[Solution]) -> Vec<(String, String)> {
    let mut distance = 0.0;
    let mut speeds = Stats::default();
    let mut climb = 0.0;
    for w in solutions.windows(2) {
        let (a, b) = (&w[0], &w[1]);
        let (e, n, u) = ecef_to_enu_vector(a.pos_m, sub3(b.pos_m, a.pos_m));
        let horizontal = (e * e + n * n).sqrt();
        distance += horizontal;
        if u > 0.0 {
            climb += u;
        }
        let dt = (b.epoch - a.epoch).to_seconds();
        if dt > 0.0 {
            speeds.push(horizontal / dt);
        }
    }
    let altitudes = solutions.iter().map(|s| s.lat_long_alt.2);
    let (alt_min, alt_max) = altitudes.fold((f64::MAX, f64::MIN), |(a, b), h| (a.min(h), b.max(h)));
    vec![
        (
            "Distance travelled (horizontal)".to_string(),
            format!("{:.0} m", distance),
        ),
        (
            "Speed".to_string(),
            format!(
                "mean {:.2} m/s ({:.1} km/h), max {:.2} m/s",
                speeds.mean(),
                speeds.mean() * 3.6,
                speeds.max
            ),
        ),
        (
            "Altitude".to_string(),
            format!(
                "{:.1} → {:.1} m (cumulated climb {:.0} m)",
                alt_min, alt_max, climb
            ),
        ),
    ]
}

/// World map, centered on the solutions (and the base)
fn locator(receiver: &str, solutions: &[Solution], base: Option<(&str, Ecef)>) -> Chart {
    let mut chart =
        Chart::xy("Location", "Longitude (°)", "Latitude (°)").with_kind(ChartKind::Globe);
    if let Some(last) = solutions.last() {
        let mut point = Series::new(receiver);
        point.push(last.lat_long_alt.1, last.lat_long_alt.0);
        chart.push(point);
    }
    if let Some((name, base_ecef_m)) = base {
        let (lat, long, _) = degrees(base_ecef_m);
        let mut point = Series::new(&format!("base: {}", name));
        point.push(long, lat);
        chart.push(point);
    }
    chart
}

impl NavigationAnalysis {
    pub fn new(context: &SessionContext) -> Self {
        Self {
            reference_ecef_m: context
                .navigation
                .as_ref()
                .and_then(|nav| nav.reference_ecef_m),
            rover: context.navigation.as_ref().map(|nav| nav.rover.clone()),
            moving: context.navigation.as_ref().is_some_and(|nav| nav.moving),
            base: context.navigation.as_ref().and_then(|nav| {
                nav.base
                    .as_ref()
                    .map(|base| (base.clone(), nav.base_ecef_m))
            }),
            solutions: BTreeMap::new(),
            reports: BTreeMap::new(),
            skies: BTreeMap::new(),
        }
    }
}

/// Error statistics over a set of solutions
#[derive(Default)]
struct ErrorStats {
    east: Stats,
    north: Stats,
    up: Stats,
    horizontal: Stats,
    error_3d: Stats,
}

impl ErrorStats {
    fn push(&mut self, (e, n, u): (f64, f64, f64)) {
        self.east.push(e);
        self.north.push(n);
        self.up.push(u);
        self.horizontal.push((e * e + n * n).sqrt());
        self.error_3d.push((e * e + n * n + u * u).sqrt());
    }

    fn row(&self, label: &str) -> Vec<String> {
        vec![
            label.to_string(),
            self.east.n.to_string(),
            format!("{} ± {}", fmt(self.east.mean(), 3), fmt(self.east.std(), 3)),
            format!(
                "{} ± {}",
                fmt(self.north.mean(), 3),
                fmt(self.north.std(), 3)
            ),
            format!("{} ± {}", fmt(self.up.mean(), 3), fmt(self.up.std(), 3)),
            fmt(self.horizontal.rms(), 3),
            fmt(self.error_3d.rms(), 3),
            fmt(self.horizontal.max, 3),
            fmt(self.up.max_abs(), 3),
        ]
    }
}

fn sub3(a: (f64, f64, f64), b: (f64, f64, f64)) -> (f64, f64, f64) {
    (a.0 - b.0, a.1 - b.1, a.2 - b.2)
}

fn norm3(a: (f64, f64, f64)) -> f64 {
    (a.0 * a.0 + a.1 * a.1 + a.2 * a.2).sqrt()
}

fn degrees(ecef_m: (f64, f64, f64)) -> (f64, f64, f64) {
    let (lat, long, alt) = ecef_to_geodetic(ecef_m);
    (lat.to_degrees(), long.to_degrees(), alt)
}

/// RTK baseline: base → rover vector (local frame of the base), estimated and reference
#[allow(clippy::too_many_arguments)]
fn baseline_section(
    section: &mut Section,
    origin: Epoch,
    base: &str,
    base_ecef_m: (f64, f64, f64),
    reference_ecef_m: Option<(f64, f64, f64)>,
    rover: &str,
    solutions: &[Solution],
    moving: bool,
) {
    // static rover: mean of the last 50 % (converged); moving rover: last solution
    let half = solutions.len() / 2;
    let (estimated, estimated_label) = if moving {
        (
            solutions.last().map(|s| s.pos_m).unwrap_or_default(),
            "Baseline (last solution)",
        )
    } else {
        (
            mean_position(&solutions[half..]),
            "Estimated baseline (last 50 %)",
        )
    };

    let estimated_enu = ecef_to_enu_vector(base_ecef_m, sub3(estimated, base_ecef_m));
    let estimated_length = norm3(sub3(estimated, base_ecef_m));

    let (base_lat, base_long, base_alt) = degrees(base_ecef_m);

    section.push(Block::Heading("RTK baseline".to_string()));
    section.push(Block::Text(
        "Differential navigation: the rover is positioned relative to the base, whose coordinates are fixed. The baseline is the base → rover vector, expressed in the local frame (east, north, up) of the base.".to_string(),
    ));

    let mut items = vec![
        ("Base".to_string(), base.to_string()),
        (
            "Base position".to_string(),
            format!(
                "ECEF {:.3} {:.3} {:.3} m — {:.6}°, {:.6}°, {:.3} m",
                base_ecef_m.0, base_ecef_m.1, base_ecef_m.2, base_lat, base_long, base_alt
            ),
        ),
        (
            estimated_label.to_string(),
            format!(
                "{:.3} m — east {:.3} m, north {:.3} m, up {:.3} m",
                estimated_length, estimated_enu.0, estimated_enu.1, estimated_enu.2
            ),
        ),
    ];

    if moving {
        let lengths = solutions
            .iter()
            .map(|s| norm3(sub3(s.pos_m, base_ecef_m)))
            .collect::<Vec<_>>();
        let (min, max) = lengths
            .iter()
            .fold((f64::MAX, f64::MIN), |(a, b), l| (a.min(*l), b.max(*l)));
        items.push((
            "Baseline length".to_string(),
            format!("{:.1} → {:.1} m over the session", min, max),
        ));
    }

    if let Some(reference) = reference_ecef_m {
        let reference_enu = ecef_to_enu_vector(base_ecef_m, sub3(reference, base_ecef_m));
        let reference_length = norm3(sub3(reference, base_ecef_m));
        let error = sub3(estimated_enu, reference_enu);

        items.push((
            "Reference baseline".to_string(),
            format!(
                "{:.3} m — east {:.3} m, north {:.3} m, up {:.3} m",
                reference_length, reference_enu.0, reference_enu.1, reference_enu.2
            ),
        ));
        items.push((
            "Baseline error (last 50 %)".to_string(),
            format!(
                "length {:+.3} m — east {:+.3} m, north {:+.3} m, up {:+.3} m ({:.1} ppm)",
                estimated_length - reference_length,
                error.0,
                error.1,
                error.2,
                1.0E6 * norm3(error) / reference_length.max(1.0)
            ),
        ));
    }

    section.push(Block::KeyValue(items));

    // map: base, rover track (time), baseline; world map
    section.push(Block::Chart(trajectory_map(
        "RTK: rover trajectory and base (color: minutes elapsed)",
        rover,
        origin,
        solutions,
        Some((base, base_ecef_m)),
        Some(estimated),
    )));
    section.push(Block::Chart(locator(
        rover,
        solutions,
        Some((base, base_ecef_m)),
    )));

    // local frame of the base (km)
    let mut chart = Chart::xy(
        "RTK baseline, local frame of the base",
        "East (km)",
        "North (km)",
    )
    .with_equal_axes();

    let mut baseline = Series::new("baseline").connected();
    baseline.push(0.0, 0.0);
    baseline.push(estimated_enu.0 / 1.0E3, estimated_enu.1 / 1.0E3);
    chart.push(baseline);

    let mut rover_points = Series::new("rover solutions");
    for s in solutions.iter() {
        let enu = ecef_to_enu_vector(base_ecef_m, sub3(s.pos_m, base_ecef_m));
        rover_points.push(enu.0 / 1.0E3, enu.1 / 1.0E3);
    }
    chart.push(rover_points);
    section.push(Block::Chart(chart));

    // baseline length over time
    if moving && reference_ecef_m.is_none() {
        let mut chart = Chart::time("Baseline length", "m", origin);
        let mut series = Series::new("length");
        for s in solutions.iter() {
            series.push(
                elapsed_s(origin, s.epoch),
                norm3(sub3(s.pos_m, base_ecef_m)),
            );
        }
        chart.push(series);
        section.push(Block::Chart(chart));
    }

    if let Some(reference) = reference_ecef_m {
        let reference_length = norm3(sub3(reference, base_ecef_m));
        let mut chart = Chart::time("Baseline length error (estimated − reference)", "m", origin);
        let mut series = Series::new("length error");
        for s in solutions.iter() {
            series.push(
                elapsed_s(origin, s.epoch),
                norm3(sub3(s.pos_m, base_ecef_m)) - reference_length,
            );
        }
        chart.push(series);
        section.push(Block::Chart(chart));
    }
}

fn mean_position(solutions: &[Solution]) -> (f64, f64, f64) {
    let n = solutions.len().max(1) as f64;
    let (x, y, z) = solutions.iter().fold((0.0, 0.0, 0.0), |acc, s| {
        (acc.0 + s.pos_m.0, acc.1 + s.pos_m.1, acc.2 + s.pos_m.2)
    });
    (x / n, y / n, z / n)
}

impl Analysis for NavigationAnalysis {
    fn consume(&mut self, item: &QcOutputItem) {
        match &item.payload {
            QcOutput::PVTSolution(solution) => {
                let pvt = &solution.solution;

                let sky = self.skies.entry(solution.receiver.to_string()).or_default();
                for contribution in pvt.sv.iter() {
                    sky.seen(contribution.sv, pvt.epoch);
                    sky.position(
                        contribution.sv,
                        pvt.epoch,
                        contribution.azimuth_deg,
                        contribution.elevation_deg,
                    );
                }

                self.solutions
                    .entry(solution.receiver.to_string())
                    .or_default()
                    .push(Solution {
                        epoch: pvt.epoch,
                        pos_m: pvt.pos_m,
                        lat_long_alt: pvt.lat_long_alt_deg_deg_m,
                        clock_offset_s: pvt.clock_offset_s,
                        gdop: pvt.gdop,
                        hdop: pvt.hdop,
                        vdop: pvt.vdop,
                        tdop: pvt.tdop,
                        satellites: pvt.sv.len(),
                    });
            },
            QcOutput::NavigationReport(report) => {
                self.reports
                    .insert(report.receiver.to_string(), report.clone());
            },
            _ => {},
        }
    }

    fn sections(&mut self, _: &SessionContext, _: &RunSummary) -> Vec<Section> {
        let mut sections = Vec::new();

        let mut receivers = self
            .solutions
            .keys()
            .chain(self.reports.keys())
            .cloned()
            .collect::<Vec<_>>();
        receivers.sort();
        receivers.dedup();

        if receivers.is_empty() {
            let mut section = Section::new("navigation", "Navigation");
            section.push(Block::Notice(
                "No solution: verify the navigation products (NAV, SP3) cover the observations, and the constellations selected.".to_string(),
            ));
            sections.push(section);
            return sections;
        }

        for (index, receiver) in receivers.iter().enumerate() {
            let mut section = Section::new(
                &format!("navigation-{}", index),
                &format!("Navigation: {}", receiver),
            );

            let empty = Vec::new();
            let solutions = self.solutions.get(receiver).unwrap_or(&empty);

            if let Some(report) = self.reports.get(receiver) {
                let rate = 100.0 * report.solutions as f64 / report.epochs.max(1) as f64;
                section.push(Block::KeyValue(vec![
                    ("Epochs presented".to_string(), report.epochs.to_string()),
                    (
                        "Solutions".to_string(),
                        format!("{} ({:.1} %)", report.solutions, rate),
                    ),
                    (
                        "Orbital states".to_string(),
                        format!(
                            "{} precise, {} broadcast",
                            report.precise_orbits, report.broadcast_orbits
                        ),
                    ),
                    (
                        "Satellite clock states".to_string(),
                        format!(
                            "{} clock products, {} precise products, {} broadcast",
                            report.precise_clocks,
                            report.precise_state_clocks,
                            report.broadcast_clocks
                        ),
                    ),
                ]));

                if !report.failures.is_empty() {
                    let mut table = Table::new(&["Failure", "Epochs"]);
                    for (reason, count) in report.failures.iter() {
                        table.push(vec![reason.clone(), count.to_string()]);
                    }
                    section.push(Block::Table(table));
                }
            }

            let Some(first) = solutions.first() else {
                section.push(Block::Notice("No solution resolved.".to_string()));
                sections.push(section);
                continue;
            };

            let origin = first.epoch;

            // reference: rover reference position, otherwise the mean solution
            let is_rover = self.rover.as_deref() == Some(receiver.as_str());
            let moving = is_rover && self.moving;
            let (reference, reference_label) = match (is_rover, self.reference_ecef_m) {
                (true, Some(reference)) => (reference, "reference position"),
                _ if moving => (first.pos_m, "first solution"),
                _ => (mean_position(solutions), "mean position"),
            };
            // moving rover: displacements, not errors
            let errors = if moving { "Displacements" } else { "Errors" };

            let enu = solutions
                .iter()
                .map(|s| {
                    let delta = (
                        s.pos_m.0 - reference.0,
                        s.pos_m.1 - reference.1,
                        s.pos_m.2 - reference.2,
                    );
                    ecef_to_enu_vector(reference, delta)
                })
                .collect::<Vec<_>>();

            // position
            let half = solutions.len() / 2;
            let converged = mean_position(&solutions[half..]);
            let distance = ((converged.0 - reference.0).powi(2)
                + (converged.1 - reference.1).powi(2)
                + (converged.2 - reference.2).powi(2))
            .sqrt();

            let (lat, long, alt) = solutions.last().map(|s| s.lat_long_alt).unwrap_or_default();

            section.push(Block::Heading("Position".to_string()));
            section.push(Block::KeyValue(vec![
                (
                    "Reference".to_string(),
                    format!(
                        "{} — ECEF {:.3} {:.3} {:.3} m",
                        reference_label, reference.0, reference.1, reference.2
                    ),
                ),
                (
                    "Mean solution (last 50 %)".to_string(),
                    format!(
                        "ECEF {:.3} {:.3} {:.3} m — {:.3} m from the {}",
                        converged.0, converged.1, converged.2, distance, reference_label
                    ),
                ),
                (
                    "Last solution".to_string(),
                    format!("{:.8}°, {:.8}°, {:.3} m", lat, long, alt),
                ),
            ]));

            // errors
            let mut all = ErrorStats::default();
            let mut last_half = ErrorStats::default();
            for (i, error) in enu.iter().enumerate() {
                all.push(*error);
                if i >= half {
                    last_half.push(*error);
                }
            }

            if moving {
                section.push(Block::Heading("Trajectory".to_string()));
                section.push(Block::KeyValue(trajectory_summary(solutions)));
            }

            section.push(Block::Heading(format!(
                "{} (relative to the {})",
                errors, reference_label
            )));
            let mut table = Table::new(&[
                "Period",
                "Solutions",
                "East (m)",
                "North (m)",
                "Up (m)",
                "RMS 2D (m)",
                "RMS 3D (m)",
                "Max horizontal (m)",
                "Max vertical (m)",
            ]);
            table.push(all.row("Session"));
            table.push(last_half.row("Last 50 %"));
            section.push(Block::Table(table));

            let mut chart = Chart::time(
                if moving {
                    "Displacements"
                } else {
                    "Position errors"
                },
                "m",
                origin,
            );
            let mut series = [Series::new("East"), Series::new("North"), Series::new("Up")];
            for (s, (e, n, u)) in solutions.iter().zip(enu.iter()) {
                let x = elapsed_s(origin, s.epoch);
                series[0].push(x, *e);
                series[1].push(x, *n);
                series[2].push(x, *u);
            }
            for s in series {
                chart.push(s);
            }
            section.push(Block::Chart(chart));

            let mut chart = Chart::xy(
                if moving {
                    "Horizontal displacements"
                } else {
                    "Horizontal errors"
                },
                "East (m)",
                "North (m)",
            )
            .with_equal_axes();
            let mut horizontal = Series::new("solutions");
            for (e, n, _) in enu.iter() {
                horizontal.push(*e, *n);
            }
            chart.push(horizontal);
            section.push(Block::Chart(chart));

            // RTK: the trajectory map is part of the baseline section
            let rtk_base = match (is_rover, &self.base) {
                (true, Some((base, Some(base_ecef_m)))) => Some((base.as_str(), *base_ecef_m)),
                _ => None,
            };

            if rtk_base.is_none() {
                section.push(Block::Chart(trajectory_map(
                    "Trajectory (color: minutes elapsed)",
                    receiver,
                    origin,
                    solutions,
                    None,
                    None,
                )));
                section.push(Block::Chart(locator(receiver, solutions, None)));
            }

            if let (true, Some((base, Some(base_ecef_m)))) = (is_rover, &self.base) {
                baseline_section(
                    &mut section,
                    origin,
                    base,
                    *base_ecef_m,
                    self.reference_ecef_m,
                    receiver,
                    solutions,
                    moving,
                );
            }

            // differential navigation: no receiver clock
            let rtk = is_rover && self.base.is_some();

            if !rtk {
                let mut chart = Chart::time("Receiver clock offset", "µs", origin);
                let mut clock = Series::new("clock offset");
                for s in solutions.iter() {
                    clock.push(elapsed_s(origin, s.epoch), s.clock_offset_s * 1.0E6);
                }
                chart.push(clock);
                section.push(Block::Chart(chart));
            }

            let mut chart = Chart::time("Dilution of precision", "DOP", origin);
            let mut dops = [
                Series::new("GDOP"),
                Series::new("HDOP"),
                Series::new("VDOP"),
                Series::new("TDOP"),
            ];
            let mut svs = Series::new("satellites");
            for s in solutions.iter() {
                let x = elapsed_s(origin, s.epoch);
                dops[0].push(x, s.gdop);
                dops[1].push(x, s.hdop);
                dops[2].push(x, s.vdop);
                dops[3].push(x, s.tdop);
                svs.push(x, s.satellites as f64);
            }
            for s in dops {
                chart.push(s);
            }
            section.push(Block::Chart(chart));

            let mut chart = Chart::time("Satellites used", "satellites", origin);
            chart.push(svs);
            section.push(Block::Chart(chart));

            if let Some(sky) = self.skies.get(receiver) {
                section.push(Block::Heading("Satellites".to_string()));
                sky.push_blocks(
                    &mut section,
                    "Sky plot: satellites used by the solver",
                    "Satellites used by the solver, over time",
                );
            }

            sections.push(section);
        }

        sections
    }
}