ARTS 2.5.0 (git: 9ee3ac6c)
igrf13.cc
Go to the documentation of this file.
1#include <algorithm>
2
3#include "constants.h"
4#include "igrf13.h"
5#include "legendre.h"
6
21namespace IGRF {
23constexpr std::array<Numeric, 196> g2020{
24 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
25 -29404.8, -1450.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
26 -2499.6, 2982.0, 1677.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
27 1363.2, -2381.2, 1236.2, 525.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
28 903.0, 809.5, 86.3, -309.4, 48.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
29 -234.3, 363.2, 187.8, -140.7, -151.2, 13.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
30 66.0, 65.5, 72.9, -121.5, -36.2, 13.5, -64.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
31 80.6, -76.7, -8.2, 56.5, 15.8, 6.4, -7.2, 9.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
32 23.7, 9.7, -17.6, -0.5, -21.1, 15.3, 13.7, -16.5, -0.3, 0.0, 0.0, 0.0, 0.0, 0.0,
33 5.0, 8.4, 2.9, -1.5, -1.1, -13.2, 1.1, 8.8, -9.3, -11.9, 0.0, 0.0, 0.0, 0.0,
34 -1.9, -6.2, -0.1, 1.7, -0.9, 0.7, -0.9, 1.9, 1.4, -2.4, -3.8, 0.0, 0.0, 0.0,
35 3.0, -1.4, -2.5, 2.3, -0.9, 0.3, -0.7, -0.1, 1.4, -0.6, 0.2, 3.1, 0.0, 0.0,
36 -2.0, -0.1, 0.5, 1.3, -1.2, 0.7, 0.3, 0.5, -0.3, -0.5, 0.1, -1.1, -0.3, 0.0,
37 0.1, -0.9, 0.5, 0.7, -0.3, 0.8, 0.0, 0.8, 0.0, 0.4, 0.1, 0.5, -0.5, -0.4,
38};
39
41constexpr std::array<Numeric, 196> h2020{
42 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
43 0.0, 4652.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
44 0.0, -2991.6, -734.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
45 0.0, -82.1, 241.9, -543.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
46 0.0, 281.9, -158.4, 199.7, -349.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
47 0.0, 47.7, 208.3, -121.2, 32.3, 98.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
48 0.0, -19.1, 25.1, 52.8, -64.5, 8.9, 68.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
49 0.0, -51.5, -16.9, 2.2, 23.5, -2.2, -27.2, -1.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
50 0.0, 8.4, -15.3, 12.8, -11.7, 14.9, 3.6, -6.9, 2.8, 0.0, 0.0, 0.0, 0.0, 0.0,
51 0.0, -23.4, 11.0, 9.8, -5.1, -6.3, 7.8, 0.4, -1.4, 9.6, 0.0, 0.0, 0.0, 0.0,
52 0.0, 3.4, -0.2, 3.6, 4.8, -8.6, -0.1, -4.3, -3.4, -0.1, -8.8, 0.0, 0.0, 0.0,
53 0.0, 0.0, 2.5, -0.6, -0.4, 0.6, -0.2, -1.7, -1.6, -3.0, -2.0, -2.6, 0.0, 0.0,
54 0.0, -1.2, 0.5, 1.4, -1.8, 0.1, 0.8, -0.2, 0.6, 0.2, -0.9, 0.0, 0.5, 0.0,
55 0.0, -0.9, 0.6, 1.4, -0.4, -1.3, -0.1, 0.3, -0.1, 0.5, 0.5, -0.4, -0.4, -0.6,
56};
57
59constexpr std::array<Numeric, 196> g2015{
60 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
61 -29441.46, -1501.77, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
62 -2445.88, 3012.2, 1676.35, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
63 1350.33, -2352.26, 1225.85, 581.69, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
64 907.42, 813.68, 120.49, -334.85, 70.38, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
65 -232.91, 360.14, 192.35, -140.94, -157.4, 4.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
66 69.55, 67.57, 72.79, -129.85, -28.93, 13.14, -70.85, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
67 81.29, -75.99, -6.79, 51.82, 15.07, 9.32, -2.88, 6.61, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
68 23.98, 8.89, -16.78, -3.16, -20.56, 13.33, 11.76, -15.98, -2.02, 0.0, 0.0, 0.0, 0.0, 0.0,
69 5.33, 8.83, 3.02, -3.22, 0.67, -13.2, -0.1, 8.68, -9.06, -10.54, 0.0, 0.0, 0.0, 0.0,
70 -2.01, -6.26, 0.17, 0.55, -0.55, 1.7, -0.67, 2.13, 2.33, -1.8, -3.59, 0.0, 0.0, 0.0,
71 3.0, -1.4, -2.3, 2.08, -0.79, 0.58, -0.7, 0.14, 1.7, -0.22, 0.44, 3.49, 0.0, 0.0,
72 -2.09, -0.16, 0.46, 1.23, -0.89, 0.85, 0.1, 0.54, -0.37, -0.43, 0.22, -0.94, -0.03, 0.0,
73 -0.02, -0.92, 0.42, 0.63, -0.42, 0.96, -0.19, 0.81, -0.13, 0.38, 0.08, 0.46, -0.35, -0.36,
74};
75
77constexpr std::array<Numeric, 196> h2015{
78 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
79 0.0, 4795.99, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
80 0.0, -2845.41, -642.17, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
81 0.0, -115.29, 245.04, -538.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
82 0.0, 283.54, -188.43, 180.95, -329.23, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
83 0.0, 46.98, 196.98, -119.14, 15.98, 100.12, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
84 0.0, -20.61, 33.3, 58.74, -66.64, 7.35, 62.41, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
85 0.0, -54.27, -19.53, 5.59, 24.45, 3.27, -27.5, -2.32, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
86 0.0, 10.04, -18.26, 13.18, -14.6, 16.16, 5.69, -9.1, 2.26, 0.0, 0.0, 0.0, 0.0, 0.0,
87 0.0, -21.77, 10.76, 11.74, -6.74, -6.88, 7.79, 1.04, -3.89, 8.44, 0.0, 0.0, 0.0, 0.0,
88 0.0, 3.28, -0.4, 4.55, 4.4, -7.92, -0.61, -4.16, -2.85, -1.12, -8.72, 0.0, 0.0, 0.0,
89 0.0, 0.0, 2.11, -0.6, -1.05, 0.76, -0.2, -2.12, -1.44, -2.57, -2.01, -2.34, 0.0, 0.0,
90 0.0, -1.08, 0.37, 1.75, -2.19, 0.27, 0.72, -0.09, 0.29, 0.23, -0.89, -0.16, 0.72, 0.0,
91 0.0, -0.88, 0.49, 1.56, -0.5, -1.24, -0.1, 0.42, -0.04, 0.48, 0.48, -0.3, -0.43, -0.71,
92};
93
95constexpr std::array<Numeric, 196> g2010{
96 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
97 -29496.57, -1586.42, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
98 -2396.06, 3026.34, 1668.17, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
99 1339.85, -2326.54, 1232.1, 633.73, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
100 912.66, 808.97, 166.58, -356.83, 89.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
101 -230.87, 357.29, 200.26, -141.05, -163.17, -8.03, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
102 72.78, 68.69, 75.92, -141.4, -22.83, 13.1, -78.09, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
103 80.44, -75.0, -4.55, 45.24, 14.0, 10.46, 1.64, 4.92, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
104 24.41, 8.21, -14.5, -5.59, -19.34, 11.61, 10.85, -14.05, -3.54, 0.0, 0.0, 0.0, 0.0, 0.0,
105 5.5, 9.45, 3.45, -5.27, 3.13, -12.38, -0.76, 8.43, -8.42, -10.08, 0.0, 0.0, 0.0, 0.0,
106 -1.94, -6.24, 0.89, -1.07, -0.16, 2.45, -0.33, 2.13, 3.09, -1.03, -2.8, 0.0, 0.0, 0.0,
107 3.05, -1.48, -2.03, 1.65, -0.51, 0.54, -0.79, 0.37, 1.79, 0.12, 0.75, 3.75, 0.0, 0.0,
108 -2.12, -0.21, 0.3, 1.04, -0.63, 0.95, -0.11, 0.52, -0.39, -0.37, 0.21, -0.77, 0.04, 0.0,
109 -0.09, -0.89, 0.31, 0.42, -0.45, 1.08, -0.31, 0.78, -0.18, 0.38, 0.02, 0.42, -0.26, -0.26,
110};
111
113constexpr std::array<Numeric, 196> h2010{
114 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
115 0.0, 4944.26, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
116 0.0, -2708.54, -575.73, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
117 0.0, -160.4, 251.75, -537.03, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
118 0.0, 286.48, -211.03, 164.46, -309.72, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
119 0.0, 44.58, 189.01, -118.06, -0.01, 101.04, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
120 0.0, -20.9, 44.18, 61.54, -66.26, 3.02, 55.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
121 0.0, -57.8, -21.2, 6.54, 24.96, 7.03, -27.61, -3.28, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
122 0.0, 10.84, -20.03, 11.83, -17.41, 16.71, 6.96, -10.74, 1.64, 0.0, 0.0, 0.0, 0.0, 0.0,
123 0.0, -20.54, 11.51, 12.75, -7.14, -7.42, 7.97, 2.14, -6.08, 7.01, 0.0, 0.0, 0.0, 0.0,
124 0.0, 2.73, -0.1, 4.71, 4.44, -7.22, -0.96, -3.95, -1.99, -1.97, -8.31, 0.0, 0.0, 0.0,
125 0.0, 0.13, 1.67, -0.66, -1.76, 0.85, -0.39, -2.51, -1.27, -2.11, -1.94, -1.86, 0.0, 0.0,
126 0.0, -0.87, 0.27, 2.13, -2.49, 0.49, 0.59, 0.0, 0.13, 0.27, -0.86, -0.23, 0.87, 0.0,
127 0.0, -0.87, 0.3, 1.66, -0.59, -1.14, -0.07, 0.54, 0.1, 0.49, 0.44, -0.25, -0.53, -0.79,
128};
129
131constexpr std::array<Numeric, 196> g2005{
132 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
133 -29554.63, -1669.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
134 -2337.24, 3047.69, 1657.76, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
135 1336.3, -2305.83, 1246.39, 672.51, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
136 920.55, 797.96, 210.65, -379.86, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
137 -227.0, 354.41, 208.95, -136.54, -168.05, -13.55, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
138 73.6, 69.56, 76.74, -151.34, -14.58, 14.58, -86.36, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
139 79.88, -74.46, -1.65, 38.73, 12.3, 9.37, 5.42, 1.94, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
140 24.8, 7.62, -11.73, -6.88, -18.11, 10.17, 9.36, -11.25, -4.87, 0.0, 0.0, 0.0, 0.0, 0.0,
141 5.58, 9.76, 3.58, -6.94, 5.01, -10.76, -1.25, 8.76, -6.66, -9.22, 0.0, 0.0, 0.0, 0.0,
142 -2.17, -6.12, 1.42, -2.35, -0.15, 3.06, 0.29, 2.06, 3.77, -0.21, -2.09, 0.0, 0.0, 0.0,
143 2.95, -1.6, -1.88, 1.44, -0.31, 0.29, -0.79, 0.53, 1.8, 0.16, 0.96, 3.99, 0.0, 0.0,
144 -2.15, -0.29, 0.21, 0.89, -0.38, 0.96, -0.3, 0.46, -0.35, -0.36, 0.08, -0.49, -0.08, 0.0,
145 -0.16, -0.88, 0.3, 0.28, -0.43, 1.18, -0.37, 0.75, -0.26, 0.35, -0.05, 0.41, -0.1, -0.18,
146};
147
149constexpr std::array<Numeric, 196> h2005{
150 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
151 0.0, 5077.99, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
152 0.0, -2594.5, -515.43, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
153 0.0, -198.86, 269.72, -524.72, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
154 0.0, 282.07, -225.23, 145.15, -305.36, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
155 0.0, 42.72, 180.25, -123.45, -19.57, 103.85, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
156 0.0, -20.33, 54.75, 63.63, -63.53, 0.24, 50.94, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
157 0.0, -61.14, -22.57, 6.82, 25.35, 10.93, -26.32, -4.64, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
158 0.0, 11.2, -20.88, 9.83, -19.71, 16.22, 7.61, -12.76, -0.06, 0.0, 0.0, 0.0, 0.0, 0.0,
159 0.0, -20.11, 12.69, 12.67, -6.72, -8.16, 8.1, 2.92, -7.73, 6.01, 0.0, 0.0, 0.0, 0.0,
160 0.0, 2.19, 0.1, 4.46, 4.76, -6.58, -1.01, -3.47, -0.86, -2.31, -7.93, 0.0, 0.0, 0.0,
161 0.0, 0.26, 1.44, -0.77, -2.27, 0.9, -0.58, -2.69, -1.08, -1.58, -1.9, -1.39, 0.0, 0.0,
162 0.0, -0.55, 0.23, 2.38, -2.63, 0.61, 0.4, 0.01, 0.02, 0.28, -0.87, -0.34, 0.88, 0.0,
163 0.0, -0.76, 0.33, 1.72, -0.54, -1.07, -0.04, 0.63, 0.21, 0.53, 0.38, -0.22, -0.57, -0.82,
164};
165
167constexpr std::array<Numeric, 196> g2000{
168 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
169 -29619.4, -1728.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
170 -2267.7, 3068.4, 1670.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
171 1339.6, -2288.0, 1252.1, 714.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
172 932.3, 786.8, 250.0, -403.0, 111.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
173 -218.8, 351.4, 222.3, -130.4, -168.6, -12.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
174 72.3, 68.2, 74.2, -160.9, -5.9, 16.9, -90.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
175 79.0, -74.0, 0.0, 33.3, 9.1, 6.9, 7.3, -1.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
176 24.4, 6.6, -9.2, -7.9, -16.6, 9.1, 7.0, -7.9, -7.0, 0.0, 0.0, 0.0, 0.0, 0.0,
177 5.0, 9.4, 3.0, -8.4, 6.3, -8.9, -1.5, 9.3, -4.3, -8.2, 0.0, 0.0, 0.0, 0.0,
178 -2.6, -6.0, 1.7, -3.1, -0.5, 3.7, 1.0, 2.0, 4.2, 0.3, -1.1, 0.0, 0.0, 0.0,
179 2.7, -1.7, -1.9, 1.5, -0.1, 0.1, -0.7, 0.7, 1.7, 0.1, 1.2, 4.0, 0.0, 0.0,
180 -2.2, -0.3, 0.2, 0.9, -0.2, 0.9, -0.5, 0.3, -0.3, -0.4, -0.1, -0.2, -0.4, 0.0,
181 -0.2, -0.9, 0.3, 0.1, -0.4, 1.3, -0.4, 0.7, -0.4, 0.3, -0.1, 0.4, 0.0, 0.1,
182};
183
185constexpr std::array<Numeric, 196> h2000{
186 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
187 0.0, 5186.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
188 0.0, -2481.6, -458.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
189 0.0, -227.6, 293.4, -491.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
190 0.0, 272.6, -231.9, 119.8, -303.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
191 0.0, 43.8, 171.9, -133.1, -39.3, 106.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
192 0.0, -17.4, 63.7, 65.1, -61.2, 0.7, 43.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
193 0.0, -64.6, -24.2, 6.2, 24.0, 14.8, -25.4, -5.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
194 0.0, 11.9, -21.5, 8.5, -21.5, 15.5, 8.9, -14.9, -2.1, 0.0, 0.0, 0.0, 0.0, 0.0,
195 0.0, -19.7, 13.4, 12.5, -6.2, -8.4, 8.4, 3.8, -8.2, 4.8, 0.0, 0.0, 0.0, 0.0,
196 0.0, 1.7, 0.0, 4.0, 4.9, -5.9, -1.2, -2.9, 0.2, -2.2, -7.4, 0.0, 0.0, 0.0,
197 0.0, 0.1, 1.3, -0.9, -2.6, 0.9, -0.7, -2.8, -0.9, -1.2, -1.9, -0.9, 0.0, 0.0,
198 0.0, -0.4, 0.3, 2.5, -2.6, 0.7, 0.3, 0.0, 0.0, 0.3, -0.9, -0.4, 0.8, 0.0,
199 0.0, -0.9, 0.2, 1.8, -0.4, -1.0, -0.1, 0.7, 0.3, 0.6, 0.3, -0.2, -0.5, -0.9,
200};
201
203constexpr Numeric r0{6371.2e3};
204
206Matrix matrix(const std::array<Numeric, 196> data) {
207 Matrix m(14, 14);
208 Index k = 0;
209 for (Index i=0; i<14; i++) for (Index j=0; j<14; j++) m(i, j) = data[k++];
210 return m;
211}
212
222Numeric radius(const Numeric h, const Numeric lat, const Numeric lon, const Numeric a, const Numeric e) ARTS_NOEXCEPT {
223 using std::sqrt;
224 using Conversion::pow2;
225 using Conversion::cosd;
226 using Conversion::sind;
227
228 ARTS_ASSERT(e >= 0 and e < 1)
229
230 const Numeric N = a / sqrt(1 - pow2(e * sind(lat)));
231
232 return std::hypot ((N + h) * cosd(lon) * cosd(lat),
233 (N + h) * sind(lon) * cosd(lat),
234 (N * (1 - pow2(e)) + h) * sind(lat));
235}
236
250 Vector& r,
251 const Matrix& g,
252 const Matrix& h,
253 const Tensor3& z_field,
254 const Vector& lat_grid,
255 const Vector& lon_grid,
256 const Vector& ell,
257 const Numeric scale) ARTS_NOEXCEPT {
258 // Constant sizes
259 const Index nz = z_field.npages();
260 const Index nlat = z_field.nrows();
261 const Index nlon = z_field.ncols();
262
263 for (Index ilat=0; ilat<nlat; ilat++) {
264 const Numeric lat = lat_grid[ilat];
265
266 for (Index ilon=0; ilon<nlon; ilon++) {
267 for (Index iz=0; iz<nz; iz++) {
268 r[ilon + nlon * iz] = radius(z_field(iz, ilat, ilon), lat, lon_grid[ilon], ell[0], ell[1]);
269 }
270 }
271
272 auto f = Legendre::schmidt_fieldcalc(g, h, r0, r, lat, lon_grid);
273 for (Index ilon=0; ilon<nlon; ilon++) {
274 for (Index iz=0; iz<nz; iz++) {
275 out.u(iz, ilat, ilon) = scale * f(ilon + nlon * iz, ilon).E;
276 out.v(iz, ilat, ilon) = - scale * f(ilon + nlon * iz, ilon).S;
277 out.w(iz, ilat, ilon) += scale * f(ilon + nlon * iz, ilon).U;
278 }
279 }
280 }
281}
282
283MagneticField compute(const Tensor3& z_field, const Vector& lat_grid, const Vector& lon_grid, const Time& time, const Vector& ell) {
284 // Constant sizes
285 const Index nz = z_field.npages();
286 const Index nlat = z_field.nrows();
287 const Index nlon = z_field.ncols();
288
289 // Compute vector
290 Vector r(nlon * nz);
291
292 // Output
293 MagneticField out(nz, nlat, nlon); // Inits to zeroes
294
295 // Select the correct time
296 if (const Time y2020("2020-01-01 00:00:00"); time >= y2020) {
297 const Matrix g(matrix(g2020));
298 const Matrix h(matrix(h2020));
299
300 compute_impl(out, r, g, h, z_field, lat_grid, lon_grid, ell, 1.0);
301 } else if (const Time y2015("2020-01-01 00:00:00"); time >= y2015) {
302 const Numeric scale = (time.Seconds() - y2015.Seconds()) / (y2020.Seconds() - y2015.Seconds());
303 ARTS_ASSERT(scale >= 0 and scale < 1)
304
305 const Matrix g0(matrix(g2020));
306 const Matrix h0(matrix(h2020));
307 compute_impl(out, r, g0, h0, z_field, lat_grid, lon_grid, ell, scale);
308
309 const Matrix g1(matrix(g2015));
310 const Matrix h1(matrix(h2015));
311 compute_impl(out, r, g1, h1, z_field, lat_grid, lon_grid, ell, 1.0 - scale);
312 } else if (const Time y2010("2020-01-01 00:00:00"); time >= y2010) {
313 const Numeric scale = (time.Seconds() - y2010.Seconds()) / (y2015.Seconds() - y2010.Seconds());
314 ARTS_ASSERT(scale >= 0 and scale < 1)
315
316 const Matrix g0(matrix(g2015));
317 const Matrix h0(matrix(h2015));
318 compute_impl(out, r, g0, h0, z_field, lat_grid, lon_grid, ell, scale);
319
320 const Matrix g1(matrix(g2010));
321 const Matrix h1(matrix(h2010));
322 compute_impl(out, r, g1, h1, z_field, lat_grid, lon_grid, ell, 1.0 - scale);
323 } else if (const Time y2005("2020-01-01 00:00:00"); time >= y2005) {
324 const Numeric scale = (time.Seconds() - y2005.Seconds()) / (y2010.Seconds() - y2005.Seconds());
325 ARTS_ASSERT(scale >= 0 and scale < 1)
326
327 const Matrix g0(matrix(g2010));
328 const Matrix h0(matrix(h2010));
329 compute_impl(out, r, g0, h0, z_field, lat_grid, lon_grid, ell, scale);
330
331 const Matrix g1(matrix(g2005));
332 const Matrix h1(matrix(h2005));
333 compute_impl(out, r, g1, h1, z_field, lat_grid, lon_grid, ell, 1.0 - scale);
334 } else if (const Time y2000("2020-01-01 00:00:00"); time >= y2000) {
335 const Numeric scale = (time.Seconds() - y2000.Seconds()) / (y2005.Seconds() - y2000.Seconds());
336 ARTS_ASSERT(scale >= 0 and scale < 1)
337
338 const Matrix g0(matrix(g2005));
339 const Matrix h0(matrix(h2005));
340 compute_impl(out, r, g0, h0, z_field, lat_grid, lon_grid, ell, scale);
341
342 const Matrix g1(matrix(g2000));
343 const Matrix h1(matrix(h2000));
344 compute_impl(out, r, g1, h1, z_field, lat_grid, lon_grid, ell, 1.0 - scale);
345 } else {
346 const Matrix g(matrix(g2000));
347 const Matrix h(matrix(h2000));
348 compute_impl(out, r, g, h, z_field, lat_grid, lon_grid, ell, 1.0);
349 }
350
351 // Conversion from nano-Tesla to Tesla
352 out.u *= 1e-9;
353 out.v *= 1e-9;
354 out.w *= 1e-9;
355
356 return out;
357}
358} // namespace IGRF
void * data
Index npages() const
Returns the number of pages.
Definition: matpackIII.h:144
Index nrows() const
Returns the number of rows.
Definition: matpackIII.h:147
Index ncols() const
Returns the number of columns.
Definition: matpackIII.h:150
The Matrix class.
Definition: matpackI.h:1225
The Tensor3 class.
Definition: matpackIII.h:339
Class to handle time in ARTS.
Definition: artstime.h:41
Numeric Seconds() const
Definition: artstime.h:81
The Vector class.
Definition: matpackI.h:876
Constants of physical expressions as constexpr.
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
Contains the code to calculate Legendre polynomials.
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
constexpr auto pow2(T x) -> decltype(x *x)
power of two
Definition: constants.h:65
auto sind(T x) -> decltype(std::sin(deg2rad(x)))
Returns the sine of the deg2rad of the input.
Definition: constants.h:346
auto cosd(T x) -> decltype(std::cos(deg2rad(x)))
Returns the cosine of the deg2rad of the input.
Definition: constants.h:340
International Geomagnetic Reference Field version 13.
Definition: igrf13.cc:21
void compute_impl(MagneticField &out, Vector &r, const Matrix &g, const Matrix &h, const Tensor3 &z_field, const Vector &lat_grid, const Vector &lon_grid, const Vector &ell, const Numeric scale) ARTS_NOEXCEPT
Perform all computations on pre-allocated local data.
Definition: igrf13.cc:249
constexpr std::array< Numeric, 196 > g2005
g-coefficients for 2005 (14x14 matrix)
Definition: igrf13.cc:131
constexpr std::array< Numeric, 196 > g2020
g-coefficients for 2020 (14x14 matrix)
Definition: igrf13.cc:23
constexpr std::array< Numeric, 196 > h2000
h-coefficients for 2000 (14x14 matrix)
Definition: igrf13.cc:185
constexpr std::array< Numeric, 196 > h2015
h-coefficients for 2015 (14x14 matrix)
Definition: igrf13.cc:77
MagneticField compute(const Tensor3 &z_field, const Vector &lat_grid, const Vector &lon_grid, const Time &time, const Vector &ell)
Computes the magnetic field based on IGRF13 coefficients.
Definition: igrf13.cc:283
constexpr std::array< Numeric, 196 > g2015
g-coefficients for 2015 (14x14 matrix)
Definition: igrf13.cc:59
constexpr std::array< Numeric, 196 > h2010
h-coefficients for 2010 (14x14 matrix)
Definition: igrf13.cc:113
constexpr std::array< Numeric, 196 > h2005
h-coefficients for 2005 (14x14 matrix)
Definition: igrf13.cc:149
Numeric radius(const Numeric h, const Numeric lat, const Numeric lon, const Numeric a, const Numeric e) ARTS_NOEXCEPT
Get the radius from ellipsoidal coordinates.
Definition: igrf13.cc:222
constexpr std::array< Numeric, 196 > g2000
g-coefficients for 2000 (14x14 matrix)
Definition: igrf13.cc:167
Matrix matrix(const std::array< Numeric, 196 > data)
Create the square matrix from the static data.
Definition: igrf13.cc:206
constexpr Numeric r0
The reference radius in IGRF13.
Definition: igrf13.cc:203
constexpr std::array< Numeric, 196 > h2020
h-coefficients for 2020 (14x14 matrix)
Definition: igrf13.cc:41
constexpr std::array< Numeric, 196 > g2010
g-coefficients for 2010 (14x14 matrix)
Definition: igrf13.cc:95
SphericalField schmidt_fieldcalc(const Matrix &g, const Matrix &h, const Numeric r0, const Numeric r, const Numeric lat, const Numeric lon) ARTS_NOEXCEPT
Computes the spherical field.
Definition: legendre.cc:2082
#define a
Numeric sqrt(const Rational r)
Square root.
Definition: rational.h:739
#define N
Definition: rng.cc:164
Magnetic field for the east (u), north (v), and up (w) components as the ENU-coordinate system.
Definition: igrf13.h:9