gavo.stc.times module

Helpers for time parsing and conversion.

gavo.stc.times.TAItoTT(tai)[source]

returns TDT for a (datetime.datetime) TAI.

gavo.stc.times.TCBtoTT(tcb)[source]

returns an approximate TCB from a TT.

This uses [EXS] 2.223-2 and the approximate conversion from TDB to TT.

gavo.stc.times.TCGtoTT(tcg)[source]

returns TT from TCG.

This uses 2.223-5 from [EXS].

gavo.stc.times.TDBtoTT(tdb)[source]

returns an approximate TT from a TDB.

The simplified formula 2.222-1 from [EXS] is used.

gavo.stc.times.TTtoTAI(tdt)[source]

returns TAI for a (datetime.datetime) TDT.

gavo.stc.times.TTtoTCB(tt)[source]

returns an approximate TT from a TCB.

This uses [EXS] 2.223-2 and the approximate conversion from TT to TDB.

gavo.stc.times.TTtoTCG(tt)[source]

returns TT from TCG.

This uses 2.223-5 from [EXS].

gavo.stc.times.TTtoTDB(tt)[source]

returns approximate TDB from TT.

The simplified formula 2.222-1 from [EXS] is used.

gavo.stc.times.TTtoUTC(tt)[source]

returns UTC from TT.

The leap second table is complete through 2009-5.

>>> TTtoUTC(UTCtoTT(datetime.datetime(1998,12,31,23,59,59)))
datetime.datetime(1998, 12, 31, 23, 59, 59)
>>> TTtoUTC(UTCtoTT(datetime.datetime(1999,1,1,0,0,0)))
datetime.datetime(1999, 1, 1, 0, 0)
gavo.stc.times.UTCtoTT(utc)[source]

returns TT from UTC.

The leap second table is complete through 2009-5.

>>> getLeapSeconds(datetime.datetime(1998,12,31,23,59,58))
datetime.timedelta(seconds=31)
>>> TTtoTAI(UTCtoTT(datetime.datetime(1998,12,31,23,59,59)))
datetime.datetime(1999, 1, 1, 0, 0, 30)
>>> TTtoTAI(UTCtoTT(datetime.datetime(1999,1,1,0,0,0)))
datetime.datetime(1999, 1, 1, 0, 0, 32)
gavo.stc.times.bYearToDateTime(bYear)[source]

returns a datetime.datetime instance for a fractional Besselian year.

This uses the formula given by Lieske, J.H., A&A 73, 282 (1979).

gavo.stc.times.dateTimeToBYear(dt)[source]
gavo.stc.times.dateTimeToJYear(dt)[source]

returns a fractional (julian) year for a datetime.datetime instance.

gavo.stc.times.dateTimeToJdn(dt)[source]

returns a julian day number (including fractionals) from a datetime instance.

gavo.stc.times.dateTimeToMJD(dt)[source]

returns a modified julian date for a datetime instance.

gavo.stc.times.datetimeMapperFactory(colDesc)[source]
gavo.stc.times.getLeapSeconds(dt, table=[(datetime.datetime(1971, 12, 31, 23, 59, 59), datetime.timedelta(seconds=10)), (datetime.datetime(1972, 6, 30, 23, 59, 59), datetime.timedelta(seconds=11)), (datetime.datetime(1972, 12, 31, 23, 59, 59), datetime.timedelta(seconds=12)), (datetime.datetime(1973, 12, 31, 23, 59, 59), datetime.timedelta(seconds=13)), (datetime.datetime(1974, 12, 31, 23, 59, 59), datetime.timedelta(seconds=14)), (datetime.datetime(1975, 12, 31, 23, 59, 59), datetime.timedelta(seconds=15)), (datetime.datetime(1976, 12, 31, 23, 59, 59), datetime.timedelta(seconds=16)), (datetime.datetime(1977, 12, 31, 23, 59, 59), datetime.timedelta(seconds=17)), (datetime.datetime(1978, 12, 31, 23, 59, 59), datetime.timedelta(seconds=18)), (datetime.datetime(1979, 12, 31, 23, 59, 59), datetime.timedelta(seconds=19)), (datetime.datetime(1981, 6, 30, 23, 59, 59), datetime.timedelta(seconds=20)), (datetime.datetime(1982, 6, 30, 23, 59, 59), datetime.timedelta(seconds=21)), (datetime.datetime(1983, 6, 30, 23, 59, 59), datetime.timedelta(seconds=22)), (datetime.datetime(1985, 6, 30, 23, 59, 59), datetime.timedelta(seconds=23)), (datetime.datetime(1987, 12, 31, 23, 59, 59), datetime.timedelta(seconds=24)), (datetime.datetime(1989, 12, 31, 23, 59, 59), datetime.timedelta(seconds=25)), (datetime.datetime(1990, 12, 31, 23, 59, 59), datetime.timedelta(seconds=26)), (datetime.datetime(1992, 6, 30, 23, 59, 59), datetime.timedelta(seconds=27)), (datetime.datetime(1993, 6, 30, 23, 59, 59), datetime.timedelta(seconds=28)), (datetime.datetime(1994, 6, 30, 23, 59, 59), datetime.timedelta(seconds=29)), (datetime.datetime(1995, 12, 31, 23, 59, 59), datetime.timedelta(seconds=30)), (datetime.datetime(1997, 6, 30, 23, 59, 59), datetime.timedelta(seconds=31)), (datetime.datetime(1998, 12, 31, 23, 59, 59), datetime.timedelta(seconds=32)), (datetime.datetime(2005, 12, 31, 23, 59, 59), datetime.timedelta(seconds=33)), (datetime.datetime(2008, 12, 31, 23, 59, 59), datetime.timedelta(seconds=34))])[source]

returns TAI-UTC for the datetime dt.

gavo.stc.times.getSeconds(td)[source]

returns the number of seconds corresponding to a timedelta object.

gavo.stc.times.getTransformFromSTC(fromSTC, toSTC)[source]
gavo.stc.times.getTransformFromScales(fromScale, toScale)[source]
gavo.stc.times.isMJD(col)[source]

returns True if the rscdef.Column instance col likely contains MJD values.

This has a long and winding history in DaCHS, and so this is a disaster of heuristics.

gavo.stc.times.jYearToDateTime(jYear)[source]

returns a datetime.datetime instance for a fractional (julian) year.

This refers to time specifications like J2001.32.

gavo.stc.times.jdnToDateTime(jd)[source]

returns a datetime.datetime instance for a julian day number.

gavo.stc.times.mjdToDateTime(mjd)[source]

returns a datetime.datetime instance for a modified julian day number.

Beware: This loses a couple of significant digits due to transformation to jd.

gavo.stc.times.parseISODT(value)[source]