This tutorial shows how to use the Geomagnetic Field Model.
Orekit provides an easy to use class for calculating the geomagnetic field of the earth. Currently there is support for two different models:
A geomagnetic field model relies on published coefficients files that are loaded on demand. There exist different formats for these files, but orekit uses a modified version, which may contain coefficients from multiple epochs inside one file.
The format of the expected model file is as follows:
{model name} {epoch} {nMax} {nMaxSec} {nMax3} {validity start} {validity end} {minAlt} {maxAlt} {model name} {line number} {n} {m} {gnm} {hnm} {dgnm} {dhnm} {model name} {line number}
Example:
WMM2010 2010.00 12 12 0 2010.00 2015.00 -1.0 600.0 WMM2010 0 1 0 -29496.6 0.0 11.6 0.0 WMM2010 1 1 1 -1586.3 4944.4 16.5 -25.9 WMM2010 2
The latest coefficient files for IGRF and WMM can be found in attachment.
To calculate the geomagnetic field of a specified geodetic location and altitude is pretty much straight-forward.
First retrieve the geomagnetic field model for a desired year (e.g. WMM):
GeoMagneticField model = GeoMagneticFieldFactory.getWMM(2012.0);
The year has to be specified as a decimal year, which can be converted from a julian date like this:
double year = GeoMagneticField.getDecimalYear(1, 6, 2012);
Finally we can calculate the magnetic field at a geodetic location (lat/lon in deg) and altitude (in km):
GeoMagneticElements result = model.calculateField(80.0, 0.0, 100.0);
The result contains the seven magnetic components: