Planning observations with astroplan


In [ ]:
import numpy as np

import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord
import pytz

from astroplan import Observer, FixedTarget

Time and Dates

  • ### All dates and times in are UTC: Coordinated Universal Time .
  • All Time calculation assume that the time is UTC.
  • UTC is related to Greenwich Mean Time (GMT) but does not change with a change of seasons.
  • Time will default to 00:00:00 UTC.

In [ ]:
my_date1 = Time("2017-11-06 13:40:15", format='iso')

my_date1

In [ ]:
my_date1.value

In [ ]:
my_date2 = Time("2017-11-06", format='iso')

my_date2

Current UTC Time


In [ ]:
current_time = Time.now()    # Current UTC Time

current_time

In [ ]:
print("The current time is {0}".format(current_time))

Different Date Formats


In [ ]:
print("The current Julian Date is {0:.2f}".format(current_time.jd))

print("The current Modified Julian Date is {0:.2f}".format(current_time.mjd))

print("The current unix Epoch is {0:.2f}".format(current_time.unix))  # Seconds since (Jan 01, 1970 00:00:00 UTC)

print("The current fraction of a year is {0:.2f}".format(current_time.decimalyear))

Math with Time and Dates


In [ ]:
print("In 1 hour and 25 minutes it will be {0} UTC".format(current_time + 1*u.h + 25*u.min))

In [ ]:
Christmas = Time("2017-12-25 00:00:00", format='iso')

delta_xmas = Christmas - current_time

print("It is {0:.2f} days until christmas, which is {1:.2f} fortnights, or {2:.2f} seconds"
      .format(delta_xmas.to(u.d),delta_xmas.to(u.fortnight),delta_xmas.to(u.s)))

Working with timezones (local time)

  • The python package pytz is used to try to deal with local timezones
  • Timezone List
  • Only use timezone conversions for printouts, NEVER calculations!
  • Working with tomezones is a quick path to maddness!

In [ ]:
my_timezone = pytz.timezone('US/Pacific')

local_now = current_time.to_datetime(my_timezone)

In [ ]:
print("The current local time is {0}".format(local_now))

In [ ]:
# Nepal is in a strange timezone!

everest_timezone = pytz.timezone('Asia/Kathmandu')

everest_local_now = current_time.to_datetime(everest_timezone)

In [ ]:
print("The current local time on Mt. Everest is {0}".format(everest_local_now))

Accurate Time - UT1

AstroPy calculates the times of events to a very high accuracy. To do this, is has to account for the fact that Earth's rotation period is constantly changing due to tidal forces and changes in the Earth's moment of inertia.

To do this, AstroPy uses a time convention called UT1. This system is tied to the rotation of the Earth with repect to the positions of distant quasars. Since the Earth's rotation is constantly changing, the time system UT1 is constanly changing with repect to UTC.

The orientation of the Earth, which must be measured continuously to keep UT1 accurate. This measurement is logged by the International Earth Rotation and Reference Systems Service (IERS). They publish a "bulletin" with the most recent measurements of the Earth's orientation. This bulletin is constantly being updated.

You will run into occasions when you will get a warning that your dates are out of range of the IERS bulletin. To update the bulletin, run the follow block of code:



In [ ]:
from astroplan import download_IERS_A

download_IERS_A()

Places

Setting your location - Observer


In [ ]:
astrolab = Observer(longitude = -122.311473 * u.deg,
                    latitude = 47 * u.deg + 39 * u.arcmin + 15 * u.arcsec,
                    elevation = 63.4 * u.m,
                    timezone = 'US/Pacific',
                    name = "Astrolab"
                    )

In [ ]:
astrolab

Information at your location


In [ ]:
sunset_here = astrolab.sun_set_time(current_time, which='nearest')

print("Sunset will be at {0.iso} UTC".format(sunset_here))

In [ ]:
print("Sunset will be at {0} local time".format(sunset_here.to_datetime(my_timezone)))

MRO

The Manastash Ridge Observatory (MRO) is operated by the Astronomy Department of the University of Washington, for the training of graduate and undergraduate students, as well as for astronomical research.


In [ ]:
mro = Observer.at_site('mro')  # many observatories are built-in to astroplan

mro

In [ ]:
sunset_mro = mro.sun_set_time(current_time, which='nearest')

print("Sunset at MRO will be at {0} local time".format(sunset_mro.to_datetime(my_timezone)))

In [ ]:
(sunset_here - sunset_mro).to(u.min)

Local Siderial Time (LST) will tell you the Right Ascension on the meridian right now.

  • You can use a star chart to find what constellations are visible now.

In [ ]:
midnight_mro = mro.midnight(current_time, which='next')

mro.local_sidereal_time(midnight_mro)

When can you observe?

Astronomical twilight is when the Sun is 18 degrees below the horizon


In [ ]:
astro_set = mro.twilight_evening_astronomical(current_time, which='nearest')  
astro_rise = mro.twilight_morning_astronomical(current_time, which='next')

print("Astronomical Evening Twilight starts at {0.iso} UTC".format(astro_set))
print("Astronomical Midnight is at {0.iso} UTC".format(midnight_mro))
print("Astronomical Morning Twilight starts at {0.iso} UTC".format(astro_rise))

In [ ]:
observing_length = (astro_rise - astro_set).to(u.h)

print("You can observe for {0:.1f} at MRO tonight".format(observing_length))

In [ ]:
# Local Times

print("Tonight's observing at MRO starts at {0},\n peaks at {1} and,\n ends at {2} local time"
      .format(astro_set.to_datetime(my_timezone),
              midnight_mro.to_datetime(my_timezone),
              astro_rise.to_datetime(my_timezone)))

Things

Objects in the sky - FixedTarget

You can define targets by coordinates


In [ ]:
coords = SkyCoord('02h19m00.0s', '+57d07m042s', frame='icrs')

ngc869 = FixedTarget(name='NGC869', coord=coords)

In [ ]:
ngc869.ra

In [ ]:
ngc869.ra.hms

Can you see the object?


In [ ]:
mro.target_is_up(midnight_mro, ngc869)

Where can you see it a midnight?


In [ ]:
where_to_look = mro.altaz(midnight_mro, ngc869)

In [ ]:
where_to_look.alt

In [ ]:
where_to_look.az

Most targets can be defined by name


In [ ]:
my_target = FixedTarget.from_name("m31")

In [ ]:
my_target.coord

In [ ]:
my_target.ra.hms

Objects in the sky - Moving Targets (solar system targets)

  • Astropy used the jplephem package to calculate the positions
  • The built-in solar system objects are: 'sun', 'mercury', 'venus', 'earth-moon-barycenter', 'earth', 'moon', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune', 'pluto'

In [ ]:
from astropy.coordinates import get_sun, get_body, get_moon
from astroplan import moon_illumination

Is the Sun above the horizion now?


In [ ]:
sun_now = get_body('sun',current_time)

sun_now

In [ ]:
sun_location = astrolab.altaz(current_time, sun_now)

sun_location.alt, sun_location.az

In [ ]:
moon_now = get_body('moon',current_time)

In [ ]:
moon_illumination(current_time)

In [ ]:
sun_now.separation(moon_now)

You can turn solar system objects into pseudo FixedTarget objects for observational planning


In [ ]:
moon_midnight = FixedTarget(name='Moon', coord=get_body('moon',midnight_mro))

In [ ]:
moon_midnight

Planning - Observing at MRO

Air Mass is the optical path length through Earth’s atmosphere.

  • At sea-level, the air mass at the zenith is 1.
  • Air mass increases as you move toward the horizon.
  • Air mass at the horizon is approximately 38.
  • The best time to observe a target is at minimum airmass.
  • When the airmass of your target is getting close to 2, you should be observing another target.

In [ ]:
my_target = FixedTarget.from_name("m31")

In [ ]:
mro.target_is_up(midnight_mro, my_target)

Object is up at midnight at MRO - good


In [ ]:
altaz_my_target = astrolab.altaz(midnight_mro, my_target)

altaz_my_target.alt, altaz_my_target.az

Nice high altitude - looking good


In [ ]:
# You can find the airmass by using the .secz method

altaz_my_target.secz

Airmass < 2, you are good to go.

Planning observation is easier with plots


In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt

from astroplan import time_grid_from_range

from astroplan.plots import plot_sky, plot_airmass

In [ ]:
plot_sky(my_target, mro, midnight_mro);

In [ ]:
start_time = astro_set
end_time = astro_rise

observing_range = [astro_set, astro_rise]

time_grid = time_grid_from_range(observing_range)

plot_sky(my_target, mro, time_grid);

Plot the airmass of the target over the night


In [ ]:
plot_airmass(my_target, mro, time_grid);

This is good target for observation at MRO for most of the night

Not all targets can (or should) be observed at all locations


In [ ]:
low_target = FixedTarget.from_name("Diphda")

In [ ]:
mro.target_is_up(midnight_mro, low_target)

In [ ]:
plot_sky(low_target, mro, time_grid);

In [ ]:
plot_airmass(low_target, mro, time_grid);

Not looking good


In [ ]:
# astroplan sets the default limits of the airmass plot to [3,0].
# If you want to see a target at a higher airmass you have to set the limits yourself.

fig,ax = plt.subplots(1,1)

plot_airmass(low_target, mro, time_grid)
ax.set_ylim([15,0]);

As you can see, this is bad target for observation at MRO.

Finder Charts - (Warning: This may not always work depending on the Skyview website)


In [ ]:
from astroplan.plots import plot_finder_image
from astroquery.skyview import SkyView

In [ ]:
plot_finder_image(ngc869)

In [ ]:
# plot_finder_image defaults to a field of view of 10 u*arcmin
# You can specify a different fov

plot_finder_image(ngc869, fov_radius= 1.3 * u.degree)

In [ ]:
plot_finder_image(my_target, fov_radius= 120 * u.arcmin)