Adding Action/Events to a Propagator

We will perform a propagation in a number of different ways, first using the trajectory and then using the BallisticPropagator and finally the standard Propagator.

We will show how to use events with triggers and actions to perform user defined actions on the propagation.

First perform all necessary imports

In [1]:
from godot import cosmos
from godot.model import prop
from godot.model import common
from godot.model import interface
from godot.model import geometry
from godot.core.autodif import bridge as br
from godot.core import autodif as ad
from godot.core import tempo, util, constants, integ
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline


# avoid verbose output
util.suppressLogger()

next load the universe.

In [2]:
uni_config = cosmos.util.load_yaml('universe.yml')
uni = cosmos.Universe(uni_config)

Note that in the universe configuration the dynamics model named SunEarthMarsDynamics is of type Combined. Only Combined dynamics models can have more dynamics models added to them:

Now load the trajectory configuration and create the trajectory object using the universe object

In [3]:
tra_config = cosmos.util.load_yaml('trajectory.yml')
tra = cosmos.Trajectory(uni, tra_config)

Now we plot the trajectory

In [4]:
def plot(points):
    ran = tempo.EpochRange(tempo.Epoch("2020-01-01 TDB"),
                           tempo.Epoch("2022-01-01 TDB"))
    earth = np.asarray([uni.frames.vector3('Sun', 'Earth', 'EMC', e) /
                       constants.AU for e in ran.createGrid(1.0 * tempo.SecondsInDay)])
    mars = np.asarray([uni.frames.vector3('Sun', 'Mars', 'EMC', e) /
                      constants.AU for e in ran.createGrid(1.0 * tempo.SecondsInDay)])

    def pos(e,point):
        try:
            return uni.frames.vector3('Sun', point, 'EMC', e)
        except:
            return [np.nan] * 3

    plt.figure(figsize=(8, 8))


    grid = tra.range().createGrid(0.01 * tempo.SecondsInDay)
    t = [e.mjd() for e in grid]
    for point in points:
        x = np.asarray([pos(e, point) for e in grid])/constants.AU
        plt.plot(x[:, 0], x[:, 1], '-', linewidth=2, label=point)
        plt.plot(x[0, 0], x[0, 1], 'o')
        plt.plot(x[-1, 0], x[-1, 1], 'o')

    plt.xlabel('EMC X (AU)')
    plt.ylabel('EMC Y (AU)')
    plt.plot(earth[:, 0], earth[:, 1], '--', label="Earth")
    plt.plot(mars[:, 0], mars[:, 1], '--', label="Mars")
    plt.xlim([-2, 2])
    plt.ylim([-2, 2])
    plt.legend()
    plt.grid()

    if len(points) > 1:
        plt.figure(figsize=(8, 4))
        ref = points[0]
        for point in points[1:]:
            x = np.asarray([np.linalg.norm(pos(e, point)-pos(e,ref)) for e in grid])
            plt.plot(t, x, '-', linewidth=2, label=f"|{point}-{ref}|")
        plt.legend()
        plt.grid()

tra.compute(False)
plot(['SC_center'])

Ballistic Propagator

We create a cosmos.BallisticPropagator to propagate the spacecraft again with the same dynamic model. The difference with the trajectory is that in this case only the state is propagated and in the trajectory, state mass and deltav ar propagated.

We can create a simple action to print the epoch of the trigger time, but with this propagator no action can be taken to adjust the state.

The difference in the propagator is

In [5]:
epoch0 = tempo.Epoch("9750.0 TDB")
epoch1 = tempo.Epoch("9755.0 TDB")

# create the BallisticPropagator
pro = cosmos.BallisticPropagator(
    uni, 'SC', 'SunEarthMarsDynamics', epoch0, 'Earth', 1e-12)

# Action to print output only
class ExampleAction(interface.EventAction):
    def __init__(self):
        # We have to call C++ trampoline class constructor explicitly
        interface.EventAction.__init__(self)
        # Assign member variables
    def eval(self, epoch, crossDir, integDir):
        def actionFunc(): return integ.Action.Continue
        print(f"epoch={epoch}")
        return interface.create_action(epoch, actionFunc, dict())
action = ExampleAction()

# create the trigger
trigger = common.SimpleFixedEventTrigger(
    [tempo.Epoch("9751 TDB"), tempo.Epoch("9752 TDB")])

# create the event and add it to the propagator
event = common.SimpleEvent(trigger, action)
pro.addEvent(event)

# propagate state from trajectory initial state
x0 = uni.frames.vector6('Earth', 'SC_center', 'ICRF', epoch0)
pro.compute(x0, 0, epoch1)
# plot results
plot(['SC_center','SC'])
epoch=2026-09-12T00:00:00.000000 TDB
epoch=2026-09-13T00:00:00.000000 TDB

Propagator

Lets now add a spacecraft propagator to the universe. This time we will use a different dynamic model for the propagation and compare the results.

First get variables for the points we need and create a point for the propagator to use:

In [6]:
# Get frames object and variables for points to use
fra = uni.frames
icrf = fra.axesId('ICRF')
earth = fra.pointId('Earth')

# Create point for spacecraft
try:
    scPoint = fra.addPoint('Spacecraft', tempo.TimeScale.TDB)
except:
    scPoint = fra.pointId('Spacecraft')

Now we create a propagator

In [7]:
propPoint = prop.PropagatorPoint(fra, icrf, scPoint)

And define the dynamics (GravityOnly, so without SRP). We need to set some aliases to use the dynamics with the newly created spacecraft point:

In [8]:
dyn = uni.dynamics.get("GravityOnly")
fra.setAlias(dyn.point, scPoint)
fra.setAlias(dyn.coi, earth)
fra.setAlias(dyn.axes, icrf)
for key, alias in dyn.inputs.items():
    alias.set(uni.parameters.get("{}_{}".format("Spacecraft", key)))

Now we create a propagator and propagate and plot the difference with the propagation with SRP.

In [9]:
# We create a time evaluable to get the initial state from the SC_center already propagated
x0 = geometry.Vector6(fra, 'Earth', 'SC_center', 'ICRF')
# Define error tolerance
tol = np.full(6, 1e-12)
# Setup inputs for propagator
inp = [prop.PointInput(propPoint, earth, x0, dyn.acc, tol, tol)]
# create a propagator
pro = prop.Propagator('Prop', epoch0, None, inp)
# Propagate without partials
pro.compute(epoch1, False)
# Output final state and spacecraft X axis direction
plot(['SC_center','Spacecraft'])

This shows the effect of SRP on the propagation. Suppose we want to correct the state of the spacecraft to account for the SRP, using the trajectory reference as a guide. We do this by adding events to the propagator, correcting the Spacecraft state to match the SC_center values.

We define our correction action:

In [10]:
class CorrectionAction(interface.EventAction):

    def __init__(self, propPoint):
        # We have to call C++ trampoline class constructor explicitly
        interface.EventAction.__init__(self)
        # Assign member variables
        self.__propPoint = propPoint

    def eval(self, e, crossDir, integDir):
        """Correct the state back to the SC_center value

        Parameters
        ----------
        e : tempo.Epoch
            The epoch
        crossDir : [type]
            Cross direction as defined by the event 
        integDir : [type]
            Integration direction

        Returns
        -------
        [type]
            [description]
        """
        delta = uni.frames.vector6('Spacecraft', 'SC_center', 'ICRF', e) 
        print(f"adding correction at {e}={delta}")
        def actionFunc(): return integ.Action.Continue
        deltaState = dict()
        deltaState[self.__propPoint] = delta
        return interface.create_action(e, actionFunc, deltaState)

We add the event with a simple trigger occurring every hour to our existing propagator:

In [11]:
action = CorrectionAction(propPoint)
trigger = common.SimpleFixedEventTrigger(tempo.EpochRange(epoch0,epoch1).createGrid(3600))
event = common.SimpleEvent(trigger, action)
pro.addEvent(event)

Finally we can re-propagate:

In [12]:
# Propagate without partials
pro.compute(epoch1, False)

# Output final state and spacecraft X axis direction
plot(['SC_center','Spacecraft'])
adding correction at 2026-09-11T00:00:00.000000 TDB=[0. 0. 0. 0. 0. 0.]
adding correction at 2026-09-11T01:00:00.000000 TDB=[ 1.43223828e-04 -1.82015792e-05 -7.81385825e-06  8.83545543e-08
 -9.51940748e-09 -3.54899088e-09]
adding correction at 2026-09-11T02:00:00.000000 TDB=[ 1.71496908e-04 -4.03152590e-05 -1.60322743e-05  8.82637916e-08
 -2.02469241e-08 -8.76726891e-09]
adding correction at 2026-09-11T03:00:00.000000 TDB=[ 1.60132666e-04 -2.50208832e-05 -1.11227782e-05  8.99986146e-08
 -1.61494778e-08 -6.96264313e-09]
adding correction at 2026-09-11T04:00:00.000000 TDB=[ 1.66906961e-04 -2.67452342e-05 -1.10939036e-05  8.92756409e-08
 -1.78254314e-08 -7.74542452e-09]
adding correction at 2026-09-11T05:00:00.000000 TDB=[ 1.65833655e-04 -2.44715047e-05 -1.02948179e-05  8.96378649e-08
 -1.73573751e-08 -7.52305773e-09]
adding correction at 2026-09-11T06:00:00.000000 TDB=[ 9.46182336e-05 -6.02482760e-05 -3.27869930e-05  9.08787008e-08
 -1.18293544e-08 -5.13662202e-09]
adding correction at 2026-09-11T07:00:00.000000 TDB=[ 2.28538760e-04 -9.61804471e-06  2.71276076e-06  8.86656130e-08
 -2.24956267e-08 -9.73259229e-09]
adding correction at 2026-09-11T08:00:00.000000 TDB=[ 1.48229701e-04 -3.50988703e-05 -1.65898236e-05  9.02945303e-08
 -1.57588729e-08 -6.80758205e-09]
adding correction at 2026-09-11T09:00:00.000000 TDB=[ 1.80714575e-04 -1.64912635e-05 -5.39955363e-06  8.92376038e-08
 -1.85686764e-08 -8.07129297e-09]
adding correction at 2026-09-11T10:00:00.000000 TDB=[ 9.67695596e-05 -7.45895377e-05 -3.84021550e-05  9.06005132e-08
 -1.31989286e-08 -5.73229175e-09]
adding correction at 2026-09-11T11:00:00.000000 TDB=[ 2.07450961e-04 -3.83681618e-06  2.72587931e-06  8.94830584e-08
 -1.93285130e-08 -8.35517278e-09]
adding correction at 2026-09-11T12:00:00.000000 TDB=[ 1.71312808e-04 -2.23522948e-05 -8.83442408e-06  8.95139127e-08
 -1.79246546e-08 -7.78002640e-09]
adding correction at 2026-09-11T13:00:00.000000 TDB=[ 1.49867774e-04 -3.66125896e-05 -1.70292915e-05  9.03382846e-08
 -1.54846505e-08 -6.69448341e-09]
adding correction at 2026-09-11T14:00:00.000000 TDB=[ 1.65435835e-04 -2.69908342e-05 -1.13777933e-05  8.97677004e-08
 -1.70220380e-08 -7.38467087e-09]
adding correction at 2026-09-11T15:00:00.000000 TDB=[ 1.93679894e-04  2.66340794e-06  3.84547457e-06  8.94713826e-08
 -1.82722473e-08 -7.92724708e-09]
adding correction at 2026-09-11T16:00:00.000000 TDB=[ 4.82040487e-05 -1.41781347e-04 -7.11894245e-05  9.07270039e-08
 -1.24701032e-08 -5.42375189e-09]
adding correction at 2026-09-11T17:00:00.000000 TDB=[ 2.58073924e-04  6.45322725e-05  3.62167775e-05  8.94430916e-08
 -1.95306571e-08 -8.44347725e-09]
adding correction at 2026-09-11T18:00:00.000000 TDB=[ 1.45504775e-04 -4.76814748e-05 -2.20266666e-05  9.01556919e-08
 -1.59107421e-08 -6.88949520e-09]
adding correction at 2026-09-11T19:00:00.000000 TDB=[ 1.98263806e-04  1.31514680e-05  8.62999877e-06  8.95956405e-08
 -1.78215158e-08 -7.73031172e-09]
adding correction at 2026-09-11T20:00:00.000000 TDB=[ 8.00299313e-05 -1.23228994e-04 -6.00958883e-05  9.04402357e-08
 -1.41520662e-08 -6.14160256e-09]
adding correction at 2026-09-11T21:00:00.000000 TDB=[ 1.76738555e-04 -1.31211418e-05 -4.47039201e-06  9.00864984e-08
 -1.62320384e-08 -7.02835568e-09]
adding correction at 2026-09-11T22:00:00.000000 TDB=[ 2.17995170e-04  3.83855368e-05  2.11099978e-05  8.96572961e-08
 -1.77994255e-08 -7.71463027e-09]
adding correction at 2026-09-11T23:00:00.000000 TDB=[ 1.37294337e-04 -6.07491529e-05 -2.82673427e-05  9.02912238e-08
 -1.54277613e-08 -6.67807654e-09]
adding correction at 2026-09-12T00:00:00.000000 TDB=[ 1.92609368e-04  1.21143239e-05  7.58026727e-06  8.98084802e-08
 -1.70209105e-08 -7.38071493e-09]
adding correction at 2026-09-12T01:00:00.000000 TDB=[ 1.48210849e-04 -4.63446195e-05 -2.11835868e-05  9.00858199e-08
 -1.59443161e-08 -6.91137569e-09]
adding correction at 2026-09-12T02:00:00.000000 TDB=[ 5.24548086e-05 -1.73817622e-04 -8.37862754e-05  9.05337907e-08
 -1.34873148e-08 -5.86087179e-09]
adding correction at 2026-09-12T03:00:00.000000 TDB=[ 2.41775080e-04  7.44662830e-05  3.84614541e-05  8.99850455e-08
 -1.72024519e-08 -7.43496431e-09]
adding correction at 2026-09-12T04:00:00.000000 TDB=[ 2.02316907e-04  2.91920151e-05  1.56237365e-05  8.98457240e-08
 -1.68089827e-08 -7.29021499e-09]
adding correction at 2026-09-12T05:00:00.000000 TDB=[ 1.44563703e-04 -5.41477348e-05 -2.47696298e-05  9.02716998e-08
 -1.53681423e-08 -6.65600008e-09]
adding correction at 2026-09-12T06:00:00.000000 TDB=[ 1.59516407e-04 -3.17330705e-05 -1.39706535e-05  9.01743381e-08
 -1.56644222e-08 -6.78745105e-09]
adding correction at 2026-09-12T07:00:00.000000 TDB=[ 1.99826856e-04  2.89137242e-05  1.52330904e-05  8.99321086e-08
 -1.65488978e-08 -7.17451765e-09]
adding correction at 2026-09-12T08:00:00.000000 TDB=[ 1.37388517e-04 -6.44884421e-05 -2.97844526e-05  9.02453865e-08
 -1.52833430e-08 -6.62427357e-09]
adding correction at 2026-09-12T09:00:00.000000 TDB=[ 5.99358318e-05 -1.81898940e-04 -8.62573215e-05  9.05136551e-08
 -1.37667411e-08 -5.97688421e-09]
adding correction at 2026-09-12T10:00:00.000000 TDB=[ 1.59747244e-04 -3.36486264e-05 -1.47249375e-05  9.02507663e-08
 -1.52286828e-08 -6.60129051e-09]
adding correction at 2026-09-12T11:00:00.000000 TDB=[ 2.51069345e-04  1.04238687e-04  5.16389555e-05  9.01084062e-08
 -1.66027001e-08 -7.17639481e-09]
adding correction at 2026-09-12T12:00:00.000000 TDB=[ 1.91435276e-04  2.18094210e-05  1.14087597e-05  9.00226460e-08
 -1.59672400e-08 -6.92721425e-09]
adding correction at 2026-09-12T13:00:00.000000 TDB=[ 1.45225480e-04 -5.59493783e-05 -2.54306942e-05  9.03560292e-08
 -1.49521471e-08 -6.47669474e-09]
adding correction at 2026-09-12T14:00:00.000000 TDB=[ 1.47978979e-04 -5.13938721e-05 -2.32680177e-05  9.03483645e-08
 -1.49487756e-08 -6.47606879e-09]
adding correction at 2026-09-12T15:00:00.000000 TDB=[ 1.87908678e-04  1.62223005e-05  8.73749377e-06  9.01545464e-08
 -1.56162394e-08 -6.76924794e-09]
adding correction at 2026-09-12T16:00:00.000000 TDB=[ 1.90414154e-04  2.09097052e-05  1.09265093e-05  9.01620724e-08
 -1.56184123e-08 -6.76914902e-09]
adding correction at 2026-09-12T17:00:00.000000 TDB=[ 1.32558765e-04 -7.69048347e-05 -3.53844953e-05  9.03781474e-08
 -1.46959920e-08 -6.36949216e-09]
adding correction at 2026-09-12T18:00:00.000000 TDB=[ 7.31962937e-05 -1.78298505e-04 -8.33214726e-05  9.05358959e-08
 -1.38032252e-08 -5.98845773e-09]
adding correction at 2026-09-12T19:00:00.000000 TDB=[ 1.04577441e-04 -1.26539962e-04 -5.87293471e-05  9.04554319e-08
 -1.41026413e-08 -6.11915096e-09]
adding correction at 2026-09-12T20:00:00.000000 TDB=[ 2.31436672e-04  8.80365842e-05  4.28581261e-05  9.02874441e-08
 -1.54620361e-08 -6.69083045e-09]
adding correction at 2026-09-12T21:00:00.000000 TDB=[ 2.23648181e-04  7.70962797e-05  3.75321251e-05  9.02938485e-08
 -1.54002890e-08 -6.66480759e-09]
adding correction at 2026-09-12T22:00:00.000000 TDB=[ 1.91213447e-04  2.78732041e-05  1.38593314e-05  9.02148749e-08
 -1.51914925e-08 -6.58854349e-09]
adding correction at 2026-09-12T23:00:00.000000 TDB=[ 1.56552851e-04 -3.74051742e-05 -1.66081591e-05  9.04163998e-08
 -1.45592916e-08 -6.30859132e-09]
adding correction at 2026-09-13T00:00:00.000000 TDB=[ 1.39892014e-04 -6.89723529e-05 -3.13311175e-05  9.05061299e-08
 -1.42452223e-08 -6.17058382e-09]
adding correction at 2026-09-13T01:00:00.000000 TDB=[ 1.59159594e-04 -3.25999572e-05 -1.43603829e-05  9.04315620e-08
 -1.44707073e-08 -6.27045060e-09]
adding correction at 2026-09-13T02:00:00.000000 TDB=[ 1.87179627e-04  2.05918332e-05  1.04408537e-05  9.03387275e-08
 -1.47952877e-08 -6.41264664e-09]
adding correction at 2026-09-13T03:00:00.000000 TDB=[ 1.92249165e-04  3.05519206e-05  1.50648120e-05  9.03398653e-08
 -1.48026356e-08 -6.41526898e-09]
adding correction at 2026-09-13T04:00:00.000000 TDB=[ 1.62162498e-04 -2.61740643e-05 -1.14079739e-05  9.04407701e-08
 -1.43923637e-08 -6.23686969e-09]
adding correction at 2026-09-13T05:00:00.000000 TDB=[ 1.12535316e-04 -1.20390265e-04 -5.53378486e-05  9.05651734e-08
 -1.37952254e-08 -5.97986738e-09]
adding correction at 2026-09-13T06:00:00.000000 TDB=[ 8.03003495e-05 -1.82225020e-04 -8.41312576e-05  9.06236199e-08
 -1.34112552e-08 -5.81696147e-09]
adding correction at 2026-09-13T07:00:00.000000 TDB=[ 1.03263359e-04 -1.39655080e-04 -6.42205996e-05  9.05826302e-08
 -1.35553675e-08 -5.87991167e-09]
adding correction at 2026-09-13T08:00:00.000000 TDB=[ 1.86618505e-04  1.79174822e-05  9.29203816e-06  9.04968290e-08
 -1.41823864e-08 -6.14416096e-09]
adding correction at 2026-09-13T09:00:00.000000 TDB=[ 2.57335807e-04  1.52554945e-04  7.20480748e-05  9.04724333e-08
 -1.46529504e-08 -6.33785857e-09]
adding correction at 2026-09-13T10:00:00.000000 TDB=[ 1.93067041e-04  3.40570114e-05  1.65900274e-05  9.04802189e-08
 -1.42183025e-08 -6.16003937e-09]
adding correction at 2026-09-13T11:00:00.000000 TDB=[ 1.89470506e-04  3.10011674e-05  1.49467378e-05  9.04321054e-08
 -1.42332479e-08 -6.17122753e-09]
adding correction at 2026-09-13T12:00:00.000000 TDB=[ 1.65042991e-04 -2.00850191e-05 -8.59668944e-06  9.05475263e-08
 -1.38545153e-08 -6.00400973e-09]
adding correction at 2026-09-13T13:00:00.000000 TDB=[ 1.44552963e-04 -6.31166622e-05 -2.84194248e-05  9.06360020e-08
 -1.35456011e-08 -5.86820248e-09]
adding correction at 2026-09-13T14:00:00.000000 TDB=[ 1.44888094e-04 -6.24945387e-05 -2.81292305e-05  9.06433885e-08
 -1.34931648e-08 -5.84574156e-09]
adding correction at 2026-09-13T15:00:00.000000 TDB=[ 1.61784556e-04 -2.70106830e-05 -1.17841701e-05  9.05995328e-08
 -1.36200984e-08 -5.90191740e-09]
adding correction at 2026-09-13T16:00:00.000000 TDB=[ 1.81873795e-04  1.53337605e-05  7.71315536e-06  9.05545769e-08
 -1.37664489e-08 -5.96608662e-09]
adding correction at 2026-09-13T17:00:00.000000 TDB=[ 1.91570551e-04  3.59616242e-05  1.72010914e-05  9.05448020e-08
 -1.37975773e-08 -5.97946670e-09]
adding correction at 2026-09-13T18:00:00.000000 TDB=[ 1.82927266e-04  1.80453062e-05  8.93513788e-06  9.05800573e-08
 -1.36558644e-08 -5.91755656e-09]
adding correction at 2026-09-13T19:00:00.000000 TDB=[ 1.56578346e-04 -3.72421928e-05 -1.65357778e-05  9.06458587e-08
 -1.33702995e-08 -5.79378112e-09]
adding correction at 2026-09-13T20:00:00.000000 TDB=[ 1.21902238e-04 -1.10306661e-04 -5.01799223e-05  9.07141237e-08
 -1.30364928e-08 -5.65015035e-09]
adding correction at 2026-09-13T21:00:00.000000 TDB=[ 9.45288048e-05 -1.68299302e-04 -7.68669415e-05  9.07572695e-08
 -1.27781572e-08 -5.54001423e-09]
adding correction at 2026-09-13T22:00:00.000000 TDB=[ 9.13219701e-05 -1.75627065e-04 -8.02096911e-05  9.07610675e-08
 -1.26997937e-08 -5.50739199e-09]
adding correction at 2026-09-13T23:00:00.000000 TDB=[ 1.22967525e-04 -1.09552755e-04 -4.97500878e-05  9.07322010e-08
 -1.28391444e-08 -5.56682000e-09]
adding correction at 2026-09-14T00:00:00.000000 TDB=[ 1.84297911e-04  1.93598680e-05  9.63028288e-06  9.06969745e-08
 -1.31270146e-08 -5.68720482e-09]
adding correction at 2026-09-14T01:00:00.000000 TDB=[ 2.42485781e-04  1.42211560e-04  6.61897357e-05  9.06880437e-08
 -1.33611646e-08 -5.78276471e-09]
adding correction at 2026-09-14T02:00:00.000000 TDB=[ 2.23332230e-04  1.02630001e-04  4.79224254e-05  9.07163338e-08
 -1.32007112e-08 -5.71399328e-09]
adding correction at 2026-09-14T03:00:00.000000 TDB=[ 1.82424614e-04  2.12884042e-05  1.02157937e-05  9.06748555e-08
 -1.30664826e-08 -5.66379499e-09]
adding correction at 2026-09-14T04:00:00.000000 TDB=[ 1.86424266e-04  3.08493618e-05  1.45628583e-05  9.06753018e-08
 -1.30402324e-08 -5.65262304e-09]
adding correction at 2026-09-14T05:00:00.000000 TDB=[ 1.69043342e-04 -9.30530950e-06 -3.74380033e-06  9.07425636e-08
 -1.28036417e-08 -5.54854440e-09]
adding correction at 2026-09-14T06:00:00.000000 TDB=[ 1.51856570e-04 -4.91396058e-05 -2.18993519e-05  9.08037270e-08
 -1.25802062e-08 -5.45049783e-09]
adding correction at 2026-09-14T07:00:00.000000 TDB=[ 1.44504738e-04 -6.62331004e-05 -2.96882354e-05  9.08331093e-08
 -1.24550255e-08 -5.39590672e-09]
adding correction at 2026-09-14T08:00:00.000000 TDB=[ 1.48516410e-04 -5.69685362e-05 -2.54648039e-05  9.08317792e-08
 -1.24307418e-08 -5.38570899e-09]
adding correction at 2026-09-14T09:00:00.000000 TDB=[ 1.60526659e-04 -2.90948665e-05 -1.27629610e-05  9.08129988e-08
 -1.24687820e-08 -5.40274858e-09]
adding correction at 2026-09-14T10:00:00.000000 TDB=[ 1.74911460e-04  4.36604023e-06  2.48150900e-06  9.07925277e-08
 -1.25182753e-08 -5.42460488e-09]
adding correction at 2026-09-14T11:00:00.000000 TDB=[ 1.85854005e-04  2.99095409e-05  1.41146011e-05  9.07828359e-08
 -1.25347595e-08 -5.43183876e-09]
adding correction at 2026-09-14T12:00:00.000000 TDB=[ 1.88861537e-04  3.70725757e-05  1.73698645e-05  9.07903754e-08
 -1.24906068e-08 -5.41252621e-09]
adding correction at 2026-09-14T13:00:00.000000 TDB=[ 1.81749812e-04  2.07306584e-05  9.91456909e-06  9.08151458e-08
 -1.23788884e-08 -5.36386990e-09]
adding correction at 2026-09-14T14:00:00.000000 TDB=[ 1.65113481e-04 -1.77941984e-05 -7.64604192e-06  9.08518645e-08
 -1.22122370e-08 -5.29160193e-09]
adding correction at 2026-09-14T15:00:00.000000 TDB=[ 1.42300676e-04 -7.07759755e-05 -3.17887170e-05  9.08921260e-08
 -1.20181258e-08 -5.20781818e-09]
adding correction at 2026-09-14T16:00:00.000000 TDB=[ 1.18909200e-04 -1.25237158e-04 -5.65987430e-05  9.09269914e-08
 -1.18318322e-08 -5.12782838e-09]
adding correction at 2026-09-14T17:00:00.000000 TDB=[ 1.01823884e-04 -1.65173435e-04 -7.47838640e-05  9.09495065e-08
 -1.16882417e-08 -5.06654718e-09]
adding correction at 2026-09-14T18:00:00.000000 TDB=[ 9.78120952e-05 -1.74810179e-04 -7.91582861e-05  9.09566934e-08
 -1.16135486e-08 -5.03490416e-09]
adding correction at 2026-09-14T19:00:00.000000 TDB=[ 1.11696747e-04 -1.42850797e-04 -6.45788969e-05  9.09506080e-08
 -1.16177943e-08 -5.03670683e-09]
adding correction at 2026-09-14T20:00:00.000000 TDB=[ 1.44125544e-04 -6.76776981e-05 -3.03140259e-05  9.09380897e-08
 -1.16891152e-08 -5.06634712e-09]
adding correction at 2026-09-14T21:00:00.000000 TDB=[ 1.88954058e-04  3.65346204e-05  1.71723077e-05  9.09288676e-08
 -1.17904861e-08 -5.10771481e-09]
adding correction at 2026-09-14T22:00:00.000000 TDB=[ 2.30261969e-04  1.32834190e-04  6.10399293e-05  9.09317188e-08
 -1.18596715e-08 -5.13463594e-09]
adding correction at 2026-09-14T23:00:00.000000 TDB=[ 2.39021261e-04  1.53674162e-04  7.05138664e-05  9.09484016e-08
 -1.18130434e-08 -5.11314135e-09]
adding correction at 2026-09-15T00:00:00.000000 TDB=[ 1.83052180e-04  2.40451191e-05  1.14250579e-05  9.09660702e-08
 -1.15882250e-08 -5.01958919e-09]
adding correction at 2026-09-15T01:00:00.000000 TDB=[ 1.63754448e-04 -2.06708210e-05 -8.95652920e-06  9.09763579e-08
 -1.14731491e-08 -4.97121422e-09]
adding correction at 2026-09-15T02:00:00.000000 TDB=[ 1.63772522e-04 -2.05567339e-05 -8.90705269e-06  9.09863564e-08
 -1.14097085e-08 -4.94371055e-09]
adding correction at 2026-09-15T03:00:00.000000 TDB=[ 1.63789227e-04 -2.04468379e-05 -8.85938061e-06  9.09962897e-08
 -1.13462584e-08 -4.91620278e-09]
adding correction at 2026-09-15T04:00:00.000000 TDB=[ 1.63805438e-04 -2.03398522e-05 -8.81298911e-06  9.10061569e-08
 -1.12828049e-08 -4.88869345e-09]
adding correction at 2026-09-15T05:00:00.000000 TDB=[ 1.94489956e-04  5.93140721e-05  2.71564350e-05  9.09371636e-08
 -1.14588730e-08 -4.96696018e-09]
adding correction at 2026-09-15T06:00:00.000000 TDB=[ 2.40802765e-04  1.79406255e-04  8.13864172e-05  9.08323239e-08
 -1.17470265e-08 -5.09457188e-09]
adding correction at 2026-09-15T07:00:00.000000 TDB=[ 2.40564346e-04  1.79249793e-04  8.13147053e-05  9.08465827e-08
 -1.16736132e-08 -5.06246778e-09]
adding correction at 2026-09-15T08:00:00.000000 TDB=[ 2.14636326e-04  1.12626702e-04  5.12236729e-05  9.09200484e-08
 -1.14162333e-08 -4.94930852e-09]
adding correction at 2026-09-15T09:00:00.000000 TDB=[ 1.79171562e-04  2.10553408e-05  9.86736268e-06  9.10107634e-08
 -1.11016476e-08 -4.81109730e-09]
adding correction at 2026-09-15T10:00:00.000000 TDB=[ 1.45077705e-04 -6.69844449e-05 -2.98926607e-05  9.10930984e-08
 -1.08090852e-08 -4.68276795e-09]
adding correction at 2026-09-15T11:00:00.000000 TDB=[ 1.19239092e-04 -1.33786350e-04 -6.00619242e-05  9.11536064e-08
 -1.05817719e-08 -4.58329552e-09]
adding correction at 2026-09-15T12:00:00.000000 TDB=[ 1.05112791e-04 -1.70331448e-04 -7.65640289e-05  9.11875730e-08
 -1.04365263e-08 -4.51999682e-09]
adding correction at 2026-09-15T13:00:00.000000 TDB=[ 1.03622675e-04 -1.74377114e-04 -7.83922151e-05  9.11962021e-08
 -1.03718172e-08 -4.49208315e-09]
adding correction at 2026-09-15T14:00:00.000000 TDB=[ 1.13576651e-04 -1.48735940e-04 -6.68177381e-05  9.11843436e-08
 -1.03742366e-08 -4.49357884e-09]
adding correction at 2026-09-15T15:00:00.000000 TDB=[ 1.32560730e-04 -9.97781754e-05 -4.47109342e-05  9.11587192e-08
 -1.04237756e-08 -4.51562521e-09]
adding correction at 2026-09-15T16:00:00.000000 TDB=[ 1.57237053e-04 -3.60086560e-05 -1.59237534e-05  9.11265650e-08
 -1.04979208e-08 -4.54830307e-09]
adding correction at 2026-09-15T17:00:00.000000 TDB=[ 1.83939934e-04  3.30321491e-05  1.52429566e-05  9.10946523e-08
 -1.05747056e-08 -4.58197569e-09]
adding correction at 2026-09-15T18:00:00.000000 TDB=[ 2.08944082e-04  9.78372991e-05  4.44957986e-05  9.10686153e-08
 -1.06349347e-08 -4.60826044e-09]
adding correction at 2026-09-15T19:00:00.000000 TDB=[ 2.28971243e-04  1.49741769e-04  6.79213554e-05  9.10525566e-08
 -1.06636406e-08 -4.62067185e-09]
adding correction at 2026-09-15T20:00:00.000000 TDB=[ 2.41249800e-04  1.81619078e-04  8.22981820e-05  9.10488711e-08
 -1.06508615e-08 -4.61493421e-09]
adding correction at 2026-09-15T21:00:00.000000 TDB=[ 2.43753195e-04  1.88339502e-04  8.53212550e-05  9.10582543e-08
 -1.05919469e-08 -4.58911131e-09]
adding correction at 2026-09-15T22:00:00.000000 TDB=[ 2.35468149e-04  1.67202204e-04  7.57621601e-05  9.10798574e-08
 -1.04873195e-08 -4.54349980e-09]
adding correction at 2026-09-15T23:00:00.000000 TDB=[ 2.16394663e-04  1.18061900e-04  5.35603613e-05  9.11115472e-08
 -1.03420099e-08 -4.48038584e-09]
adding correction at 2026-09-16T00:00:00.000000 TDB=[ 1.87456608e-04  4.34033573e-05  1.98381022e-05  9.11502447e-08
 -1.01647828e-08 -4.40367032e-09]
In [13]:
def Propagator(_uni, _name, _dyn, _coi, _x0, _epoch0, _epoch1, _dt, _delta, _tol=np.full(6, 1e-12)) :

    fra = _uni.frames
    icrf = fra.axesId('ICRF')
    coi = fra.pointId(_coi)

    # get or create sc point
    if fra.containsPoint(_name):
        scPoint = fra.pointId(_name)
    else:
        scPoint = fra.addPoint(_name, tempo.TimeScale.TDB)

    # set up dynamic model
    if not _uni.dynamics.contains(_dyn):
        raise ValueError(f'Dynamics model {_dyn} not present in universe')
    dyn = _uni.dynamics.get(_dyn)
    fra.setAlias(dyn.point, scPoint)
    fra.setAlias(dyn.coi, earth)
    fra.setAlias(dyn.axes, icrf)
    for key, alias in dyn.inputs.items():
        alias.set(_uni.parameters.get("{}_{}".format(_name, key)))

    # create the propagator
    propPoint = prop.PropagatorPoint(fra, icrf, scPoint)
    inp = [prop.PointInput(propPoint, coi, _x0, dyn.acc, _tol, _tol)]
    pro = prop.Propagator('Prop', _epoch0, None, inp)

    class Action(interface.EventAction):
        def __init__(self, propPoint):
            interface.EventAction.__init__(self)
            self.__propPoint = propPoint
        def eval(self, e, crossDir, integDir):
            delta = _delta(e)
            def actionFunc(): return integ.Action.Continue
            deltaState = dict()
            deltaState[self.__propPoint] = delta
            return interface.create_action(e, actionFunc, deltaState)
    action = Action(propPoint)
    epochs = tempo.EpochRange(_epoch0,_epoch1).createGrid(_dt)
    trigger = common.SimpleFixedEventTrigger(epochs)
    event = common.SimpleEvent(trigger, action)
    pro.addEvent(event)
    pro.compute(_epoch1, False)

x0 = geometry.Vector6(fra, 'Earth', 'SC_center', 'ICRF')
if not fra.containsPoint('mysc'):
    scPoint = fra.addPoint('mysc', tempo.TimeScale.TDB)
# define some action function
def func(e): return fra.vector6('mysc', 'SC_center', 'ICRF', e) /2
Propagator(uni, 'mysc', 'GravityOnly', 'Earth', x0, epoch0, epoch1, 3600,func)
plot(['SC_center','mysc'])
In [14]:
uni.frames.containsPoint('SC')
Out[14]:
True