CDF_TT2000
==========
== TT2000 with cdflib
We can handle the CDF_TT2000 with the cdflib binding of several languages (C, IDL, Matlab, python...)
In python, using spacepy.pycdf library, CDF_TT2000 values are automatically converted in python datatime objects
that can de displayed as UTC strings.
----
from spacepy import pycdf
cdf = pycdf.CDF("filename.cdf")
epoch = cdf["Epoch"]
print ("START time = ", epoch [0].isoformat(timespec="milliseconds")
print ("STOP time = ", epoch [-1].isoformat(timespec="milliseconds")
----
== TT2000 using spice kernels
We can handle TT2000 values using spice kernels.
TT2000 values correspond to Terrestrial Time (TT) but given in nano-seconds
They have first to be converted in TDT (fractional seconds).
Then converted to TDB (or ET) ephemeris time
Then these ET can be converted in UTC ISO string values
----
import spiceypy
# Import leap seconds file
spiceypy.furnsh ("kernels/lsk/naif0012.tls")
def tt2000_to_UTC (tt2000):
"""
Convert TT2000 (nanoseconds) to UTC string
"""
# TT2000 to TDT
seconds = tt2000 / 1.0e9
# TDT to TDB == ET
et = spiceypy.unitim (seconds, "TDT", "TDB")
# ET to UTC string
return spiceypy.et2utc (et, "ISOC", 6)
----