%pylab # what version are we using? from obsplan.version import version version # boilerplate stuff from obsplan import entity from datetime import datetime import pytz # 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") # 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") # define a target s5 = entity.StaticTarget(name='S5', ra='14:20:00.00', dec='48:00:00.00') # 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) # can observe under these conditions? tf # first time available thusly show_hst(t_rise_utc) # setting time show_hst(t_set_utc) # 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) # observable with this airmass tf # first time available at airmass 1.2 show_hst(t_rise_utc) # set time airmass 1.2 t_set_utc.astimezone(hst).strftime("%m/%d %H:%M:%S") # when is sunset on May 1, 2015 at observing position? day = datetime(2015, 5, 1, tzinfo=hst) show_hst(obs.sunset(date=day)) # sunrise the next morning? day = datetime(2015, 5, 2, tzinfo=hst) show_hst(obs.sunrise(date=day)) # 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) # moon rise day = obs.get_date("2015-05-01") show_hst(obs.moon_rise(date=day)) # moon set day = obs.get_date("2015-05-01") show_hst(obs.moon_set(date=day)) # 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') # 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) # 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 # 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 # ut, gmst, lmst cr.ut, cr.gmst, cr.lmst # moon altitude, moon separation from target, moon illumination cr.moon_alt, cr.moon_sep, cr.moon_pct # we can also ask for a calculation via the target (same result) cr = sm.calc(obs, t) # 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) # 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 # 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 # get a brief almanac of the day day = obs.get_date("2015-05-01") almanac = obs.get_text_almanac(day) print(almanac) 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)