Last active
November 8, 2016 15:09
-
-
Save boada/12584fa0b7046aedf27aebb0616892a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import astroplan | |
from astroplan import Observer, FixedTarget | |
from astropy.coordinates import SkyCoord | |
from astropy.time import Time, TimeDelta | |
from astroplan.constraints import AtNightConstraint, AirmassConstraint | |
import pandas as pd | |
import numpy as np | |
def mst2utc(time): | |
''' Converts from MST to UTC ''' | |
dt = TimeDelta(7*3600, format='sec') | |
return time + dt | |
def utc2mts(time): | |
''' Converts from UTC to MST ''' | |
dt = TimeDelta(7*3600, format='sec') | |
return time - dt | |
# make telescope location | |
kpno = Observer.at_site('KPNO', timezone='MST') | |
# make target coordinates | |
coords = SkyCoord(131.1331774, 62.41165761, unit='deg', frame='icrs') | |
# make all the targets | |
target = [FixedTarget(name='test', coord=coords)] | |
# make the observing time - Local time. | |
start_time_mst = Time('2016-11-11 18:53') | |
end_time_mst = Time('2016-11-12 05:29') | |
night_time = end_time_mst - start_time_mst | |
observable_time_mst = start_time_mst + night_time * np.linspace(0,1,75) | |
# convert everything to UTC | |
start_time_utc = mst2utc(start_time_mst) | |
end_time_utc = mst2utc(end_time_mst) | |
observable_time_utc = mst2utc(observable_time_mst) | |
print(kpno.target_is_up(start_time_utc, target)) | |
# expect to print True | |
# now we try to do all the fancy scheduling | |
# set our only constraint to be at night | |
constraint = [AtNightConstraint.twilight_civil(), AirmassConstraint(max=5)] | |
print(astroplan.is_observable(constraint, kpno, target[:1], | |
time_range=observable_time_utc)) | |
# expect to print True. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment