In [1]:
%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 [2]:
!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 [3]:
data = np.genfromtxt('open_exoplanet_catalogue.txt', delimiter=',', comments = '#')
In [4]:
assert data.shape==(1993,24)
Make a histogram of the distribution of planetary masses. This will reproduce Figure 2 in the original paper.
In [5]:
import math
# get rid of the missing values - they seem to cause problems with hist
complete = [x for x in data[:,2] if not math.isnan(x)]
max(complete)
Out[5]:
In [9]:
# plt.hist(complete, bins=50)
f = plt.figure(figsize = (6,4))
plt.hist(complete, bins = 25, range = (0,20))
plt.xlabel("Planetary Masses (Jupiter Units)")
plt.ylabel("Frequency")
plt.title("Distribution of Planetary masses less than 20 Jupiter units\n")
Out[9]:
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 [34]:
y = data[:,6]
x = data[:,5]
# plt.scatter(x,y)
plt.semilogx(x,y,'bo', alpha = .2, ms = 4)
plt.xlabel("Semi-Major Axis (AU)")
plt.ylabel("Orbital Eccentricity")
plt.title("Orbital Eccentricity veruss Semi-Major Axis\n")
Out[34]:
In [32]:
plt.scatter(x,np.log(y))
Out[32]:
In [ ]:
assert True # leave for grading