# Path: skyfield/almanac.py
# def phase_angle(ephemeris, body, t):
# def fraction_illuminated(ephemeris, body, t):
# def seasons(ephemeris):
#     def season_at(t):
# def moon_phase(ephemeris, t):
# def moon_phases(ephemeris):
#     def moon_phase_at(t):
# def moon_nodes(ephemeris):
#     def moon_node_at(t):
# def oppositions_conjunctions(ephemeris, target):
#     def leading_or_trailing(t):
# def meridian_transits(ephemeris, target, topos):
#     def west_of_meridian_at(t):
# def sunrise_sunset(ephemeris, topos):
#     def is_sun_up_at(t):
# def dark_twilight_day(ephemeris, topos):
#     def is_it_dark_twilight_day_at(t):
# def risings_and_settings(ephemeris, target, topos,
#                          horizon_degrees=-34.0/60.0, radius_degrees=0): #?
#     def is_body_up_at(t):
# SEASONS = [
#     'Spring',
#     'Summer',
#     'Autumn',
#     'Winter',
# ]
# SEASON_EVENTS = [
#     'Vernal Equinox',
#     'Summer Solstice',
#     'Autumnal Equinox',
#     'Winter Solstice',
# ]
# SEASON_EVENTS_NEUTRAL = [
#     'March Equinox',
#     'June Solstice',
#     'September Equinox',
#     'December Solstice',
# ]
# MOON_PHASES = [
#     'New Moon',
#     'First Quarter',
#     'Full Moon',
#     'Last Quarter',
# ]
# MOON_NODES = [
#     'descending',
#     'ascending',
# ]
# CONJUNCTIONS = [
#     'conjunction',
#     'opposition',
# ]
# MERIDIAN_TRANSITS = ['Antimeridian transit', 'Meridian transit']
# TWILIGHTS = {
#     0: 'Night',
#     1: 'Astronomical twilight',
#     2: 'Nautical twilight',
#     3: 'Civil twilight',
#     4: 'Day',
# }
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0


from skyfield import almanac
from skyfield import api
    import matplotlib.pyplot as plt
import matplotlib.pyplot as plt

ts = api.load.timescale()
t0 = ts.tt(-1000, 1, 1)
t1 = ts.tt(2000, 1, 1)
days = int(t1 - t0)

if 1:
    t = ts.tt(-1000, 1, range(days))
    gy, gm, gd = t.tt_calendar()[:3]
    ts.julian_calendar_cutoff = 99999999999999999 #api.GREGORIAN_START
    jy, jm, jd = t.tt_calendar()[:3]
    print(gd - jd)

    # import numpy as np
    # t = np.arange(0.0, 2.0, 0.01)
    # s = 1 + np.sin(2 * np.pi * t)

    fig, ax = plt.subplots()
    ax.plot(t.J, gd - jd, '.') #, label='label', linestyle='--')
    ax.axvline(325, color='blue')
    #ax.plot(325, 0, '.') #, label='label', linestyle='--')
    # ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='Title')
    # ax.set_aspect(aspect=1.0)
    ax.grid()
    # plt.legend()
    ax.set_ylim(-10, 15)
    fig.savefig('tmp.png')
    exit()

eph = api.load('de422.bsp')

# Path: skyfield/almanac.py
# def phase_angle(ephemeris, body, t):
# def fraction_illuminated(ephemeris, body, t):
# def seasons(ephemeris):
#     def season_at(t):
# def moon_phase(ephemeris, t):
# def moon_phases(ephemeris):
#     def moon_phase_at(t):
# def moon_nodes(ephemeris):
#     def moon_node_at(t):
# def oppositions_conjunctions(ephemeris, target):
#     def leading_or_trailing(t):
# def meridian_transits(ephemeris, target, topos):
#     def west_of_meridian_at(t):
# def sunrise_sunset(ephemeris, topos):
#     def is_sun_up_at(t):
# def dark_twilight_day(ephemeris, topos):
#     def is_it_dark_twilight_day_at(t):
# def risings_and_settings(ephemeris, target, topos,
#                          horizon_degrees=-34.0/60.0, radius_degrees=0): #?
#     def is_body_up_at(t):
# SEASONS = [
#     'Spring',
#     'Summer',
#     'Autumn',
#     'Winter',
# ]
# SEASON_EVENTS = [
#     'Vernal Equinox',
#     'Summer Solstice',
#     'Autumnal Equinox',
#     'Winter Solstice',
# ]
# SEASON_EVENTS_NEUTRAL = [
#     'March Equinox',
#     'June Solstice',
#     'September Equinox',
#     'December Solstice',
# ]
# MOON_PHASES = [
#     'New Moon',
#     'First Quarter',
#     'Full Moon',
#     'Last Quarter',
# ]
# MOON_NODES = [
#     'descending',
#     'ascending',
# ]
# CONJUNCTIONS = [
#     'conjunction',
#     'opposition',
# ]
# MERIDIAN_TRANSITS = ['Antimeridian transit', 'Meridian transit']
# TWILIGHTS = {
#     0: 'Night',
#     1: 'Astronomical twilight',
#     2: 'Nautical twilight',
#     3: 'Civil twilight',
#     4: 'Day',
# }
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0


# Path: design/calendar_matches.py
from skyfield import almanac
from skyfield import api
    import matplotlib.pyplot as plt
import matplotlib.pyplot as plt


ts = api.load.timescale()
t0 = ts.tt(-1000, 1, 1)
t1 = ts.tt(2000, 1, 1)
days = int(t1 - t0)

if 1:
    t = ts.tt(-1000, 1, range(days))
    gy, gm, gd = t.tt_calendar()[:3]
    ts.julian_calendar_cutoff = 99999999999999999 #api.GREGORIAN_START
    jy, jm, jd = t.tt_calendar()[:3]
    print(gd - jd)

    # import numpy as np
    # t = np.arange(0.0, 2.0, 0.01)
    # s = 1 + np.sin(2 * np.pi * t)

    fig, ax = plt.subplots()
    ax.plot(t.J, gd - jd, '.') #, label='label', linestyle='--')
    ax.axvline(325, color='blue')
    #ax.plot(325, 0, '.') #, label='label', linestyle='--')
    # ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='Title')
    # ax.set_aspect(aspect=1.0)
    ax.grid()
    # plt.legend()
    ax.set_ylim(-10, 15)
    fig.savefig('tmp.png')
    exit()

eph = api.load('de422.bsp')

t, y = almanac.find_discrete(t0, t1, almanac.seasons(eph))