Skip to content

Commit

Permalink
Add back in libnova methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaycedowell committed Dec 13, 2023
1 parent d32fb61 commit 2d71870
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lsl/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ def utc_mcs(self, value):
raise TypeError("Expected a two-element tuple of int/float values")
self._time = astro.mjd_to_jd(float(mjd) + float(mpm)/86400/1000)

@property
def utc_ln_date(self):
"""
Time value formatted as UTC calendar astro.date object.
"""

return astro.get_date(self._time)

@utc_ln_date.setter
def utc_ln_date(self, value):
if not isinstance(value, astro.date):
raise TypeError("value must be type astro.date")

self._time = astro.get_julian_day(value)

@property
def utc_py_date(self):
"""
Expand Down Expand Up @@ -314,6 +329,29 @@ def tai_timet(self, value):
raise TypeError("value must be type int or float")

self._time = astro.tai_to_utc(astro.get_julian_from_timet(int(value)))

@staticmethod
def date_py_to_ln(pyDate):
"""
Convert python datatime.datetime object into a libnova astro.date
object.
"""

lnDate = astro.date(pyDate.year, pyDate.month, pyDate.day, pyDate.hour, pyDate.minute)
lnDate.seconds = float(pyDate.second) + (pyDate.microsecond * 1e-6)
return lnDate

@staticmethod
def date_ln_to_py(lnDate):
"""
Convert libnova astro.date object into a python datetime.datetime
object.
"""

(usec, sec) = math.modf(lnDate.seconds)
pyDate = datetime.datetime(lnDate.years, lnDate.months, lnDate.days,
lnDate.hours, lnDate.minutes, int(sec), int(usec * 1e6))
return pyDate


class SkyPosition(object):
Expand Down

0 comments on commit 2d71870

Please sign in to comment.