Gravity Potential model in ICGEMF format

Hello,

I’m new with Orekit and with Java in general so I’m encountering some difficulties. Basically, I want to load the .gfc file and extract the relevant parameters (i.e earth_gravity_constant, radius, max_degree, L, M, C and S). This is what i reached so far without encounting errors:

% Java add path

javaaddpath ‘/path/MATLAB’
javaaddpath ‘/path/MATLAB/Libraries/orekit-13.0.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-clustering-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-core-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-fft-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-filtering-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-fitting-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-geometry-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-ode-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-optim-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-samples-4.0.2.jar’
javaaddpath ‘/path/MATLAB/Libraries/hipparchus-4.0.2-bin/hipparchus-stat-4.0.2.jar’
% Import Orekit

import org.orekit.data.*
import org.orekit.forces.gravity.*
import org.orekit.time.*

% Initialize

DM = org.orekit.data.DataContext.getDefault().getDataProvidersManager()
dataDir = java.io.File(‘/path/Desktop/orekit-data-main/’);
crawler = org.orekit.data.DirectoryCrawler(dataDir);
DM.clearProviders()
DM.addProvider(crawler)

% Attempt
reader = org.orekit.forces.gravity.potential.ICGEMFormatReader(‘/path/Desktop/orekit-data-main/Potential/GOCO05s.gfc’, true);

Now i would like to understand how to proceed.

I really hope you can help me :slight_smile:

Hi @Salvo,

Welcome to the forum!

If your gfc file is the only one in your “orekit-data” folder then it’s automatically loaded and read when calling (Java version sorry):

UnnormalizedSphericalHarmonicsProvider gravity = GravityFieldFactory.getUnnormalizedProvider(n,m);

From there you’ll get Ae, mu, degree, order with getAe(), getMu etc.

Then if you call method onDate(date) you’ll have access to the Cnm and Snm.
Example for C30 and S33 with J2000:

UnnormalizedSphericalHarmonics harmonics = gravity.onDate(AbsoluteDate.J2000_EPOCH);
double C30 = harmonics.getUnnormalizedCnm(3, 0);
double S30 = harmonics.getUnnormalizedSnm(3, 3);

Hope this helps,
Maxime