Time and coordinates


In [ ]:
import matplotlib 
matplotlib.use('Agg')

import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

We are going to use astropy to find out whether the Large Magellanic Cloud (LMC) is visible from the a given observatory at a given time and date.

In the process we need to manipulate different coordinates and time definitions.


In [ ]:
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz

Let's start by getting the coordinates of the LMC


In [ ]:
lmc_center = SkyCoord.from_name('LMC')

In [ ]:
lmc_center

lmc_center is an instance of a class astropy.coordinates.sky_coordinate.SkyCoord


In [ ]:
type(lmc_center)

The full list of attributes and methods can be found using dir()


In [ ]:
dir(lmc_center)

In [ ]:
# To get the ra and dec we print the corresponding attribute
print(lmc_center.ra, lmc_center.dec) # units of degrees for RA
print(lmc_center.ra.hour, lmc_center.dec) # units of hours for RA

An optional way to initialize an object belonging to the class SkyCoord would be

option = SkyCoord('0h39m00', '0d53m1s', frame='icrs')

To find out whether the LMC will be visible from the observatory, we have to define the observatory location and the time of the year.

Let's assume that we are going to observe from SALT (Southern African Large Telescope).


In [ ]:
SALT = EarthLocation.of_site("Southern African Large Telescope")

In [ ]:
SALT.lat, SALT.lon, SALT.height

You can get a list of observatory locations with:

EarthLocation.get_site_names()

If your observatory is not listed in astropy you can initialize its location using

my_observatory = EarthLocation(lat=4.0*u.deg, lon=-75.0*u.deg, height=4000*u.m)

Now let's fix the observation date and time. We are going to use a different class for that


In [ ]:
time = Time('2017-11-11 21:00:00') # That's in Universal Time Coordinated!

In [ ]:
time

We now have all the elements to compute the Altitude + Azimuth coordinates of the LMC at SALT location on November 11th 2017 at 9PM UTC.


In [ ]:
lmg_altaz = lmc_center.transform_to(AltAz(obstime=time,location=SALT))

In [ ]:
print(lmg_altaz.az, lmg_altaz.alt)

With 42 degrees altitude it looks like the LMC was observable with SALT on November 11th 2017 at 9PM UTC!

Exercise 2.1

Plot the altitude of M31 (the Andromeda galaxy) at Las Campanas Observatory on March 10th 2019 between 6PM and 6AM LOCAL TIME.

Hint The following Python code is valid to get the time 30 minutes later than a given time and date.

time = Time('2019-03-10 18:00:00') + 0.5*u.hour

Will be M31 observable that night at Las Campanas?


In [ ]: