Step 1: Complete this tutorial on plotting in Python.
Step 2: Manipulate an astronomical dataset with Python.
Part A. Download this data table [GlobularClusters_clean.tab] to your class folder. This table is a cleaned up version of the data table at http://spider.seds.org/spider/MWGC/mwgc.html.
If you right-click on the *.tab link and choose ‘Download Linked File As’, you can save it directly to the work folder you created. Or, you can download it to your Desktop or Downloads folder and use your knowledge of Unix to move it into your work folder.
Open GlobularClusters_clean.tab in your text editor. For a reminder on how to do this, reread CT-1a.
The table contains the RA and DEC locations, distance from our sun and from the galactic center in kilolightyears (kly), apparent magnitude in the V-band, and angular size of the Globular Clusters in our Milky Way galaxy.
#Set up astropy
from astropy.table import Table,Column
from astropy.coordinates import SkyCoord, Distance
from astropy import units as u
from astropy.io import ascii
#Set up plotting libraries
%config InlineBackend.rc = {}
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn
Globulars = ascii.read('data/GlobularClusters_clean.tab')
Globulars
name | RA | DEC | distSun(kly) | distGalCenter(kly) | m_v | angular_diameter |
---|---|---|---|---|---|---|
Tuc | 6.02362 | -72.0813 | 14.7 | 24.1 | 3.95 | 50.0 |
Scl | 13.1885 | -26.5826 | 29.0 | 39.1 | 8.09 | 13.0 |
Tuc | 15.8094 | -70.8488 | 28.0 | 30.6 | 6.4 | 14.0 |
Cet | 30.7375 | -3.25278 | 98.1 | 112.5 | 15.03 | 1.2 |
Hor | 48.0675 | -55.2162 | 53.1 | 59.0 | 8.29 | 6.8 |
Cep | 53.3335 | 79.5811 | 36.2 | 56.1 | 13.18 | 2.8 |
Hor | 58.7596 | -49.6153 | 2.0 | 406.2 | 15.72 | 0.5 |
Eri | 66.1854 | -21.1869 | 93.7 | 309.7 | 14.7 | 1.0 |
Aur | 71.5246 | 31.3815 | 88.7 | 114.1 | 13.04 | 2.2 |
Col | 78.5282 | -40.0466 | 39.4 | 54.1 | 7.14 | 12.0 |
Lep | 81.0462 | -24.5247 | 42.1 | 61.3 | 7.73 | 9.6 |
... | ... | ... | ... | ... | ... | ... |
Sge | 298.444 | 18.7792 | 13.0 | 21.8 | 8.19 | 7.2 |
Sgr | 301.52 | -21.9212 | 68.1 | 47.9 | 8.52 | 6.8 |
Del | 308.547 | 7.40447 | 50.9 | 41.7 | 8.83 | 7.1 |
Aqr | 313.365 | -12.5373 | 55.4 | 42.1 | 9.27 | 6.6 |
Del | 315.372 | 16.1873 | 34.3 | 125.5 | 10.56 | 3.6 |
Peg | 322.493 | 12.167 | 33.9 | 33.9 | 6.2 | 18.0 |
Aqr | 323.363 | -0.82325 | 37.5 | 33.9 | 6.47 | 16.0 |
Cap | 325.092 | -23.1799 | 26.4 | 23.1 | 7.19 | 12.0 |
Cap | 326.662 | -21.2526 | 61.9 | 51.5 | 11.99 | 2.9 |
Peg | 346.685 | 12.772 | 84.8 | 87.7 | 13.47 | 0.7 |
Aqr | 347.111 | -15.6115 | 85.7 | 82.5 | 11.29 | 4.2 |
To locate an object in 3D space we need three numbers. RA and dec to tell us an objects location on the sky and a distance
GlobularCoords=SkyCoord(Globulars['RA'],Globulars['DEC'],unit=(u.degree, u.degree),\
distance=Distance(Globulars['distSun(kly)']/3.26,u.kpc),frame='icrs')
Globular clusters are plotted in a Mollweide projection. Points are scalled according to the angular diameter and colored according to distance (blue close - pink far)
fig = plt.figure (figsize=(13,7))
ax = fig.add_subplot(111,projection="mollweide")
ax.grid(True)
plt.title("Globular Clusters",fontsize=24)
ax.scatter(GlobularCoords.ra.wrap_at(180.*u.degree).radian,GlobularCoords.dec.radian,c=Globulars['distSun(kly)'],\
cmap='cool',s=4*Globulars['angular_diameter'])
ax.set_xlabel("RA",fontsize=16)
ax.set_ylabel("dec",fontsize=16)
<matplotlib.text.Text at 0x1f750a20>
Questions:
Why are the biggest points mostly light blue and the pink points all small?
Why are the globular clusters centered/clumped around that RA/DEC? Hint: what's the RA/DEC of the center of our galaxy?
Here we'll make the same plot but ransformed to Galactic Coordinates (l,b). In Glaactic coordinates the center of the Galaxy is at (0.0,0.0)
fig = plt.figure (figsize=(13,7))
ax = fig.add_subplot(111,projection="mollweide")
ax.grid(True)
plt.title("Globular Clusters",fontsize=24)
ax.scatter(GlobularCoords.galactic.l.wrap_at(180.*u.degree).radian,GlobularCoords.galactic.b.radian,c=Globulars['distSun(kly)'],\
cmap='cool',s=4*Globulars['angular_diameter'])
ax.set_xlabel("l",fontsize=16)
ax.set_ylabel("b",fontsize=16)
<matplotlib.text.Text at 0x19cd9940>