dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
WorldMagModel.c File Reference

Source file for the World Magnetic Model This is a port of code available from the US NOAA. More...

#include "openpilot.h"
#include "physical_constants.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include "WorldMagModel.h"
#include "WMMInternal.h"

Go to the source code of this file.

Functions

int WMM_Initialize ()
 
int WMM_GetMagVector (float Lat, float Lon, float AltEllipsoid, uint16_t Month, uint16_t Day, uint16_t Year, float B[3])
 
int WMM_Geomag (WMMtype_CoordSpherical *CoordSpherical, WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_GeoMagneticElements *GeoMagneticElements)
 
int WMM_ComputeSphericalHarmonicVariables (WMMtype_CoordSpherical *CoordSpherical, uint16_t nMax, WMMtype_SphericalHarmonicVariables *SphVariables)
 
int WMM_AssociatedLegendreFunction (WMMtype_CoordSpherical *CoordSpherical, uint16_t nMax, WMMtype_LegendreFunction *LegendreFunction)
 
int WMM_Summation (WMMtype_LegendreFunction *LegendreFunction, WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
 
int WMM_SecVarSummation (WMMtype_LegendreFunction *LegendreFunction, WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
 
int WMM_RotateMagneticVector (WMMtype_CoordSpherical *, WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_MagneticResults *MagneticResultsSph, WMMtype_MagneticResults *MagneticResultsGeo)
 
int WMM_CalculateGeoMagneticElements (WMMtype_MagneticResults *MagneticResultsGeo, WMMtype_GeoMagneticElements *GeoMagneticElements)
 
int WMM_CalculateSecularVariation (WMMtype_MagneticResults *MagneticVariation, WMMtype_GeoMagneticElements *MagneticElements)
 
int WMM_PcupHigh (float *Pcup, float *dPcup, float x, uint16_t nMax)
 
int WMM_PcupLow (float *Pcup, float *dPcup, float x, uint16_t nMax)
 
int WMM_SummationSpecial (WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
 
int WMM_SecVarSummationSpecial (WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
 
float WMM_get_main_field_coeff_g (uint16_t index)
 Comput the MainFieldCoeffH accounting for the date. More...
 
float WMM_get_main_field_coeff_h (uint16_t index)
 
float WMM_get_secular_var_coeff_g (uint16_t index)
 
float WMM_get_secular_var_coeff_h (uint16_t index)
 
int WMM_DateToYear (uint16_t month, uint16_t day, uint16_t year)
 
int WMM_GeodeticToSpherical (WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_CoordSpherical *CoordSpherical)
 

Variables

static const float CoeffFile [91][6] = COEFFS_FROM_NASA
 
static WMMtype_Ellipsoid Ellip
 
static WMMtype_MagneticModel MagneticModel
 
static float decimal_date
 

Detailed Description

Source file for the World Magnetic Model This is a port of code available from the US NOAA.

Author
The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
Tau Labs, http://taulabs.org, Copyright (C) 2013-2014
dRonin, http://dronin.org Copyright (C) 2015 The hard coded coefficients should be valid until 2020.

Updated coeffs from .. http://www.ngdc.noaa.gov/geomag/WMM/wmm_ddownload.shtml

NASA C source code .. http://www.ngdc.noaa.gov/geomag/WMM/wmm_wdownload.shtml

Major changes include:

  • No geoid model (altitude must be geodetic WGS-84)
  • Floating point calculation (not double precision)
  • Hard coded coefficients for model
  • Elimination of user interface
  • Elimination of dynamic memory allocation
See Also
The GNU Public License (GPL) Version 3

Definition in file WorldMagModel.c.