obsplan home: github.com/ejeschke/obsplan
In [1]:
%pylab
In [2]:
# what version are we using?
from obsplan.version import version
version
Out[2]:
In [3]:
# boilerplate stuff
from obsplan import entity
from datetime import datetime
import pytz
In [4]:
# convenience function for viewing dates in HST
hst = pytz.timezone('US/Hawaii')
def show_hst(dt):
return dt.astimezone(hst).strftime("%m/%d %H:%M:%S")
In [5]:
# define an observer
obs = entity.Observer('Subaru Telescope',
longitude='-155:28:48.900',
latitude='+19:49:42.600',
elevation=4163,
pressure=615,
temperature=0,
timezone='US/Hawaii',
description="Subaru Telescope on Mauna Kea, Hawaii")
In [6]:
# define a target
s5 = entity.StaticTarget(name='S5', ra='14:20:00.00', dec='48:00:00.00')
In [7]:
# Can I observe this target on the night of May 1, 2015 between 18:30 and 05:30 HST
# for 30 minutes somewhere between 45 degrees and 89 degrees altitude?
t_start = datetime(2015, 05, 01, 18, 30, 0, tzinfo=hst)
t_stop = datetime(2015, 05, 02, 5, 30, 0, tzinfo=hst)
tf, t_rise_utc, t_set_utc = obs.observable(s5, t_start, t_stop, 45.0, 89.0, 30*60)
In [8]:
# can observe under these conditions?
tf
Out[8]:
In [21]:
# first time available thusly
t_rise_utc.astimezone(obs.tz_utc).strftime("%m/%d %H:%M:%S")
#t_rise_utc.astimezone(obs.tz_local).strftime("%m/%d %H:%M:%S")
import ephem
datetime(2015, 5, 1, 12, 0, 0, tzinfo=pytz.timezone('US/Eastern'))
Out[21]:
In [10]:
# setting time
show_hst(t_set_utc)
Out[10]:
In [11]:
# same question, but specify the lower elevation bound to be the
# telescope minimum and I will specify an airmass of 1.2 for the target
tf, t_rise_utc, t_set_utc = obs.observable(s5, t_start, t_stop, 15.0, 89.0, 30*60, airmass=1.2)
In [12]:
# observable with this airmass
tf
Out[12]:
In [13]:
# first time available at airmass 1.2
show_hst(t_rise_utc)
Out[13]:
In [14]:
# set time airmass 1.2
t_set_utc.astimezone(hst).strftime("%m/%d %H:%M:%S")
Out[14]:
In [15]:
# when is sunset on May 1, 2015 at observing position?
day = datetime(2015, 5, 1, tzinfo=hst)
show_hst(obs.sunset(date=day))
Out[15]:
In [16]:
# sunrise the next morning?
day = datetime(2015, 5, 2, tzinfo=hst)
show_hst(obs.sunrise(date=day))
Out[16]:
In [17]:
# what is the moon phase?
# (shows another way of getting the local date/time)
day = obs.get_date("2015-05-01")
obs.moon_phase(date=day)
Out[17]:
In [18]:
# moon rise
day = obs.get_date("2015-05-01")
show_hst(obs.moon_rise(date=day))
Out[18]:
In [19]:
# moon set
day = obs.get_date("2015-05-01")
show_hst(obs.moon_set(date=day))
Out[19]:
In [20]:
# define a few more targets
sf = entity.StaticTarget(name='Sf', ra='09:40:00.00', dec='43:00:00.00')
sm = entity.StaticTarget(name='Sm', ra='10:30:00.00', dec='36:00:00.00')
sn = entity.StaticTarget(name='Sn', ra='15:10:00.00', dec='34:00:00.00')
In [21]:
# calculate the distance in alt and az degrees between two targets at
# the given time (e.g. to calculate slew time)
t = obs.get_date("2015-05-01 23:00")
obs.distance(sf, sm, t)
Out[21]:
In [22]:
# tell me about object sm in relation to observer obs at time t
t = obs.get_date("2015-05-01 23:00")
cr = obs.calc(sm, t)
cr
Out[22]:
In [23]:
# Note use of CalculationResult object--many computations are
# lazily delayed until they are asked for. This saves a lot of
# time if many objects are evaluated wrt a given time and we only
# need some of the calculation results (e.g. for scheduling)
# airmass, parallactic angle, hour angle
cr.airmass, cr.pang, cr.ha
Out[23]:
In [24]:
# ut, gmst, lmst
cr.ut, cr.gmst, cr.lmst
Out[24]:
In [25]:
# moon altitude, moon separation from target, moon illumination
cr.moon_alt, cr.moon_sep, cr.moon_pct
Out[25]:
In [26]:
# we can also ask for a calculation via the target (same result)
cr = sm.calc(obs, t)
In [27]:
# boilerplate
from matplotlib.backends.backend_agg import FigureCanvasAgg as fc
targets = [s5, sf, sm, sn]
day = obs.get_date("2015-05-01")
obs.set_date(day)
In [28]:
# make an airmass plot of our targets for the night of May 1, 2015
from obsplan.plots import airmass
plot = airmass.AirMassPlot(10, 6)
canvas = fc(plot.fig)
plot.plot_targets(obs, targets, hst)
plot.fig
Out[28]:
In [29]:
# show our targets sky position relative to our telescope
# on May 1, 2015 at 22:30 HST
from obsplan.plots import polarsky
reload(polarsky)
plot = polarsky.AZELPlot(6, 6)
canvas = fc(plot.fig)
targets = [s5, sf, sm, sn, entity.moon]
t = obs.get_date("2015-05-01 22:30")
plot.setup()
plot.plot_targets(obs, targets, t)
plot.fig
Out[29]:
In [30]:
# get a brief almanac of the day
day = obs.get_date("2015-05-01")
almanac = obs.get_text_almanac(day)
print(almanac)
In [31]:
t_start = obs.get_date("2015-05-01 18:30")
t_stop = obs.get_date("2015-05-02 05:30")
tbl = obs.get_target_info_table(s5, t_start, t_stop, 10)
print(tbl)
In [ ]: