Issue with IGRF model

Hello everyone,

I’m having a problem trying to read the IGRF magnetic model. I downloaded the file from here and put it in my orekit-data folder.
When trying to read the file I get this error though:

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 12
        at org.orekit.models.earth.GeoMagneticField.getDecimalYear(GeoMagneticField.java:327)
        at org.orekit.models.earth.GeoMagneticModelLoader.readOriginalWMMFormat(GeoMagneticModelLoader.java:239)
        at org.orekit.models.earth.GeoMagneticModelLoader.readModel(GeoMagneticModelLoader.java:136)
        at org.orekit.models.earth.GeoMagneticModelLoader.loadData(GeoMagneticModelLoader.java:111)
        at org.orekit.data.DataProvidersManager$MonitoringWrapper.loadData(DataProvidersManager.java:354)
        at org.orekit.data.DirectoryCrawler.feed(DirectoryCrawler.java:127)
        at org.orekit.data.DirectoryCrawler.feed(DirectoryCrawler.java:73)
        at org.orekit.data.DataProvidersManager.feed(DataProvidersManager.java:312)
        at org.orekit.models.earth.LazyLoadedGeoMagneticFields.loadModels(LazyLoadedGeoMagneticFields.java:101)
        at org.orekit.models.earth.LazyLoadedGeoMagneticFields.getIGRF(LazyLoadedGeoMagneticFields.java:75)
        at org.orekit.models.earth.GeoMagneticFieldFactory.getIGRF(GeoMagneticFieldFactory.java:82)

Is the file not the correct one?

In which folder did you place it within orekit-data?

I think it should be .gcf file extension.

To make sure which files were loaded, use this in your code:

DataContext.getDefault().getDataProvidersManager().getLoadedDataNames().forEach(System.out::println);    
        } catch (Exception e) {
            e.printStackTrace();
        }

I put it in the main orekit-data folder, named IGRF.COF

This is the error I get if I change its name:

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: unable to find resource ^IGRF\.COF$ in classpath
        at org.orekit.models.earth.LazyLoadedGeoMagneticFields.loadModels(LazyLoadedGeoMagneticFields.java:117)
        at org.orekit.models.earth.LazyLoadedGeoMagneticFields.getIGRF(LazyLoadedGeoMagneticFields.java:75)
        at org.orekit.models.earth.GeoMagneticFieldFactory.getIGRF(GeoMagneticFieldFactory.java:82)

I think the location and name I set are correct.

Ok. So, in my folder I have a file with extension .conf, instead of .cof. Could be it.

Also, my itrf-versions.conf is within EarthOrientationParametrs. Maybe you try these changes? Other than that, I guess I can’t help further :confused:

It is not a .COF format, which is described here: WMM format

You should perhaps open an issue so we parse this format too.

2 Likes

The file I’m referring to is for the magnetic field, not the gravity field. I doubt it should be in the folder for the EOP :sweat_smile:

Also, I added the WMM model in the same location and it is read just fine :slight_smile:

1 Like

Ok, I’ll open the issue.

But then if I want to read the IGRF model, which file should I download? This was the only one I could find

Maybe here: wmm-coefficients.

But isn’t that for the WMM model? Does that mean that at the moment there is no way of reading the IGRF?
If that’s the case it’s not a big deal, I can use the WMM, I just want to understand :slight_smile:

The model can be found here International Geomagnetic Reference Field (IGRF). Look for the IGRF14.COF file under Data, Programs and Software. Copy it to you orekit folder and rename it to IGRF.COF. That did it for me

1 Like

Also note that with the development version of Orekit (which will soon become the official 13.0 release), you can parse the file directly using a DataSource. You could still put it in the orekit foilder as before, but it will not be a requirement anymore (see issue 1658).

1 Like

Thanks! That worked like a charm :slight_smile:

Hi,

I see that there’s no link to magnetic fields data files in the page Supported Data Types of the technical documentation.
Maybe it would be worth it to add both of your links: @luc’s for WMM and @BS_space’s for IGRF.
What do you think?

Cheers,
Maxime

2 Likes

Don’t you want to add WMM.COF and IGRF.COF to default set of data files? (Orekit / Orekit Data · GitLab)

Now that issue 1658 is done, I am not sure orekit-data is a good place for this. Data there is almost forgotten because it is “too easy” to get and at the end we don’t know which data we used.

But this is only my own feeling, I guess we could put it in the convenience repository we set up, otr simply suggest people to just put the file in their own folder, after all orekit-data is something users are expected to manage.

1 Like