# Path: caput/time.py
# UT1_S = 1.00000000205
# SIDEREAL_S = 1.0 / 1.002737909350795 * UT1_S
# STELLAR_S = 1.0 / 1.00273781191135448 * UT1_S
# def _fixup_interval_and_step(t0, t1, step):
#     def __init__(self, lon=0.0, lat=0.0, alt=0.0, lsd_start=None, sf_wrapper=None):
#     def skyfield_obs(self):
#     def unix_to_lsa(self, time):
#     def lsa_to_unix(self, lsa, time0):
#     def lsd_zero(self):
#     def unix_to_lsd(self, time):
#     def lsd_to_unix(self, lsd):
#     def unix_to_lst(self, unix):
#     def transit_RA(self, time):
#     def transit_times(
#         self, source, t0, t1=None, step=None, lower=False, return_dec=False
#     ):
#         def f(t):
#     def rise_set_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def rise_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def set_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def _sr_work(self, source, t0, t1, step, diameter, skip_rise=False, skip_set=False):
#         def f(t):
#     def _source_ha(self, source, t):
#     def _source_alt(self, source, t):
# def unix_to_skyfield_time(unix_time):
# def skyfield_time_to_unix(skyfield_time):
# def unix_to_era(unix_time):
# def era_to_unix(era, time0):
# def unix_to_datetime(unix_time):
# def datetime_to_unix(dt):
# def datetime_to_timestr(dt):
# def timestr_to_datetime(time_str):
# def leap_seconds_between(time_a, time_b):
# def ensure_unix(time):
# def naive_datetime_to_utc(dt):
# def time_of_day(time):
#     def __init__(self, path=None, expire=None, ephemeris="de421.bsp"):
#     def load(self):
#     def path(self):
#     def timescale(self):
#     def ephemeris(self):
#     def reload(self):
# def _solve_all(f, x0, x1, dx, skip_increasing=False, skip_decreasing=False, **kwargs):
# def skyfield_star_from_ra_dec(ra, dec, name=""):
# class Observer:
# class SkyfieldWrapper:


import os
import random
import time
import numpy as np
import pytest
from datetime import datetime
from skyfield import earthlib, api
from pytest import approx, raises
from caput import time as ctime

    # Compare
    assert lst == approx(TRA, abs=0.02, rel=1e-10)
    assert lst == approx(LSA, abs=0.02, rel=1e-10)


def test_delta():

    delta = np.arange(0, 200000, 1000)  # Seconds.
    # time.time() when I wrote this.  No leap seconds for the next few
    # days.

    obs = ctime.Observer(118.3, 36.1)

    start = 1383679008.816173
    times = start + delta

    # Test for transit RA
    start_ra = obs.transit_RA(start)
    ra = obs.transit_RA(times)
    delta_ra = ra - start_ra
    expected = delta / 3600.0 * 15.0 / ctime.SIDEREAL_S
    error = ((expected - delta_ra + 180.0) % 360) - 180
    # Tolerance limited by stellar aberation (40" peak to peak).
    assert error == approx(0, abs=0.02)

    # Test for lsa
    start_lsa = obs.lsa(start)
    lsa = obs.lsa(times)
    delta_lsa = lsa - start_lsa

# Path: caput/time.py
# UT1_S = 1.00000000205
# SIDEREAL_S = 1.0 / 1.002737909350795 * UT1_S
# STELLAR_S = 1.0 / 1.00273781191135448 * UT1_S
# def _fixup_interval_and_step(t0, t1, step):
#     def __init__(self, lon=0.0, lat=0.0, alt=0.0, lsd_start=None, sf_wrapper=None):
#     def skyfield_obs(self):
#     def unix_to_lsa(self, time):
#     def lsa_to_unix(self, lsa, time0):
#     def lsd_zero(self):
#     def unix_to_lsd(self, time):
#     def lsd_to_unix(self, lsd):
#     def unix_to_lst(self, unix):
#     def transit_RA(self, time):
#     def transit_times(
#         self, source, t0, t1=None, step=None, lower=False, return_dec=False
#     ):
#         def f(t):
#     def rise_set_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def rise_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def set_times(self, source, t0, t1=None, step=None, diameter=0.0):
#     def _sr_work(self, source, t0, t1, step, diameter, skip_rise=False, skip_set=False):
#         def f(t):
#     def _source_ha(self, source, t):
#     def _source_alt(self, source, t):
# def unix_to_skyfield_time(unix_time):
# def skyfield_time_to_unix(skyfield_time):
# def unix_to_era(unix_time):
# def era_to_unix(era, time0):
# def unix_to_datetime(unix_time):
# def datetime_to_unix(dt):
# def datetime_to_timestr(dt):
# def timestr_to_datetime(time_str):
# def leap_seconds_between(time_a, time_b):
# def ensure_unix(time):
# def naive_datetime_to_utc(dt):
# def time_of_day(time):
#     def __init__(self, path=None, expire=None, ephemeris="de421.bsp"):
#     def load(self):
#     def path(self):
#     def timescale(self):
#     def ephemeris(self):
#     def reload(self):
# def _solve_all(f, x0, x1, dx, skip_increasing=False, skip_decreasing=False, **kwargs):
# def skyfield_star_from_ra_dec(ra, dec, name=""):
# class Observer:
# class SkyfieldWrapper:


# Path: caput/tests/test_time.py
import os
import random
import time
import numpy as np
import pytest
from datetime import datetime
from skyfield import earthlib, api
from pytest import approx, raises
from caput import time as ctime


    # Compare
    assert lst == approx(TRA, abs=0.02, rel=1e-10)
    assert lst == approx(LSA, abs=0.02, rel=1e-10)


def test_delta():

    delta = np.arange(0, 200000, 1000)  # Seconds.
    # time.time() when I wrote this.  No leap seconds for the next few
    # days.

    obs = ctime.Observer(118.3, 36.1)

    start = 1383679008.816173
    times = start + delta

    # Test for transit RA
    start_ra = obs.transit_RA(start)
    ra = obs.transit_RA(times)
    delta_ra = ra - start_ra
    expected = delta / 3600.0 * 15.0 / ctime.SIDEREAL_S
    error = ((expected - delta_ra + 180.0) % 360) - 180
    # Tolerance limited by stellar aberation (40" peak to peak).
    assert error == approx(0, abs=0.02)

    # Test for lsa
    start_lsa = obs.lsa(start)
    lsa = obs.lsa(times)
    delta_lsa = lsa - start_lsa

    expected = delta / 3600.0 * 15.0 / ctime.STELLAR_S