Source code for ecpi.common.mission.time

'''Referential time tools
'''
from astropy.time import Time, TimeDelta

#TODO: TT = UTC + 69.184 s in 2018 !!! doc A. Sauvageo
TSVOM = 70.184 # s


[docs]def get_mjd_ref(): """return the mjd reference for the SVOM mission :return: mjd reference in mjd :rtype: float """ return 57754.0
[docs]def convert_mjd_in_svomref_seconds(time_mjd): """ convert a time in mjd in a time in seconds from the mjd reference :param time_mjd: time in mjd :type time_mjd: float :return: time in seconds :rtype: float """ return (time_mjd - get_mjd_ref())*24*3600
[docs]def convert_mjd_in_svomref_seconds_ref(time_mjd, time_mjd_ref): """ convert a time in mjd in a time in seconds from the mjd reference :param time_mjd: time in mjd :type time_mjd: float :param time_mjd_ref: time in mjd :type time_mjd_ref: float :return: time in seconds :rtype: float """ return (time_mjd - time_mjd_ref)*24*3600
[docs]def convert_svomref_seconds_in_mjd(time_s): """ convert a time in seconds from the mjd reference in a time in mjd :param time_s: time in s from mjdref :type time_s: float :return: time in mjd :rtype: float """ return time_s/24./3600. + get_mjd_ref()
### ADDED FOR DC2 PURPOSES ###
[docs]def from_isot_to_mjd(t_isot): '''convert isot to mjd :param t_isot: ''' tmp = Time(t_isot, format='isot').mjd return convert_mjd_in_svomref_seconds(tmp) + TSVOM
[docs]def from_mjd_to_isot(t_mjd): '''convert mjd to isot :param t_mjd: ''' tmp = convert_svomref_seconds_in_mjd(t_mjd) tmp_t = Time(tmp, format='mjd') tmp_tsvom = TimeDelta(TSVOM, format='sec') return (tmp_t - tmp_tsvom).isot