In [ ]:
import numpy as np
from astropy.table import QTable
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation
import pytz
from astroplan import Observer, FixedTarget
import warnings
warnings.filterwarnings('ignore', category=Warning)
In [ ]:
squares = [] # create a blank list
for x in range(10): # foor loop 0 -> 9
squares.append(x**2) # calculate x**2 for each x, add to end of list
squares
In [ ]:
squares = [x**2 for x in range(10)]
squares
In [ ]:
even_squares = []
for x in range(10):
if (x % 2 == 0):
even_squares.append(x**2)
even_squares
In [ ]:
even_squares = [x**2 for x in range(10) if (x % 2 == 0)]
even_squares
In [ ]:
target_table = QTable.read('ObjectList.csv', format='ascii.csv')
In [ ]:
target_table
In [ ]:
targets = [FixedTarget(coord=SkyCoord(ra = RA*u.hourangle, dec = DEC*u.deg), name=Name)
for Name, RA, DEC in target_table]
In [ ]:
targets
In [ ]:
observe_date = Time("2018-01-01", format='iso')
In [ ]:
my_timezone = pytz.timezone('US/Hawaii')
my_location = Observer.at_site('gemini_north')
In [ ]:
observe_start = my_location.sun_set_time(observe_date, which='nearest')
observe_end = my_location.sun_rise_time(observe_date, which='next')
print("Observing starts at {0.iso} UTC".format(observe_start))
print("Observing ends at {0.iso} UTC".format(observe_end))
print("Observing starts at {0} local".format(observe_start.to_datetime(my_timezone)))
print("Observing ends at {0} local".format(observe_end.to_datetime(my_timezone)))
In [ ]:
# A complete list of built-in observatories can be found by:
#EarthLocation.get_site_names()
In [ ]:
observing_length = (observe_end - observe_start).to(u.h)
print("You can observe for {0:.1f} tonight".format(observing_length))
In [ ]:
observing_range = [observe_start, observe_end]
In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
from astroplan import time_grid_from_range
from astroplan.plots import plot_sky, plot_airmass
In [ ]:
time_grid = time_grid_from_range(observing_range)
In [ ]:
fig,ax = plt.subplots(1,1)
fig.set_size_inches(10,10)
fig.tight_layout()
for my_object in targets:
ax = plot_sky(my_object, my_location, time_grid)
ax.legend(loc=0,shadow=True);
In [ ]:
fig,ax = plt.subplots(1,1)
fig.set_size_inches(10,5)
fig.tight_layout()
for my_object in targets:
ax = plot_airmass(my_object, my_location, time_grid)
ax.legend(loc=0,shadow=True);
In [ ]:
from astroplan import AltitudeConstraint, AirmassConstraint
from astroplan import observability_table
In [ ]:
constraints = [AltitudeConstraint(20*u.deg, 80*u.deg)]
In [ ]:
observing_table = observability_table(constraints, my_location, targets, time_range=observing_range)
print(observing_table)
In [ ]:
constraints.append(AirmassConstraint(2))
In [ ]:
observing_table = observability_table(constraints, my_location, targets, time_range=observing_range)
print(observing_table)
from astroplan import CONSTRAINT
AtNightConstraint()
- Constrain the Sun to be below horizon.MoonIlluminationConstraint(min, max)
- Constrain the fractional illumination of the Moon.MoonSeparationConstraint(min, max)
- Constrain the separation between the Moon and some targets.SunSeparationConstraint(min, max)
- Constrain the separation between the Sun and some targets.
In [ ]:
from astroplan import moon_illumination
In [ ]:
moon_illumination(observe_start)
In [ ]:
from astroplan import MoonSeparationConstraint
In [ ]:
constraints.append(MoonSeparationConstraint(45*u.deg))
In [ ]:
observing_table = observability_table(constraints, my_location, targets, time_range=observing_range)
print(observing_table)
In [ ]:
fig,ax = plt.subplots(1,1)
fig.set_size_inches(10,5)
fig.tight_layout()
for i, my_object in enumerate(targets):
if observing_table['ever observable'][i]:
ax = plot_airmass(my_object, my_location, time_grid)
ax.legend(loc=0,shadow=True);