# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/positionlib.py
# _GIGAPARSEC_AU = 206264806247096.38  # 1e9 * 360 * 3600 / tau
#             V = at(t)
#         RT = _T(frame.rotation_at(t))
#         R = framelib.itrs.rotation_at(self.t)
#         R = frame.rotation_at(self.t)
#             V = at(self.t)
#         R = rotation_at(self.t)
# ICRS = ICRF
#         R = cb._altaz_rotation
#             R = rotation_at(position.t)
#     R = mxm(t.MT, spin)
#     V = array((
#         (z,-DAY_S * angvel,z),
#         (DAY_S * angvel,z,z),
#         (z,z,z),
#     ))
# def build_position(position_au, velocity_au_per_d=None, t=None,
#                    center=None, target=None):
# def position_of_radec(ra_hours, dec_degrees, distance_au=_GIGAPARSEC_AU,
#                       epoch=None, t=None, center=None, target=None):
# def position_from_radec(ra_hours, dec_degrees, distance=1.0, epoch=None,
#                         t=None, center=None, target=None):
#     def __init__(self, position_au, velocity_au_per_d=None, t=None,
#                  center=None, target=None):
#     def from_radec(cls, ra_hours, dec_degrees,
#                    distance_au=_GIGAPARSEC_AU, epoch=None):
#     def from_time_and_frame_vectors(cls, t, frame, distance, velocity):
#     def __repr__(self):
#     def __sub__(self, body):
#     def __getitem__(self, i):
#     def __neg__(self):
#     def distance(self):
#     def speed(self):
#     def light_time(self):
#     def radec(self, epoch=None):
#     def hadec(self):
#     def separation_from(self, another_icrf):
#     def cirs_xyz(self, epoch):
#     def cirs_radec(self, epoch):
#     def ecliptic_xyz(self, epoch=None):
#     def ecliptic_velocity(self):
#     def ecliptic_latlon(self, epoch=None):
#     def galactic_xyz(self): return self.frame_xyz(framelib.galactic_frame)
#     def galactic_latlon(self): return self.frame_latlon(framelib.galactic_frame)
#     def frame_xyz(self, frame):
#     def frame_xyz_and_velocity(self, frame):
#     def frame_latlon(self, frame):
#     def frame_latlon_and_rates(self, frame):
#     def to_skycoord(self, unit=None):
#     def phase_angle(self, sun):
#     def fraction_illuminated(self, sun):
#     def is_sunlit(self, ephemeris):
#     def is_behind_earth(self):
#     def _altaz_rotation(self):
#     def from_altaz(self, alt=None, az=None, alt_degrees=None, az_degrees=None,
#                    distance=Distance(au=0.1)):
#     def altaz(self, temperature_C=None, pressure_mbar='standard'):
#     def observe(self, body):
#     def apparent(self):
#     def altaz(self, temperature_C=None, pressure_mbar='standard'):
#     def itrf_xyz(self):
#     def subpoint(self):
# def _to_altaz(position, temperature_C, pressure_mbar):
#     def __init__(self, original, epoch):
# def ITRF_to_GCRS(t, rITRF):  # Deprecated; for compatibility with old versions.
# def ITRF_to_GCRS2(t, rITRF, vITRF, _high_accuracy=False):
# class ICRF(object):
# class Geometric(ICRF):
# class Barycentric(ICRF):
# class Astrometric(ICRF):
# class Apparent(ICRF):
# class Geocentric(ICRF):
# class _Fake(ICRF):  # support for deprecated frame rotation methods above
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/errors.py
# class EphemerisRangeError(ValueError):
#     """An ephemeris has been asked about positions outside its time range.
# 
#     Attributes:
# 
#     - `start_time`, `end_time`: the range of times supported by the segment
#     - `time_mask`: Boolean array where ``True`` marks out-of-range times
#     - `segment`: the ephemeris segment that was asked for positions
# 
#     """
#     def __init__(self, message, start_time, end_time, time_mask, segment):
#         self.args = message,
#         self.start_time = start_time
#         self.end_time = end_time
#         self.time_mask = time_mask
#         self.segment = segment


import numpy as np
from assay import assert_raises
from skyfield import api, positionlib
from skyfield.api import Topos
from skyfield.errors import EphemerisRangeError
"""Tests of the Skyfield `api` module and user-facing exceptions."""


def ts():
    yield api.load.timescale()

def test_sending_jd_that_is_not_a_julian_date():
    earth = api.load('de421.bsp')['earth']
    with assert_raises(ValueError, r"please provide the at\(\) method"
                       " with a Time instance as its argument,"
                       " instead of the value 'blah'"):
        earth.at('blah')

def test_apparent_position_class(ts):
    e = api.load('de421.bsp')
    p = e['earth'].at(ts.utc(2014, 2, 9, 14, 50)).observe(e['mars']).apparent()

# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/positionlib.py
# _GIGAPARSEC_AU = 206264806247096.38  # 1e9 * 360 * 3600 / tau
#             V = at(t)
#         RT = _T(frame.rotation_at(t))
#         R = framelib.itrs.rotation_at(self.t)
#         R = frame.rotation_at(self.t)
#             V = at(self.t)
#         R = rotation_at(self.t)
# ICRS = ICRF
#         R = cb._altaz_rotation
#             R = rotation_at(position.t)
#     R = mxm(t.MT, spin)
#     V = array((
#         (z,-DAY_S * angvel,z),
#         (DAY_S * angvel,z,z),
#         (z,z,z),
#     ))
# def build_position(position_au, velocity_au_per_d=None, t=None,
#                    center=None, target=None):
# def position_of_radec(ra_hours, dec_degrees, distance_au=_GIGAPARSEC_AU,
#                       epoch=None, t=None, center=None, target=None):
# def position_from_radec(ra_hours, dec_degrees, distance=1.0, epoch=None,
#                         t=None, center=None, target=None):
#     def __init__(self, position_au, velocity_au_per_d=None, t=None,
#                  center=None, target=None):
#     def from_radec(cls, ra_hours, dec_degrees,
#                    distance_au=_GIGAPARSEC_AU, epoch=None):
#     def from_time_and_frame_vectors(cls, t, frame, distance, velocity):
#     def __repr__(self):
#     def __sub__(self, body):
#     def __getitem__(self, i):
#     def __neg__(self):
#     def distance(self):
#     def speed(self):
#     def light_time(self):
#     def radec(self, epoch=None):
#     def hadec(self):
#     def separation_from(self, another_icrf):
#     def cirs_xyz(self, epoch):
#     def cirs_radec(self, epoch):
#     def ecliptic_xyz(self, epoch=None):
#     def ecliptic_velocity(self):
#     def ecliptic_latlon(self, epoch=None):
#     def galactic_xyz(self): return self.frame_xyz(framelib.galactic_frame)
#     def galactic_latlon(self): return self.frame_latlon(framelib.galactic_frame)
#     def frame_xyz(self, frame):
#     def frame_xyz_and_velocity(self, frame):
#     def frame_latlon(self, frame):
#     def frame_latlon_and_rates(self, frame):
#     def to_skycoord(self, unit=None):
#     def phase_angle(self, sun):
#     def fraction_illuminated(self, sun):
#     def is_sunlit(self, ephemeris):
#     def is_behind_earth(self):
#     def _altaz_rotation(self):
#     def from_altaz(self, alt=None, az=None, alt_degrees=None, az_degrees=None,
#                    distance=Distance(au=0.1)):
#     def altaz(self, temperature_C=None, pressure_mbar='standard'):
#     def observe(self, body):
#     def apparent(self):
#     def altaz(self, temperature_C=None, pressure_mbar='standard'):
#     def itrf_xyz(self):
#     def subpoint(self):
# def _to_altaz(position, temperature_C, pressure_mbar):
#     def __init__(self, original, epoch):
# def ITRF_to_GCRS(t, rITRF):  # Deprecated; for compatibility with old versions.
# def ITRF_to_GCRS2(t, rITRF, vITRF, _high_accuracy=False):
# class ICRF(object):
# class Geometric(ICRF):
# class Barycentric(ICRF):
# class Astrometric(ICRF):
# class Apparent(ICRF):
# class Geocentric(ICRF):
# class _Fake(ICRF):  # support for deprecated frame rotation methods above
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/errors.py
# class EphemerisRangeError(ValueError):
#     """An ephemeris has been asked about positions outside its time range.
# 
#     Attributes:
# 
#     - `start_time`, `end_time`: the range of times supported by the segment
#     - `time_mask`: Boolean array where ``True`` marks out-of-range times
#     - `segment`: the ephemeris segment that was asked for positions
# 
#     """
#     def __init__(self, message, start_time, end_time, time_mask, segment):
#         self.args = message,
#         self.start_time = start_time
#         self.end_time = end_time
#         self.time_mask = time_mask
#         self.segment = segment


# Path: skyfield/tests/test_api.py
import numpy as np
from assay import assert_raises
from skyfield import api, positionlib
from skyfield.api import Topos
from skyfield.errors import EphemerisRangeError

"""Tests of the Skyfield `api` module and user-facing exceptions."""


def ts():
    yield api.load.timescale()

def test_sending_jd_that_is_not_a_julian_date():
    earth = api.load('de421.bsp')['earth']
    with assert_raises(ValueError, r"please provide the at\(\) method"
                       " with a Time instance as its argument,"
                       " instead of the value 'blah'"):
        earth.at('blah')

def test_apparent_position_class(ts):
    e = api.load('de421.bsp')
    p = e['earth'].at(ts.utc(2014, 2, 9, 14, 50)).observe(e['mars']).apparent()

    assert isinstance(p, positionlib.Apparent)