Determining and plotting the altitude/azimuth of a celestial object¶
This example demonstrates coordinate transformations and the creation of visibility curves to assist with observing run planning.
By: Erik Tollerud, Kelle Cruz
Let’s suppose you are planning to visit picturesque Bear Mountain State Park in New York, USA. You’re bringing your telescope with you (of course), and someone told you M33 is a great target to observe there. You happen to know you’re free at 11:00 pm local time, and you want to know if it will be up. Astropy can answer that.
Import numpy and matplotlib. For the latter, use a nicer set of plot parameters and set up support for plotting/converting quantities.
<astropy.visualization.units.quantity_support.<locals>.MplQuantityConverter object at 0x7fbabf0fb3a0>
Import the packages necessary for finding coordinates and making coordinate transformations
astropy.coordinates.SkyCoord.from_name uses Simbad to resolve object
names and retrieve coordinates.
Get the coordinates of M33:
astropy.coordinates.EarthLocation to provide the location of Bear
Mountain and set the time to 11pm EDT on 2012 July 12:
astropy.coordinates to find the Alt, Az coordinates of M33 at as
observed from Bear Mountain at 11pm on 2012 July 12.
M33's Altitude = 0.13 deg
This is helpful since it turns out M33 is barely above the horizon at this time. It’s more informative to find M33’s airmass over the course of the night.
Find the alt,az coordinates of M33 at 100 times evenly spaced between 10pm and 7am EDT:
convert alt, az to airmass with
Plot the airmass as a function of time:
get_sun to find the location of the Sun at 1000
evenly spaced times between noon on July 12 and noon on July 13:
from astropy.coordinates import get_sun delta_midnight = np.linspace(-12, 12, 1000)*u.hour times_July12_to_13 = midnight + delta_midnight frame_July12_to_13 = AltAz(obstime=times_July12_to_13, location=bear_mountain) sunaltazs_July12_to_13 = get_sun(times_July12_to_13).transform_to(frame_July12_to_13)
Do the same with
get_moon to find when the moon is
up. Be aware that this will need to download a 10MB file from the internet
to get a precise location of the moon.
Find the alt,az coordinates of M33 at those same times:
Make a beautiful figure illustrating nighttime and the altitudes of M33 and the Sun over that time:
plt.plot(delta_midnight, sunaltazs_July12_to_13.alt, color='r', label='Sun') plt.plot(delta_midnight, moonaltazs_July12_to_13.alt, color=[0.75]*3, ls='--', label='Moon') plt.scatter(delta_midnight, m33altazs_July12_to_13.alt, c=m33altazs_July12_to_13.az, label='M33', lw=0, s=8, cmap='viridis') plt.fill_between(delta_midnight, 0*u.deg, 90*u.deg, sunaltazs_July12_to_13.alt < -0*u.deg, color='0.5', zorder=0) plt.fill_between(delta_midnight, 0*u.deg, 90*u.deg, sunaltazs_July12_to_13.alt < -18*u.deg, color='k', zorder=0) plt.colorbar().set_label('Azimuth [deg]') plt.legend(loc='upper left') plt.xlim(-12*u.hour, 12*u.hour) plt.xticks((np.arange(13)*2-12)*u.hour) plt.ylim(0*u.deg, 90*u.deg) plt.xlabel('Hours from EDT Midnight') plt.ylabel('Altitude [deg]') plt.show()
Total running time of the script: ( 0 minutes 4.199 seconds)