Basic Tempo Examples¶
To start using tempo, we import the module:
import godot.core.tempo as tempo
Lets construct an Epoch from a string:
epoch = tempo.Epoch("2012-12-23T18:23:23.00 TDB")
There are a few other ways to construct an epoch
# MJD in days
e1 = tempo.Epoch("1020.0 TDB")
# Specify the Julian day type in the string
e2 = tempo.Epoch("1020.0 MJD1950 TDB")
# Integer and float days to be added together
e3 = tempo.Epoch(1,123.234544444,tempo.TimeScale.TDB)
# Integer and float days to be added together with Julian day type
e4 = tempo.Epoch(1,123.342598888,tempo.TimeScale.TDB,tempo.JulianDay.MJD1950)
print(e1)
print(e2)
print(e3)
print(e4)
To convert to another time scale is straightforward:
epochTAI = epoch.convertTo(tempo.TimeScale.TAI)
Now we can print out the two epochs
print(epoch)
print(epochTAI)
or add seconds to the epoch
epoch += 30.0
epochTAI += 30.0
print(epoch)
print(epochTAI)
or compare epochs - including implicit time scale conversions, for example:
epoch < epochTAI
We can create an epoch range and iterate over a grid of values
rng = tempo.EpochRange(epoch,epoch+360)
for t in rng.createGrid(20.123):
print(t)
And many other things.
We want to look at how to make use of automatic differentiation with times. For that purpose we construct an XEpoch
xepoch = tempo.XEpoch("2012-12-23T18:23:23.00 TDB")
we can also add a delta time in seconds to this, but we need to use an autodiff scalar
import godot.core.autodif as ad
delta = ad.Scalar(30.0,"a")
xepoch += delta
print(xepoch)
Note that the time scale conversion does not affect the gradient. This is an intended simplfication in the code
xepochTAI = tempo.convert(tempo.TimeScale.TAI,xepoch)
print(xepochTAI)
It is possible to extract the gradient using the gradient function, and to convert to a numpy.ndarray
g = tempo.gradient(xepochTAI)
print(g)
print(g[delta.leaf()])