Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes to work with astropy 2.0 #75

Merged
merged 3 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ env:
matrix:
# Make sure that egg_info works without dependencies
- PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.3 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'
Expand Down Expand Up @@ -98,7 +97,7 @@ matrix:
- os: linux
env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.7
- os: linux
env: PYTHON_VERSION=3.3 NUMPY_VERSION=1.8
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.8
- os: linux
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.9
- os: linux
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
0.10 (unreleased)
-----------------
- No changes yet.
- Handle non-backwards compatible changes to astropy.constants in astropy 2.0.
- Handle deprecated longitude, latitude attributes for astropy >= 2.0.
- Remove tests against python 3.3 (3.4-3.6 are still tested).

0.9 (2017-05-11)
----------------
Expand Down
7 changes: 6 additions & 1 deletion specsim/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,13 @@ def initialize(config):
nominal_start = exposure_start
point_radec = pointing.transform_to('icrs')
hour_angle = astropy.coordinates.Angle(adjust_ha)
try:
lon = location.lon
except AttributeError:
# Required for astropy < 2.0
lon = location.longitude
exposure_start = specsim.transform.adjust_time_to_hour_angle(
nominal_start, point_radec.ra, hour_angle, location.longitude)
nominal_start, point_radec.ra, hour_angle, lon)
# Put the requested HA at the middle of the exposure.
exposure_start -= 0.5 * constants['exposure_time']

Expand Down
11 changes: 7 additions & 4 deletions specsim/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ def create_observing_model(where, when, wavelength, temperature=15*u.deg_C,
# See https://en.wikipedia.org/wiki/Vertical_pressure_variation
if pressure is None:
h = where.height
p0 = astropy.constants.atmosphere
# The atmosphere constant in astropy < 2.0 was renamed to atm in 2.0.
try:
p0 = astropy.constants.atm
except AttributeError:
# Fallback for astropy < 2.0.
p0 = astropy.constants.atmosphere
g0 = astropy.constants.g0
R = astropy.constants.R
air_molar_mass = 0.0289644 * u.kg / u.mol
Expand All @@ -336,7 +341,7 @@ def sky_to_altaz(sky_coords, observing_model):
two steps. First, define the atmosphere through which the sky is being
observed with a call to :func:`create_observing_model`. Next, call this
function. For example, to locate Polaris from Kitt Peak, observing at
a wavelength of 5400 Angstroms:
a wavelength of 5400 Angstroms (we expect altitude ~ longitude ~ 32 deg):

>>> where = observatories['KPNO']
>>> when = astropy.time.Time('2001-01-01T00:00:00')
Expand All @@ -346,8 +351,6 @@ def sky_to_altaz(sky_coords, observing_model):
>>> print('alt = %.3f deg, az = %.3f deg' %
... (altaz.alt.to(u.deg).value, altaz.az.to(u.deg).value))
alt = 32.465 deg, az = 0.667 deg
>>> print('lat = %.3f deg' % where.latitude.to(u.deg).value)
lat = 31.963 deg

The output shape is determined by the usual `numpy broadcasting rules
<http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`__ applied
Expand Down