def current_MJD(): """ current_MJD(): Return the current MJD accurate to ~1 sec. """ YY, MM, DD, hh, mm, ss, wday, yday, isdst = time.gmtime() mjd_f, J = s.sla_dtf2d(hh, mm, ss) mjd_i, J = s.sla_cldj(YY, MM, DD) return mjd_i + mjd_f
def datetime2mjd_utc(d): """Converts a passed datetime object in UTC to the equivalent Modified Julian Date (MJD), which is returned""" # Compute MJD for UTC (mjd, status) = S.sla_cldj(d.year, d.month, d.day) if status != 0: return None (fday, status) = S.sla_dtf2d(d.hour, d.minute, d.second + (d.microsecond / 1e6)) if status != 0: return None mjd_utc = mjd + fday return mjd_utc