View Source Astrex.Astro.GeoMag (Astrex v0.4.0)
Calculates the Earth Magnetic field basing on local coordinates and (optionally) altitude. The calculations model is the WMM (World Magnetic Model).
More information available here:
https://www.ngdc.noaa.gov/geomag/WMM/
The datafile WMM.COF
https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2020/WMM2020COF.zip
is valid until 2025 and will be replaced when the next one will be released
Calculations results have been compared to the results of this calculator's
https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#declination
and the prove accurate with an error margin of about 1/100° likely due to floating point roundings
This code has been directly ported from a python implementation available at
https://github.com/cmweiss/geomag/blob/master/geomag/geomag/geomag.py
Link to this section Summary
Functions
Requires latitude and longitude expressed in decimal degrees (not deg, min, sec)
Link to this section Functions
Requires latitude and longitude expressed in decimal degrees (not deg, min, sec)
- Latitude: between 0° and 90° -- southern latitudes are negative
- Longitude: between 0° and +/- 180° -- western longitudes are negative
- Altitude: in km above sea level - optional parameter, default is 0
returns
Returns
dec: magnetic declination
dip: magnetic inclination
ti: total intensity
epoch: Epoch of the current datafile
examples
Examples
iex> Astrex.Astro.GeoMag.mag_declination(%{lat: 45.5, long: 9.15})
{3.3219734037666426, 61.709940202847136, 47715.72107126719, "2020.0"}