Skip to content

Instantly share code, notes, and snippets.

@vn-ki
Created April 4, 2018 17:48
Show Gist options
  • Save vn-ki/28edbc581b1218118b40df29855d1c6c to your computer and use it in GitHub Desktop.
Save vn-ki/28edbc581b1218118b40df29855d1c6c to your computer and use it in GitHub Desktop.
from astropy.time import Time
def convert_dt64_to_Time(dt64):
if dt64.dtype.name in ['datetime64[M]', 'datetime64[Y]']:
dt64 = dt64.astype('M8[D]')
time_string = str(dt64)
precision = 3
if '.' in time_string:
precision = len(time_string.split('.')[-1])
return Time(time_string, precision=precision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment