Heya,
I’m getting my head around the OCM writer and I’ve tripped up at the Perturbations block. The number that gets written is much bigger than I expected for the F10.7 and the Geomag AP. I feed the set functions with normal values but what gets written is several orders of magnitude too big. This is using the orekit_jpype wrapper. See minimal example below. The output given is:
CCSDS_OCM_VERS = 3.0
CREATION_DATE = 2024-12-11T13:56:26.011104
ORIGINATOR = TEST
META_START
OBJECT_DESIGNATOR = Test Satellite
TIME_SYSTEM = UTC
EPOCH_TZERO = 2024-12-11T13:56:26.011104
OCM_DATA_ELEMENTS = PERT
START_TIME = 0.0
STOP_TIME = 2024-12-11T13:58:06.011103
META_STOP
PERT_START
ATMOSPHERIC_MODEL = NRLMSIS00
GRAVITY_MODEL = EGM-96: 8D 8O
N_BODY_PERTURBATIONS = MOON,SUN
ALBEDO_GRID_SIZE = 0
SHADOW_BODIES = EARTH
FIXED_GEOMAG_AP = 1.1199999999999998E10[nT]
FIXED_F10P7 = 1.5299999999999999E24[SFU]
FIXED_F10P7_MEAN = 1.5299999999999999E24[SFU]
PERT_STOP
I feel like I’ve done something daft but I can’t think what! Any help much appreciated.
import orekit_jpype as orekit
vm = orekit.initVM()
from orekit_jpype.pyhelpers import (
setup_orekit_curdir,
absolutedate_to_datetime,
)
from org.orekit.propagation.analytical.tle import TLE, TLEPropagator
from org.orekit.files.ccsds.section import Segment
from org.orekit.files.ccsds.ndm.odm import OdmHeader
from org.orekit.files.ccsds.ndm.odm.ocm import (
OcmWriter,
OcmMetadata,
OcmElements,
Ocm,
OcmData,
Perturbations,
)
from org.orekit.utils import (
Constants,
IERSConventions,
)
from org.orekit.data import DataContext
from org.orekit.files.ccsds.utils.generation import (
KvnGenerator,
XmlGenerator,
)
from org.orekit.files.ccsds.definitions import (
TimeSystem,
BodyFacade,
)
from org.orekit.bodies import (
CelestialBodyFactory,
LazyLoadedCelestialBodies,
)
from org.orekit.time import LazyLoadedTimeScales
from org.orekit.frames import LazyLoadedEop, FramesFactory
from java.util import ArrayList
from java.lang import StringBuffer
from pathlib import Path
if __name__ == "__main__":
setup_orekit_curdir(str(Path.cwd() / "orekit-data"))
# -------- Getting data ---------------------------------------------------
line1 = (
"1 25544U 98067A 24346.58085661 .00019796 00000+0 34772-3 0 9995"
)
line2 = (
"2 25544 51.6389 156.5072 0007053 328.6631 66.3051 15.50486876486069"
)
tle = TLE(line1, line2)
print("Starting TLE:")
print(tle.toString())
propagator = TLEPropagator.selectExtrapolator(tle)
epoch = tle.getDate()
end_date = absolutedate_to_datetime(epoch.shiftedBy(100.0))
step = 100.0
cur_date = epoch
pvcoordinates = []
dates = []
while absolutedate_to_datetime(cur_date) < end_date:
pvcoordinates.append(propagator.getPVCoordinates(cur_date))
dates.append(cur_date)
cur_date = cur_date.shiftedBy(step)
version = 3.0
header = OdmHeader()
header.setCreationDate(epoch)
header.setOriginator("TEST")
DM = DataContext.getDefault()
ocmwriter = OcmWriter(
IERSConventions.IERS_2010,
Constants.EGM96_EARTH_EQUATORIAL_RADIUS,
Constants.EGM96_EARTH_C20,
DM,
)
metadata = OcmMetadata(DM)
metadata.setStartTime(epoch)
metadata.setEpochT0(epoch)
metadata.setStopTime(epoch.shiftedBy(100.0))
metadata.setTimeSystem(TimeSystem.UTC)
metadata.setObjectDesignator("Test Satellite")
metadata.setOcmDataElements(
ArrayList(
[
OcmElements.PERT,
]
)
)
metadata.validate(version)
# Perturbations Block -----------------------------------------------------
perturbations = Perturbations(
LazyLoadedCelestialBodies(
DM.getDataProvidersManager(),
LazyLoadedTimeScales(LazyLoadedEop(DM.getDataProvidersManager())),
FramesFactory.getGCRF(),
)
)
perturbations.setAtmosphericModel("NRLMSIS00")
perturbations.setFixedGeomagneticAp(11.2)
perturbations.setFixedF10P7(153.0)
perturbations.setFixedF10P7Mean(153.0)
perturbations.setGravityModel("EGM-96", 8, 8)
perturbations.setNBodyPerturbations(
ArrayList(
[
BodyFacade("MOON", CelestialBodyFactory.getMoon()),
BodyFacade("SUN", CelestialBodyFactory.getSun()),
]
)
)
perturbations.setShadowBodies(
ArrayList(
[
BodyFacade("EARTH", CelestialBodyFactory.getEarth()),
]
)
)
perturbations.validate(version)
# Perturbations Block -----------------------------------------------------
ocmdata = OcmData(None, None, None, None, perturbations, None, None)
ocm = Ocm(
header,
ArrayList([Segment(metadata, ocmdata)]),
IERSConventions.IERS_2010,
DM,
Constants.EGM96_EARTH_MU,
)
ocm.validate()
test = StringBuffer()
# generator = XmlGenerator(test, 4, "test.txt", 0.0, True, None)
generator = KvnGenerator(test, 4, "test.txt", 0.0, True)
out = ocmwriter.writeMessage(generator, ocm)
print(test)