This example is based on Determining and plotting the altitude/azimuth of a celestial object by Erik Tollerud and Kelle Cruz available in AstroPy Documentation.
The source code of this document is available at https://gitlab.com/rgaiacs/sheffield-r-users-group-2018-07-03.
import numpy as np
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
m33 = SkyCoord.from_name('M33') # Get the coordinates of M33
bear_mountain = EarthLocation(lat=41.3*u.deg, lon=-74*u.deg, height=390*u.m) # Provide the location of Bear Mountain
utcoffset = -4*u.hour # Eastern Daylight Time
midnight = Time('2012-7-13 00:00:00') - utcoffset # Set the time
delta_midnight = np.linspace(-2, 10, 100) * u.hour
frame_July13night = AltAz(
obstime=midnight+delta_midnight,
location=bear_mountain
)
m33altazs_July13night = m33.transform_to(frame_July13night) # Find the Alt, Az coordinates
## Downloading http://maia.usno.navy.mil/ser7/finals2000A.all [Done]
m33airmasss_July13night = m33altazs_July13night.secz
x = delta_midnight
y = m33airmasss_July13night
library(ggplot2)
ggplot(
data.frame(x=py$x, y=py$y),
aes(x, y)
) +
geom_line() +
xlim(-2, 10) +
ylim(1, 4) +
xlab('Hours from EDT Midnight') +
ylab('Airmass [Sec(z)]')
## Warning: Removed 22 rows containing missing values (geom_path).