Skip to content

Instantly share code, notes, and snippets.

@bmorris3
Last active August 29, 2015 14:26
Show Gist options
  • Save bmorris3/9af7530a33e47b11d1f4 to your computer and use it in GitHub Desktop.
Save bmorris3/9af7530a33e47b11d1f4 to your computer and use it in GitHub Desktop.
"""
Recipe for calculating which bright exoplanets will be transiting tonight and
visible from Apache Point Obsevatory.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from astropy.time import Time
from astroplan import Observer, get_site, Exoplanets
# Get an instance of the exoplanet database
db = Exoplanets()
planets = db.get_available_planets()
# Filter for only the bright planets (found in ground based, wide field surveys)
bright_planets = [planet for planet in planets if 'HAT' in planet or
'WASP' in planet or 'HD' in planet or 'TrES' in planet]
# Initialize an observer at APO
apo = Observer(location=get_site('APO'))
present_time = Time.now()
# Figure out when "tonight" is
if not apo.is_night(present_time):
# If it's currently day time at runtime
tonight_start = apo.sun_set_time(present_time, which='next')
tonight_end = apo.sun_rise_time(present_time, which='next')
else:
tonight_start = present_time
tonight_end = apo.sun_rise_time(present_time, which='next')
# Identify visible transits of planets with bright hosts, print them
for planet in bright_planets:
visible_transits = db.get_visible_transits(apo, planet, tonight_start,
tonight_end)
if visible_transits is not None:
print("Planet: {planet}\t Time: {time.iso}".format(planet=planet,
time=visible_transits))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment