Skip to content

Commit

Permalink
Changing Windows -> Ranges to comply with API updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Jun 23, 2015
1 parent 0cddae5 commit aa8c2c9
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions astroplan/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
unicode_literals)

from astropy.coordinates import (EarthLocation, Latitude, Longitude, SkyCoord,
AltAz)
AltAz, get_sun)
import astropy.units as u
from astropy.units import Quantity

import pytz
import numpy as np

################################################################################
# TODO: Temporary solution to IERS tables problems
Expand All @@ -29,12 +30,11 @@
# and modified by Adrian Price-Whelan (email) and Erik Tollerud (email).

__all__ = ["Observer", "Target", "FixedTarget", "NonFixedTarget",
"Constraint", "TimeWindow", "AltitudeRange",
"AboveAirmass", "Observation"]
"Constraint", "TimeRange", "AltitudeRange",
"AirmassRange", "Observation"]

#__doctest_requires__ = {'*': ['scipy.integrate']}


class Observer(object):
"""
Some comments.
Expand Down Expand Up @@ -137,11 +137,16 @@ def altaz(self, target, time):
time : `~astropy.time.Time`
Object
"""
if not isinstance(target, FixedTarget):
if isinstance(target, FixedTarget):
coordinates = target.coord
elif isinstance(target, SkyCoord):
coordinates = target
else:
raise TypeError('The target must be an instance of FixedTarget')

return target.coord.transform_to(AltAz(target.coord.ra, target.coord.dec,
location=self.location, obstime=time))
return coordinates.transform_to(AltAz(coordinates.ra, coordinates.dec,
location=self.location,
obstime=time))

# Sun-related methods.

Expand Down Expand Up @@ -197,6 +202,15 @@ def sunrise(date_time, **kwargs):
"""
raise NotImplementedError()

def _calc_rise_set_limits(self, time, dt, rise_set, N=150,
return_bounds=True, return_a=False):
times = timelinspace(time, dt, N)
sun = get_sun(times)
altitudes = self.altaz(sun, times).alt
return self._horiz_cross(times, altitudes, rise_set,
return_bounds=True,
return_a=return_a)

# Moon-related methods.

def moonrise(date_time, **kwargs):
Expand Down Expand Up @@ -404,7 +418,7 @@ def apply_constraints(self, target, observer, constraint_list):
raise NotImplementedError


class TimeWindow(Constraint):
class TimeRange(Constraint):
"""
An object containing start and end times for an observation.
"""
Expand Down Expand Up @@ -440,12 +454,12 @@ def __init__(self, low, high):
raise NotImplementedError


class AboveAirmass(Constraint):
class AirmassRange(Constraint):
"""
An object containing an airmass lower limit.
"""

def __init__(self, low):
def __init__(self, low, upper=None):
"""
Initializes an AboveAirmass object.
Expand Down

0 comments on commit aa8c2c9

Please sign in to comment.