我想将儒略日期转换为正常日期和时间。我的开始年份是2010.1.1 00:00:00,我正在处理日期的代码部分如下:
import astropy.time
import dateutil.parser
import datetime
from datetime import datetime
dt = dateutil.parser.parse('2010.01.01')
time1 = astropy.time.Time(dt)
jd=time1.jd
print(jd)
datetime_start=266065955.675 #seconds from 2010.1.1 00:00:00
datetime_startjd=(datetime_start/24./60./60.)+jd
print(datetime_startjd)
from __future__ import print_function, division
from PyAstronomy import pyasl
print("The decimal year %10.5f correspond to " % datetime_startjd+ \
pyasl.decimalYearGregorianDate(datetime_startjd, "yyyy-mm-dd hh:mm:ss"))
print(" ... or equivalently (y, m, d, h, m, s, ms): ", \
pyasl.decimalYearGregorianDate(datetime_startjd, "tuple"))
我遇到了错误:
ValueError:2458276年超出范围
有人可以用正确的代码或方式将我的儒略日期转换为正常日期和时间来建议我吗?
答案 0 :(得分:0)
我使用以下代码找到了我需要的东西,以防万一有人想要使用它:
import numpy as np
from astropy.time import Time
times = [ '2010-01-01T00:00:00']
t = Time(times, format='isot', scale='utc')
juliant=t.jd
print(juliant)
datetime_start=265633590.42
datetime_startjd=(datetime_start/24./60./60.)+juliant
print(datetime_startjd)
time2=Time('2458271.96285208',format='jd')
time3=time2.iso
print(time3)
datetime_length=1.0800000429153442
cover_time=((datetime_start+datetime_length)/24./60./60.)+juliant
print(cover_time)
cover_time=Time(cover_time,format='jd')
cover_time=cover_time.iso
print(cover_time)