0.3.0
Loading...
Searching...
No Matches
GMF.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/// @file GMF.cpp
10/// @brief Global Mapping Function (GMF)
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2024-04-21
13/// @note See \cite Böhm2006a Böhm2006: Global Mapping Function (GMF): A new empirical mapping function based on numerical weather model data
14/// @note See https://vmf.geo.tuwien.ac.at/codes/ for code sources in matlab.
15
16#include "GMF.hpp"
18
20{
21
22namespace
23{
24
25// degree n and order m
26constexpr int nmax = 9;
27
28std::array<Eigen::Matrix<double, nmax + 1, nmax + 1>, 2> calcLegendrePolynomials(const Eigen::Vector3d& lla_pos)
29{
30 // unit vector
31 double x = std::cos(lla_pos(0)) * std::cos(lla_pos(1));
32 double y = std::cos(lla_pos(0)) * std::sin(lla_pos(1));
33 double z = std::sin(lla_pos(0));
34
35 // Legendre polynomials
36 Eigen::Matrix<double, nmax + 1, nmax + 1> V;
37 Eigen::Matrix<double, nmax + 1, nmax + 1> W;
38
39 V(0, 0) = 1;
40 W(0, 0) = 0;
41 V(1, 0) = z * V(0, 0);
42 W(1, 0) = 0;
43
44 for (int n = 2; n <= nmax; n++)
45 {
46 auto dn = static_cast<double>(n);
47 V(n, 0) = ((2 * dn - 1) * z * V(n - 1, 0) - (dn - 1) * V(n - 2, 0)) / dn;
48 W(n, 0) = 0;
49 }
50 for (int m = 1; m <= nmax; m++)
51 {
52 auto dm = static_cast<double>(m);
53 V(m, m) = (2 * dm - 1) * (x * V(m - 1, m - 1) - y * W(m - 1, m - 1));
54 W(m, m) = (2 * dm - 1) * (x * W(m - 1, m - 1) + y * V(m - 1, m - 1));
55 if (m < nmax)
56 {
57 V(m + 1, m) = (2 * dm + 1) * z * V(m, m);
58 W(m + 1, m) = (2 * dm + 1) * z * W(m, m);
59 }
60 for (int n = m + 2; n <= nmax; n++)
61 {
62 auto dn = static_cast<double>(n);
63 V(n, m) = ((2 * dn - 1) * z * V(n - 1, m) - (dn + dm - 1) * V(n - 2, m)) / (dn - dm);
64 W(n, m) = ((2 * dn - 1) * z * W(n - 1, m) - (dn + dm - 1) * W(n - 2, m)) / (dn - dm);
65 }
66 }
67
68 return { V, W };
69}
70
71} // namespace
72
73} // namespace NAV::internal::GMF
74
75double NAV::calcTropoMapFunc_GMFH(double mjd, const Eigen::Vector3d& lla_pos, double elevation)
76{
77 using namespace internal::GMF; // NOLINT(google-build-using-namespace)
78
79 // reference day is 28 January
80 // this is taken from Niell (1996) to be consistent
81 double doy = mjd - 44239.0 + 1 - 28;
82
83 auto [V, W] = calcLegendrePolynomials(lla_pos);
84
85 double bh = 0.0029;
86 double c0h = 0.062;
87 double phh = 0.0;
88 double c11h = 0.0;
89 double c10h = 0.0;
90 if (lla_pos(0) < 0) // southern hemisphere
91 {
92 phh = M_PI;
93 c11h = 0.007;
94 c10h = 0.002;
95 }
96 else // northern hemisphere
97 {
98 phh = 0;
99 c11h = 0.005;
100 c10h = 0.001;
101 }
102 double ch = c0h + ((std::cos(doy / 365.25 * 2 * M_PI + phh) + 1) * c11h / 2 + c10h) * (1 - std::cos(lla_pos(0)));
103
104 double ahm = 0;
105 double aha = 0;
106 size_t i = 0;
107 for (int n = 0; n <= nmax; n++)
108 {
109 for (int m = 0; m <= n; m++)
110 {
111 ahm = ahm + (ah_mean.at(i) * V(n, m) + bh_mean.at(i) * W(n, m));
112 aha = aha + (ah_amp.at(i) * V(n, m) + bh_amp.at(i) * W(n, m));
113 i = i + 1;
114 }
115 }
116 double ah = (ahm + aha * std::cos(doy / 365.25 * 2 * M_PI)) * 1e-5;
117
118 double sine = std::sin(elevation);
119 double beta = bh / (sine + ch);
120 double gamma = ah / (sine + beta);
121 double topcon = (1 + ah / (1 + bh / (1 + ch)));
122 double gmfh = topcon / (sine + gamma);
123
124 // height correction for hydrostatic mapping function from Niell (1996) in order to reduce the coefficients to sea level
125 double a_ht = 2.53e-5;
126 double b_ht = 5.49e-3;
127 double c_ht = 1.14e-3;
128 double hs_km = lla_pos(2) / 1000;
129
130 beta = b_ht / (sine + c_ht);
131 gamma = a_ht / (sine + beta);
132 topcon = (1 + a_ht / (1 + b_ht / (1 + c_ht)));
133 double ht_corr_coef = 1 / sine - topcon / (sine + gamma);
134 double ht_corr = ht_corr_coef * hs_km;
135 gmfh += ht_corr;
136
137 return gmfh;
138}
139
140double NAV::calcTropoMapFunc_GMFW(double mjd, const Eigen::Vector3d& lla_pos, double elevation)
141{
142 using namespace internal::GMF; // NOLINT(google-build-using-namespace)
143
144 // reference day is 28 January
145 // this is taken from Niell (1996) to be consistent
146 double doy = mjd - 44239.0 + 1 - 28;
147
148 auto [V, W] = calcLegendrePolynomials(lla_pos);
149
150 double bw = 0.00146;
151 double cw = 0.04391;
152
153 double awm = 0.0;
154 double awa = 0.0;
155 size_t i = 0;
156 for (int n = 0; n <= nmax; n++)
157 {
158 for (int m = 0; m <= n; m++)
159 {
160 awm = awm + (aw_mean.at(i) * V(n, m) + bw_mean.at(i) * W(n, m));
161 awa = awa + (aw_amp.at(i) * V(n, m) + bw_amp.at(i) * W(n, m));
162 i = i + 1;
163 }
164 }
165 double aw = (awm + awa * std::cos(doy / 365.25 * 2 * M_PI)) * 1e-5;
166
167 double sine = std::sin(elevation);
168 double beta = bw / (sine + cw);
169 double gamma = aw / (sine + beta);
170 double topcon = (1 + aw / (1 + bw / (1 + cw)));
171 double gmfw = topcon / (sine + gamma);
172
173 return gmfw;
174}
GMF Coefficients.
Global Mapping Function (GMF)
double calcTropoMapFunc_GMFH(double mjd, const Eigen::Vector3d &lla_pos, double elevation)
Calculates the Global Mapping Function (GMF) for the hydrostatic delay.
Definition GMF.cpp:75
double calcTropoMapFunc_GMFW(double mjd, const Eigen::Vector3d &lla_pos, double elevation)
Calculates the Global Mapping Function (GMF) for the wet delay.
Definition GMF.cpp:140