34 0.0, -29404.5, -1450.7, 4652.9,
35 -2500.0, 2982.0, -2991.6, 1676.8, -734.8,
36 1363.9, -2381.0, -82.2, 1236.2, 241.8, 525.7, -542.9,
37 903.1, 809.4, 282.0, 86.2, -158.4, -309.4, 199.8, 47.9, -350.1,
38 -234.4, 363.1, 47.7, 187.8, 208.4, -140.7, -121.3, -151.2, 32.2, 13.7, 99.1,
39 65.9, 65.6, -19.1, 73.0, 25.0, -121.5, 52.7, -36.2, -64.4, 13.5, 9.0, -64.7, 68.1,
40 80.6, -76.8, -51.4, -8.3, -16.8, 56.5, 2.3, 15.8, 23.5, 6.4, -2.2, -7.2, -27.2, 9.8, -1.9,
41 23.6, 9.8, 8.4, -17.5, -15.3, -0.4, 12.8, -21.1, -11.8, 15.3, 14.9, 13.7, 3.6, -16.5, -6.9, -0.3, 2.8,
42 5.0, 8.2, -23.3, 2.9, 11.1, -1.4, 9.8, -1.1, -5.1, -13.3, -6.2, 1.1, 7.8, 8.9, 0.4, -9.3, -1.5, -11.9, 9.7,
43 -1.9, -6.2, 3.4, -0.1, -0.2, 1.7, 3.5, -0.9, 4.8, 0.6, -8.6, -0.9, -0.1, 1.9, -4.2, 1.4, -3.4, -2.4, -0.1, -3.9, -8.8,
44 3.0, -1.4, 0.0, -2.5, 2.6, 2.4, -0.5, -0.9, -0.4, 0.3, 0.6, -0.7, -0.2, -0.1, -1.7, 1.4, -1.6, -0.6, -3.0, 0.2, -2.0, 3.1, -2.6,
45 -2.0, -0.1, -1.2, 0.5, 0.5, 1.3, 1.3, -1.2, -1.8, 0.7, 0.1, 0.3, 0.7, 0.5, -0.1, -0.2, 0.6, -0.5, 0.2, 0.1, -0.9, -1.1, 0.0, -0.3, 0.5
51 -11.5, -7.1, -30.2, -2.2, -23.9,
52 2.8, -6.2, 5.7, 3.4, -1.0, -12.2, 1.1,
53 -1.1, -1.6, 0.2, -6.0, 6.9, 5.4, 3.7, -5.5, -5.6,
54 -0.3, 0.6, 0.1, -0.7, 2.5, 0.1, -0.9, 1.2, 3.0, 1.0, 0.5,
55 -0.6, -0.4, 0.1, 0.5, -1.8, 1.4, -1.4, -1.4, 0.9, 0.0, 0.1, 0.8, 1.0,
56 -0.1, -0.3, 0.5, -0.1, 0.6, 0.7, -0.7, 0.2, -0.2, -0.5, -1.2, -0.8, 0.2, 1.0, 0.3,
57 -0.1, 0.1, -0.3, -0.1, 0.7, 0.5, -0.2, -0.1, 0.5, 0.4, -0.3, 0.5, -0.5, 0.0, 0.4, 0.4, 0.1,
58 -0.1, -0.2, -0.3, 0.0, 0.2, 0.4, -0.4, -0.3, 0.4, 0.0, 0.1, 0.3, 0.0, 0.0, -0.2, 0.0, 0.5, -0.4, 0.2,
59 0.0, 0.0, 0.0, 0.0, 0.1, 0.2, -0.3, -0.1, 0.1, -0.2, -0.2, 0.0, 0.1, -0.1, 0.0, -0.2, -0.1, -0.1, 0.2, 0.0, 0.0,
60 0.0, -0.1, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.2, -0.1, 0.0, 0.0, 0.0, 0.0, 0.1, -0.1, 0.0, -0.1, -0.1, -0.1, 0.0, -0.1, 0.0,
61 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.1, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.1, -0.1
74 k = nmax1 * (nmax1 + 2);
78 k = nmax2 * (nmax2 + 2);
79 l = nmax1 * (nmax1 + 2);
81 for (ii = k + 1; ii <= l; ++ii) {
87 k = nmax1 * (nmax1 + 2);
88 l = nmax2 * (nmax2 + 2);
90 for (ii = k + 1; ii <= l; ++ii) {
91 gh[ii] = factor *
gh2[ii];
98 for (ii = 1; ii <= k; ++ii) {
99 gh[ii] =
gh1[ii] + factor *
gh2[ii];
106 double *geo_mag_y,
double *geo_mag_z,
int16_t iext,
double ext1,
double ext2,
double ext3)
109 double earths_radius = 6371.2;
110 double dtr = 0.01745329;
114 double aa, bb, cc, dd;
124 #ifdef GEO_MAG_DOUBLE
131 int ii, j, k, l,
m, n;
140 argument = flat * dtr;
141 slat = sinf(argument);
142 if ((90.0 - flat) < 0.001) {
145 if ((90.0 + flat) < 0.001) {
152 clat = cosf(argument);
153 argument = flon * dtr;
154 sl[1] = sinf(argument);
155 cl[1] = cosf(argument);
166 npq = (nmax * (nmax + 3)) / 2;
169 aa = a2 * clat * clat;
170 bb = b2 * slat * slat;
174 argument = elev * (elev + 2.0 * dd) + (a2 * aa + b2 * bb) / cc;
176 cd = (elev + dd) / r;
177 sd = (a2 - b2) / dd * slat * clat / r;
179 slat = slat * cd - clat * sd;
180 clat = clat * cd + aa * sd;
183 ratio = earths_radius / r;
188 p[3] = 4.5 * slat * slat - 1.5;
189 p[4] = 3.0 * aa * clat * slat;
192 q[3] = -3.0 * clat * slat;
193 q[4] = aa * (slat * slat - clat * clat);
195 for (k = 1; k <= npq; ++k) {
201 rr = pow(argument, power);
207 argument = (1.0 - 0.5 / fm);
210 p[k] = (1.0 + 1.0 / fm) * aa * clat * p[j];
211 q[k] = aa * (clat * q[j] + slat / fm * p[j]);
212 sl[
m] = sl[m - 1] * cl[1] + cl[m - 1] * sl[1];
213 cl[
m] = cl[m - 1] * cl[1] - sl[m - 1] * sl[1];
215 argument = fn * fn - fm * fm;
217 argument = ((fn - 1.0) * (fn - 1.0)) - (fm * fm);
218 bb = sqrt(argument) / aa;
219 cc = (2.0 * fn - 1.0) / aa;
222 p[k] = (fn + 1.0) * (cc * slat / fn * p[ii] - bb / (fn - 1.0) * p[j]);
223 q[k] = cc * (slat * q[ii] - clat / fn * p[ii]) - bb * q[j];
230 *geo_mag_x = *geo_mag_x + aa * q[k];
231 *geo_mag_z = *geo_mag_z - aa * p[k];
235 cc = aa * cl[
m] + bb * sl[
m];
236 *geo_mag_x = *geo_mag_x + cc * q[k];
237 *geo_mag_z = *geo_mag_z - cc * p[k];
239 *geo_mag_y = *geo_mag_y + (aa * sl[
m] - bb * cl[
m]) *
240 fm * p[k] / ((fn + 1.0) * clat);
242 *geo_mag_y = *geo_mag_y + (aa * sl[
m] - bb * cl[
m]) * q[k] * slat;
249 aa = ext2 * cl[1] + ext3 * sl[1];
250 *geo_mag_x = *geo_mag_x - ext1 * clat + aa * slat;
251 *geo_mag_y = *geo_mag_y + ext2 * sl[1] - ext3 * cl[1];
252 *geo_mag_z = *geo_mag_z + ext1 * slat + aa * clat;
255 *geo_mag_x = *geo_mag_x * cd + *geo_mag_z * sd;
256 *geo_mag_z = *geo_mag_z * cd - aa * sd;
WMM2020 Geomagnetic field model.
int16_t extrapsh(double date, double dte1, int16_t nmax1, int16_t nmax2, double *gh)
const double gh1[MAXCOEFF]
const double gh2[MAXCOEFF]
int16_t mag_calc(int16_t igdgc, double flat, double flon, double elev, int16_t nmax, double *gh, double *geo_mag_x, double *geo_mag_y, double *geo_mag_z, int16_t iext, double ext1, double ext2, double ext3)