It is helpful for plotting to have tools which convert a JD to the year + fraction of year.
import calendar
def days_in_year(year):
"""Return the number of days in the specified year."""
return 365 + calendar.isleap(year)
def ymd(jd):
"""Given a JD, return the time as year + fraction of year."""
tup = neospy.Time(jd).time.utc.datetime.timetuple()
# tup.tm_yday should probably have a -1
frac = neospy.time.d_h_m_s_to_float_days(tup.tm_yday, tup.tm_hour, tup.tm_min, tup.tm_sec)
return tup.tm_year + frac / days_in_year(tup.tm_year)
It is helpful for plotting to have tools which convert a JD to the year + fraction of year.