Python Forum
Library (julian), lack of usage information
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Library (julian), lack of usage information
#6
Thank you, snippsat. But I'm expecting higher precision up to more decimals, according to this clue dt.second / 86400 + dt.microsecond / 86400000000 of the following function. Cheers
def to_jd(dt: datetime, fmt: str = 'jd') -> float:
    """
    Converts a given datetime object to Julian date.
    Algorithm is copied from https://en.wikipedia.org/wiki/Julian_day
    All variable names are consistent with the notation on the wiki page.
 
    Parameters
    ----------
    fmt
    dt: datetime
        Datetime object to convert to MJD
 
    Returns
    -------
    jd: float
    """
    a = math.floor((14-dt.month)/12)
    y = dt.year + 4800 - a
    m = dt.month + 12*a - 3
 
    jdn = dt.day + math.floor((153*m + 2)/5) + 365*y + math.floor(y/4) - math.floor(y/100) + math.floor(y/400) - 32045
 
    jd = jdn + (dt.hour - 12) / 24 + dt.minute / 1440 + dt.second / 86400 + dt.microsecond / 86400000000
 
    return __to_format(jd, fmt)
Reply


Messages In This Thread
RE: Library (julian), lack of usage information - by samsonite - Mar-03-2019, 11:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Questions regarding usage of pandas library Pala 5 1,118 Apr-26-2023, 10:21 PM
Last Post: deanhystad
  Lack of understanding "graphX, = ax.plot" easayed 1 2,323 Dec-21-2018, 11:08 PM
Last Post: micseydel
  PyInstaller, how to create library folder instead of library.zip file ? harun2525 2 4,855 May-06-2017, 11:29 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020