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]:
# YOUR CODE HERE
data=np.genfromtxt(fname="open_exoplanet_catalogue.txt", delimiter=",")
Jupmass=np.array(data[:,2])#takes the coloum corresponding to Jup mass
orbit_e=np.array(data[:,6])
smaxis=np.array(data[:,5])
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 [39]:
# YOUR CODE HERE
plt.figure(figsize=(9,6))
ax=plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.hist(data, bins=4)
plt.ylabel('Number of Planets')
plt.xlabel('M sin i (MJup)')
plt.title("Number of Planets per Mass")
Out[39]:
In [6]:
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 [26]:
# YOUR CODE HERE
f=plt.figure(figsize=(9,6))
ax=plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.scatter(smaxis,orbit_e)
plt.ylabel('Orbital Eccentricity')
plt.xlabel('Semi-major Axis (AU)')
plt.title('All known Extrasolar Planets')
plt.ylim(0,1)
plt.xlim(left=0)
Out[26]:
In [29]:
f1=plt.figure(figsize=(12,8))
plt.subplot(2,2,1)
plt.scatter(smaxis,orbit_e)
plt.ylabel('Orbital Eccentricity')
plt.title('Planets 1st Range')
plt.ylim(0,0.9)
plt.xlim(0,2)
ax=plt.gca()
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.subplot(2,2,2)
plt.scatter(smaxis,orbit_e)
plt.title('Planets 2nd Range')
plt.ylim(0,0.9)
plt.xlim(2,5)
ax=plt.gca()
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.subplot(2,2,3)
plt.scatter(smaxis,orbit_e)
plt.ylabel('Orbital Eccentricity')
plt.xlabel('Semi-major Axis (AU)')
plt.title('Planets 3rd Range')
plt.ylim(0,0.9)
plt.xlim(4,50)
ax=plt.gca()
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.subplot(2,2,4)
plt.scatter(smaxis,orbit_e)
plt.xlabel('Semi-major Axis (AU)')
plt.title('Planets 4th Range')
plt.ylim(0,0.9)
plt.xlim(50,200)
ax=plt.gca()
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.tight_layout()
In [ ]:
assert True # leave for grading