Line | Branch | Exec | Source |
---|---|---|---|
1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
3 | // the University of Stuttgart, Germany. | ||
4 | // | ||
5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
8 | |||
9 | #include "Ionosphere.hpp" | ||
10 | |||
11 | #include <vector> | ||
12 | #include <array> | ||
13 | #include "internal/gui/widgets/EnumCombo.hpp" | ||
14 | #include "util/Logger.hpp" | ||
15 | |||
16 | #include "Models/Klobuchar.hpp" | ||
17 | |||
18 | #include "Navigation/GNSS/Functions.hpp" | ||
19 | #include "Navigation/Constants.hpp" | ||
20 | |||
21 | namespace NAV | ||
22 | { | ||
23 | |||
24 | ✗ | const char* to_string(IonosphereModel ionosphereModel) | |
25 | { | ||
26 | ✗ | switch (ionosphereModel) | |
27 | { | ||
28 | ✗ | case IonosphereModel::None: | |
29 | ✗ | return "None"; | |
30 | ✗ | case IonosphereModel::Klobuchar: | |
31 | ✗ | return "Klobuchar / Broadcast"; | |
32 | ✗ | case IonosphereModel::COUNT: | |
33 | ✗ | break; | |
34 | } | ||
35 | ✗ | return ""; | |
36 | } | ||
37 | |||
38 | ✗ | bool ComboIonosphereModel(const char* label, IonosphereModel& ionosphereModel) | |
39 | { | ||
40 | ✗ | return gui::widgets::EnumCombo(label, ionosphereModel); | |
41 | } | ||
42 | |||
43 | 41798 | double calcIonosphericDelay(double tow, Frequency freq, int8_t freqNum, | |
44 | const Eigen::Vector3d& lla_pos, | ||
45 | double elevation, double azimuth, | ||
46 | IonosphereModel ionosphereModel, | ||
47 | const IonosphericCorrections* corrections) | ||
48 | { | ||
49 |
5/6✓ Branch 1 taken 41516 times.
✓ Branch 2 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 41516 times.
✓ Branch 6 taken 282 times.
✓ Branch 7 taken 41516 times.
|
41798 | if (lla_pos(2) < -1000.0 || std::isnan(elevation)) |
50 | { | ||
51 | LOG_TRACE("Not calculating ionospheric delay, due to altitude being invalid: {}m", lla_pos(2)); | ||
52 | 282 | return 0.0; | |
53 | } | ||
54 | |||
55 |
2/3✓ Branch 0 taken 22237 times.
✓ Branch 1 taken 19279 times.
✗ Branch 2 not taken.
|
41516 | switch (ionosphereModel) |
56 | { | ||
57 | 22237 | case IonosphereModel::Klobuchar: | |
58 | { | ||
59 |
1/2✓ Branch 0 taken 22237 times.
✗ Branch 1 not taken.
|
22237 | if (corrections) |
60 | { | ||
61 |
1/2✓ Branch 2 taken 22237 times.
✗ Branch 3 not taken.
|
22237 | const auto* alpha = corrections->get(GPS, IonosphericCorrections::Alpha); |
62 |
1/2✓ Branch 2 taken 22237 times.
✗ Branch 3 not taken.
|
22237 | const auto* beta = corrections->get(GPS, IonosphericCorrections::Beta); |
63 |
2/4✓ Branch 0 taken 22237 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22237 times.
✗ Branch 3 not taken.
|
22237 | if (alpha && beta) |
64 | { | ||
65 | 22237 | return calcIonosphericTimeDelay_Klobuchar(tow, freq, freqNum, lla_pos(0), lla_pos(1), elevation, azimuth, *alpha, *beta) | |
66 | 22237 | * InsConst::C; | |
67 | } | ||
68 | } | ||
69 | |||
70 | ✗ | LOG_ERROR("Ionosphere model Klobuchar/Broadcast needs correction parameters. Ionospheric time delay will be 0."); | |
71 | ✗ | break; | |
72 | } | ||
73 | 19279 | case IonosphereModel::None: | |
74 | case IonosphereModel::COUNT: | ||
75 | 19279 | break; | |
76 | } | ||
77 | |||
78 | 19279 | return 0.0; | |
79 | } | ||
80 | |||
81 | 41798 | double ionoErrorVar(double dpsr_I, Frequency freq, int8_t num) | |
82 | { | ||
83 | 41798 | constexpr double ERR_BRDCI = 0.5; // Broadcast iono model error factor (See GPS ICD ch. 20.3.3.5.2.5, p. 130: 50% reduction on RMS error) | |
84 | |||
85 | 41798 | return ratioFreqSquared(freq.getL1(), freq, num, num) | |
86 | 41798 | * std::pow(dpsr_I * ERR_BRDCI, 2); | |
87 | } | ||
88 | |||
89 | } // namespace NAV | ||
90 |