1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-195 Update to lasted world mag model : WMM2015

This commit is contained in:
Laurent Lalanne 2015-12-13 12:59:25 +01:00
parent 67b143a73d
commit 108bd8edb4

View File

@ -2,11 +2,12 @@
******************************************************************************
*
* @file WorldMagModel.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Source file for the World Magnetic Model
* This is a port of code available from the US NOAA.
*
* The hard coded coefficients should be valid until 2015.
* The hard coded coefficients should be valid until 2020.
*
* Updated coeffs from ..
* http://www.ngdc.noaa.gov/geomag/WMM/wmm_ddownload.shtml
@ -60,96 +61,96 @@
// first column not used but it will be optimized out by compiler
static const float CoeffFile[91][6] = {
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, -29496.6f, 0.0f, 11.6f, 0.0f },
{ 1.0f, 1.0f, -1586.3f, 4944.4f, 16.5f, -25.9f },
{ 2.0f, 0.0f, -2396.6f, 0.0f, -12.1f, 0.0f },
{ 2.0f, 1.0f, 3026.1f, -2707.7f, -4.4f, -22.5f },
{ 2.0f, 2.0f, 1668.6f, -576.1f, 1.9f, -11.8f },
{ 3.0f, 0.0f, 1340.1f, 0.0f, 0.4f, 0.0f },
{ 3.0f, 1.0f, -2326.2f, -160.2f, -4.1f, 7.3f },
{ 3.0f, 2.0f, 1231.9f, 251.9f, -2.9f, -3.9f },
{ 3.0f, 3.0f, 634.0f, -536.6f, -7.7f, -2.6f },
{ 4.0f, 0.0f, 912.6f, 0.0f, -1.8f, 0.0f },
{ 4.0f, 1.0f, 808.9f, 286.4f, 2.3f, 1.1f },
{ 4.0f, 2.0f, 166.7f, -211.2f, -8.7f, 2.7f },
{ 4.0f, 3.0f, -357.1f, 164.3f, 4.6f, 3.9f },
{ 4.0f, 4.0f, 89.4f, -309.1f, -2.1f, -0.8f },
{ 5.0f, 0.0f, -230.9f, 0.0f, -1.0f, 0.0f },
{ 5.0f, 1.0f, 357.2f, 44.6f, 0.6f, 0.4f },
{ 5.0f, 2.0f, 200.3f, 188.9f, -1.8f, 1.8f },
{ 5.0f, 3.0f, -141.1f, -118.2f, -1.0f, 1.2f },
{ 5.0f, 4.0f, -163.0f, 0.0f, 0.9f, 4.0f },
{ 5.0f, 5.0f, -7.8f, 100.9f, 1.0f, -0.6f },
{ 6.0f, 0.0f, 72.8f, 0.0f, -0.2f, 0.0f },
{ 6.0f, 1.0f, 68.6f, -20.8f, -0.2f, -0.2f },
{ 6.0f, 2.0f, 76.0f, 44.1f, -0.1f, -2.1f },
{ 6.0f, 3.0f, -141.4f, 61.5f, 2.0f, -0.4f },
{ 6.0f, 4.0f, -22.8f, -66.3f, -1.7f, -0.6f },
{ 6.0f, 5.0f, 13.2f, 3.1f, -0.3f, 0.5f },
{ 6.0f, 6.0f, -77.9f, 55.0f, 1.7f, 0.9f },
{ 7.0f, 0.0f, 80.5f, 0.0f, 0.1f, 0.0f },
{ 7.0f, 1.0f, -75.1f, -57.9f, -0.1f, 0.7f },
{ 7.0f, 2.0f, -4.7f, -21.1f, -0.6f, 0.3f },
{ 7.0f, 3.0f, 45.3f, 6.5f, 1.3f, -0.1f },
{ 7.0f, 4.0f, 13.9f, 24.9f, 0.4f, -0.1f },
{ 7.0f, 5.0f, 10.4f, 7.0f, 0.3f, -0.8f },
{ 7.0f, 6.0f, 1.7f, -27.7f, -0.7f, -0.3f },
{ 7.0f, 7.0f, 4.9f, -3.3f, 0.6f, 0.3f },
{ 8.0f, 0.0f, 24.4f, 0.0f, -0.1f, 0.0f },
{ 8.0f, 1.0f, 8.1f, 11.0f, 0.1f, -0.1f },
{ 8.0f, 2.0f, -14.5f, -20.0f, -0.6f, 0.2f },
{ 8.0f, 3.0f, -5.6f, 11.9f, 0.2f, 0.4f },
{ 8.0f, 4.0f, -19.3f, -17.4f, -0.2f, 0.4f },
{ 8.0f, 5.0f, 11.5f, 16.7f, 0.3f, 0.1f },
{ 8.0f, 6.0f, 10.9f, 7.0f, 0.3f, -0.1f },
{ 8.0f, 7.0f, -14.1f, -10.8f, -0.6f, 0.4f },
{ 8.0f, 8.0f, -3.7f, 1.7f, 0.2f, 0.3f },
{ 1.0f, 0.0f, -29438.5f, 0.0f, 10.7f, 0.0f },
{ 1.0f, 1.0f, -1501.1f, 4796.2f, 17.9f, -26.8f },
{ 2.0f, 0.0f, -2445.3f, 0.0f, -8.6f, 0.0f },
{ 2.0f, 1.0f, 3012.5f, -2845.6f, -3.3f, -27.1f },
{ 2.0f, 2.0f, 1676.6f, -642.0f, 2.4f, -13.3f },
{ 3.0f, 0.0f, 1351.1f, 0.0f, 3.1f, 0.0f },
{ 3.0f, 1.0f, -2352.3f, -115.3f, -6.2f, 8.4f },
{ 3.0f, 2.0f, 1225.6f, 245.0f, -0.4f, -0.4f },
{ 3.0f, 3.0f, 581.9f, -538.3f, -10.4f, 2.3f },
{ 4.0f, 0.0f, 907.2f, 0.0f, -0.4f, 0.0f },
{ 4.0f, 1.0f, 813.7f, 283.4f, 0.8f, -0.6f },
{ 4.0f, 2.0f, 120.3f, -188.6f, -9.2f, 5.3f },
{ 4.0f, 3.0f, -335.0f, 180.9f, 4.0f, 3.0f },
{ 4.0f, 4.0f, 70.3f, -329.5f, -4.2f, -5.3f },
{ 5.0f, 0.0f, -232.6f, 0.0f, -0.2f, 0.0f },
{ 5.0f, 1.0f, 360.1f, 47.4f, 0.1f, 0.4f },
{ 5.0f, 2.0f, 192.4f, 196.9f, -1.4f, 1.6f },
{ 5.0f, 3.0f, -141.0f, -119.4f, 0.0f, -1.1f },
{ 5.0f, 4.0f, -157.4f, 16.1f, 1.3f, 3.3f },
{ 5.0f, 5.0f, 4.3f, 100.1f, 3.8f, 0.1f },
{ 6.0f, 0.0f, 69.5f, 0.0f, -0.5f, 0.0f },
{ 6.0f, 1.0f, 67.4f, -20.7f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 0.0f, 0.0f },
{ 12.0f, 8.0f, -0.4f, 0.3f, 0.0f, 0.0f },
{ 12.0f, 9.0f, -0.4f, 0.2f, 0.0f, 0.0f },
{ 12.0f, 10.0f, 0.2f, -0.9f, 0.0f, 0.0f },
{ 12.0f, 11.0f, -0.8f, -0.2f, -0.1f, 0.0f },
{ 12.0f, 12.0f, 0.0f, 0.9f, 0.1f, 0.0f }
{ 12.0f, 11.0f, -0.9f, -0.2f, 0.0f, 0.0f },
{ 12.0f, 12.0f, 0.0f, 0.7f, 0.0f, 0.0f }
};
static WMMtype_Ellipsoid *Ellip = NULL;
@ -190,10 +191,10 @@ int WMM_Initialize()
MagneticModel->nMaxSecVar = WMM_MAX_SECULAR_VARIATION_MODEL_DEGREES;
MagneticModel->SecularVariationUsed = 0;
// Really, Really needs to be read from a file - out of date in 2015 at latest
// Really, Really needs to be read from a file - out of date in 2020 at latest
MagneticModel->EditionDate = 0.0f; /* OP change. Originally 5.7863328170559505e-307, truncates to 0.0f */
MagneticModel->epoch = 2010.0f;
sprintf(MagneticModel->ModelName, "WMM-2010");
MagneticModel->epoch = 2015.0f;
sprintf(MagneticModel->ModelName, "WMM-2015");
return 0; // OK
}