Error with GeoMagneticFieldFactory class

Hi guys,

Another problem is torturing me today.
I am trying to initialize a Geomagnetic field taking advantage of the GeoMagneticFieldFactory class.
In particular I am using the method getIGRF() which requires an decimal year as input.
Using the GeoMagneticField.getDecimalYear() method, I can easily calculate it and give it as input to the getIGRF.
Here the code:
decimal_year = GeoMagneticField.getDecimalYear(5,2,2022)
mag_field = GeoMagneticFieldFactory.getIGRF(decimal_year)

But when I do so, I get an unusual error saying " org.orekit.errors.OrekitException: ^IGRF.COF$ not existing in the classpath"

Does anyone know what does this mean and a workaround for that?

Hi @jordan_93,

You need to download and IGRF.COF coefficients file and put it in your “orekit-data” directory.
See https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html
If you download the Geomag 7.0 software in zip, you’ll find in the zip the file you need.
IGRF13.COF (147.7 KB)
I haven’t tested this version though.

Hope this helps,
Maxime

Definitely the right solution, but I got the same error after putting the .cof into the config\orekit-data.zip\orekit-data-master folder that I have.
Am I doing something wrong?

Have you tried renaming it in “IGRF.COF” ?
Seems from your error that Orekit is trying to find this file by default.

:face_with_peeking_eye:
Ehm…

Thanks :sweat_smile: