In [2]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
Over the past few decades, astronomers have discovered thousands of extrasolar planets. The following paper describes the properties of some of these planets.
http://iopscience.iop.org/1402-4896/2008/T130/014001
Your job is to reproduce Figures 2 and 4 from this paper using an up-to-date dataset of extrasolar planets found on this GitHub repo:
https://github.com/OpenExoplanetCatalogue/open_exoplanet_catalogue
A text version of the dataset has already been put into this directory. The top of the file has documentation about each column of data:
In [3]:
!head -n 30 open_exoplanet_catalogue.txt
Use np.genfromtxt with a delimiter of ',' to read the data into a NumPy array called data:
In [9]:
data = np.genfromtxt('open_exoplanet_catalogue.txt', delimiter = ",")
In [7]:
assert data.shape==(1993,24)
Make a histogram of the distribution of planetary masses. This will reproduce Figure 2 in the original paper.
In [13]:
#Most of this is straight from number 1.
#Plotting the 3rd col of data which is planetary masses.
yay = data[:,2]
data2 = yay[~np.isnan(yay)]
plt.hist(data2,200)
plt.xlim(0,35)
ax = plt.gca()
plt.title('Planetary Mass Distribution')
plt.xlabel('Mass Times the Mass of Earth')
plt.ylabel('Number of Planets')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.axes.get_yaxis().tick_left()
In [ ]:
assert True # leave for grading
Make a scatter plot of the orbital eccentricity (y) versus the semimajor axis. This will reproduce Figure 4 of the original paper. Use a log scale on the x axis.
In [84]:
plt.scatter(data[:,6],data[:,5])
ax = plt.gca()
#Makes the x axis be a log scale
ax.semilogx()
plt.title('Orbital Eccentricity vs Semimajor ax')
plt.xlabel('Semimajor axis')
plt.ylabel('orbital eccentricity')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.axes.get_yaxis().tick_left()
In [ ]:
assert True # leave for grading