JavaStackTrace Error when calling WMM Model

Hi all!

I have a basic CSV file that contains PV information. For each PV entry, I am converting it to LLA and then calling the WMM model to generate the Magnetic Field Value. As a result, I call the model in a for loop, but that throws an error. I writing this code on Linux Ubuntu using Orekit Python package.

The snippet of my code is below:

elif LLAFlag == False:
    for index,sample in tm.iterrows():
        t = Time(pd.to_datetime(sample['SatelitePosition_Meas_UnixTime'],unit='s'))
        time = t.get_absolutedate()
        posx = sample['SatelitePosition_Meas_ro_m_0']
        posy = sample['SatelitePosition_Meas_ro_m_1']
        posz = sample['SatelitePosition_Meas_ro_m_2']
        position = utils.list_to_vector3d([posx,posy,posz])
        gp = earth.transform(position,earth.getBodyFrame(),time)
        lat_rad = float(gp.getLatitude())
        long_rad = float(gp.getLongitude())
        alt_m = float(gp.getAltitude())
        igrf = model.calculateField(lat_rad,long_rad,alt_m)
        igrf = igrf.getFieldVector()

But I get a JavaStack Trace Error saying:

JavaError                                 Traceback (most recent call last)
/tmp/ipykernel_53959/ in <module>
      2 sunpv = []
      3 igrfyear = GeoMagneticField.getDecimalYear(1,4,2024)
----> 4 model = GeoMagneticFieldFactory.getWMM(igrfyear)
      5 fr_gcrf = frames.get_earth_GCRF()
      6 earth = OneAxisEllipsoid(C.EARTH_RADIUS,C.EARTH_FLATTENING,frames.get_earth_GCRF())

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: unable to find resource ^WMM\.COF$ in classpath

Any suggestions on how to circumvent the issue? Thanks!

Hi @suraj-pixxel,

Welcome to the community !!

You need to put a WMM.cof file in your orekit-data folder so that the model can read the geomagnetic coefficients and compute the magnetic field.
I have this one in my orekit-data folder, though I cannot tell you if it’s the latest:
WMM.COF (4.5 KB)

After a quick search, WMM coefficients are available here.
The latest is the same as the one I uploaded above…

It appears the Geomagnetic field files are not listed in the Supported Data Types page of the documentation.
Could you please open an issue on the forge about this?