0.3.0
Loading...
Searching...
No Matches
Ionosphere.cpp
Go to the documentation of this file.
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>
14#include "util/Logger.hpp"
15
16#include "Models/Klobuchar.hpp"
17
20
21namespace NAV
22{
23
24const char* to_string(IonosphereModel ionosphereModel)
25{
26 switch (ionosphereModel)
27 {
29 return "None";
31 return "Klobuchar / Broadcast";
33 break;
34 }
35 return "";
36}
37
38bool ComboIonosphereModel(const char* label, IonosphereModel& ionosphereModel)
39{
40 return gui::widgets::EnumCombo(label, ionosphereModel);
41}
42
43double 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 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 return 0.0;
53 }
54
55 switch (ionosphereModel)
56 {
58 {
59 if (corrections)
60 {
61 const auto* alpha = corrections->get(GPS, IonosphericCorrections::Alpha);
62 const auto* beta = corrections->get(GPS, IonosphericCorrections::Beta);
63 if (alpha && beta)
64 {
65 return calcIonosphericTimeDelay_Klobuchar(tow, freq, freqNum, lla_pos(0), lla_pos(1), elevation, azimuth, *alpha, *beta)
67 }
68 }
69
70 LOG_ERROR("Ionosphere model Klobuchar/Broadcast needs correction parameters. Ionospheric time delay will be 0.");
71 break;
72 }
75 break;
76 }
77
78 return 0.0;
79}
80
81double ionoErrorVar(double dpsr_I, Frequency freq, int8_t num)
82{
83 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 return ratioFreqSquared(freq.getL1(), freq, num, num)
86 * std::pow(dpsr_I * ERR_BRDCI, 2);
87}
88
89} // namespace NAV
Holds all Constants.
Combo representing an enumeration.
GNSS helper functions.
Ionosphere Models.
Klobuchar Ionospheric correction model.
Utility class for logging to console and file.
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
Definition Logger.hpp:73
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Definition Logger.hpp:65
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
Frequency getL1() const
Returns the L1 Frequency for each constellation.
static constexpr double C
Speed of light [m/s].
Definition Constants.hpp:34
@ Beta
Coefficients of a cubic equation representing the period of the model.
@ Alpha
Coefficients of a cubic equation representing the amplitude of the vertical delay.
const std::array< double, 4 > * get(SatelliteSystem satSys, AlphaBeta alphaBeta) const
Get the Ionospheric Correction values.
bool EnumCombo(const char *label, T &enumeration, size_t startIdx=0)
Combo representing an enumeration.
Definition EnumCombo.hpp:30
double ratioFreqSquared(Frequency f1, Frequency f2, int8_t num1, int8_t num2)
Calculates the ration of the frequencies squared γ
Definition Functions.cpp:24
IonosphereModel
Available Ionosphere Models.
@ COUNT
Amount of items in the enum.
@ None
Ionosphere model turned off.
@ Klobuchar
Klobuchar model (GPS), also called Broadcast sometimes.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
double ionoErrorVar(double dpsr_I, Frequency freq, int8_t num)
Calculates the ionospheric error variance.
bool ComboIonosphereModel(const char *label, IonosphereModel &ionosphereModel)
Shows a ComboBox to select the ionosphere model.
double calcIonosphericDelay(double tow, Frequency freq, int8_t freqNum, const Eigen::Vector3d &lla_pos, double elevation, double azimuth, IonosphereModel ionosphereModel, const IonosphericCorrections *corrections)
Calculates the ionospheric delay.
@ GPS
Global Positioning System.
double calcIonosphericTimeDelay_Klobuchar(double tow, Frequency freq, int8_t freqNum, double latitude, double longitude, double elevation, double azimuth, const std::array< double, 4 > &alpha, const std::array< double, 4 > &beta)
Calculates the ionospheric time delay with the Klobuchar model.
Definition Klobuchar.cpp:21