# 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: skyfield/api.py
# N = E = +1.0
# S = W = -1.0


from skyfield import almanac, api
from skyfield.api import load, tau
from numpy import arccos, sin, cos
from time import time
import numpy as np

    timebump = adjustment / slope
    print(timebump)

    t3 = ts.tt_jd(t2.tt + timebump)
    ha3, dec3, _ = observer.at(t3).observe(body).apparent().hadec()
    setting_ha3 = _sunrise_hour_angle_radians(geo.latitude, dec3, stdalt)
    rising_ha3 = - setting_ha3

    print(ha3.radians - rising_ha3)
    print(max(abs((ha3.radians - rising_ha3))) / tau * 24.0 * 3600.0,
          'seconds')

    return t3

    # adjustment = stdalt - alt.radians
    # print(max(abs(adjustment)) / tau * 24.0 * 3600.0,
    #       'radians adj, in seconds of day (approx)')
    # print(max(adjustment / tau * 24.0 * 3600.0),
    #       'max')

    #ha, dec, _ = observer.at(t).observe(body).apparent().hadec()

#find_sunrise(earth + bluffton, sun, stdalt, t0, t1)

T0 = time()
t_new = find_sunrise(earth + bluffton, sun, stdalt, t0, t1)
DUR_NEW = time() - T0

T0 = time()

# 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: skyfield/api.py
# N = E = +1.0
# S = W = -1.0


# Path: design/sunrise.py
from skyfield import almanac, api
from skyfield.api import load, tau
from numpy import arccos, sin, cos
from time import time
import numpy as np


    timebump = adjustment / slope
    print(timebump)

    t3 = ts.tt_jd(t2.tt + timebump)
    ha3, dec3, _ = observer.at(t3).observe(body).apparent().hadec()
    setting_ha3 = _sunrise_hour_angle_radians(geo.latitude, dec3, stdalt)
    rising_ha3 = - setting_ha3

    print(ha3.radians - rising_ha3)
    print(max(abs((ha3.radians - rising_ha3))) / tau * 24.0 * 3600.0,
          'seconds')

    return t3

    # adjustment = stdalt - alt.radians
    # print(max(abs(adjustment)) / tau * 24.0 * 3600.0,
    #       'radians adj, in seconds of day (approx)')
    # print(max(adjustment / tau * 24.0 * 3600.0),
    #       'max')

    #ha, dec, _ = observer.at(t).observe(body).apparent().hadec()

#find_sunrise(earth + bluffton, sun, stdalt, t0, t1)

T0 = time()
t_new = find_sunrise(earth + bluffton, sun, stdalt, t0, t1)
DUR_NEW = time() - T0

T0 = time()

t_old, y = almanac.find_discrete(t0, t1, almanac.sunrise_sunset(eph, bluffton))