# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/timelib.py
# def julian_date(year, month=1, day=1, hour=0, minute=0, second=0.0):
#     """Given a proleptic Gregorian calendar date and time, build a Julian date.
# 
#     The difference between a “Julian day” and a “Julian date” is that
#     the “day” is the integer part, while the “date” includes a fraction
#     indicating the time.
# 
#     """
#     return julian_day(year, month, day) - 0.5 + (
#         second + minute * 60.0 + hour * 3600.0) / DAY_S


import numpy as np
import os
    import pandas as pd
from skyfield.api import load
from skyfield.timelib import julian_date

def morrison_and_stephenson_2004_table():
    """Table of smoothed Delta T values from Morrison and Stephenson, 2004."""
    f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html')
    tables = pd.read_html(f.read())
    df = tables[0]
    return pd.DataFrame({'year': df[0], 'delta_t': df[1]})

def parse_S15_table(f):
    """Parse polynomial coefficients from Table S15.

    The table is available at the website of Her Majesty's Nautical
    Almanac Office, from the paper “Measurement of the Earth's Rotation:
    720 BC to AD 2015” by L.V. Morrison, F.R. Stephenson, C.Y. Hohenkerk
    and M. Zawilski 2021.

    """
    # http://astro.ukho.gov.uk/nao/lvm/Table-S15.2020.txt
    content = f.read()
    banner = b'- ' * 36 + b'-\n'
    sections = content.split(banner)
    names = sections[1].splitlines()[-1].decode('utf-8').split()
    table = np.loadtxt(sections[2].splitlines())
    return names, table.T

def main():
    thisdir = os.path.dirname(__file__)

    df = morrison_and_stephenson_2004_table()
    year = df.year.values

# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/timelib.py
# def julian_date(year, month=1, day=1, hour=0, minute=0, second=0.0):
#     """Given a proleptic Gregorian calendar date and time, build a Julian date.
# 
#     The difference between a “Julian day” and a “Julian date” is that
#     the “day” is the integer part, while the “date” includes a fraction
#     indicating the time.
# 
#     """
#     return julian_day(year, month, day) - 0.5 + (
#         second + minute * 60.0 + hour * 3600.0) / DAY_S


# Path: skyfield/data/earth_orientation.py
import numpy as np
import os
    import pandas as pd
from skyfield.api import load
from skyfield.timelib import julian_date


def morrison_and_stephenson_2004_table():
    """Table of smoothed Delta T values from Morrison and Stephenson, 2004."""
    f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html')
    tables = pd.read_html(f.read())
    df = tables[0]
    return pd.DataFrame({'year': df[0], 'delta_t': df[1]})

def parse_S15_table(f):
    """Parse polynomial coefficients from Table S15.

    The table is available at the website of Her Majesty's Nautical
    Almanac Office, from the paper “Measurement of the Earth's Rotation:
    720 BC to AD 2015” by L.V. Morrison, F.R. Stephenson, C.Y. Hohenkerk
    and M. Zawilski 2021.

    """
    # http://astro.ukho.gov.uk/nao/lvm/Table-S15.2020.txt
    content = f.read()
    banner = b'- ' * 36 + b'-\n'
    sections = content.split(banner)
    names = sections[1].splitlines()[-1].decode('utf-8').split()
    table = np.loadtxt(sections[2].splitlines())
    return names, table.T

def main():
    thisdir = os.path.dirname(__file__)

    df = morrison_and_stephenson_2004_table()
    year = df.year.values

    jd = julian_date(year, 1, 1)