In [1]:
import math
%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 [9]:
!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 [42]:
data = np.genfromtxt('open_exoplanet_catalogue.txt', delimiter = ',')
data_mass = data[:,2]
data_mass
def remove(x):
a = []
for item in x:
if not math.isnan(item):
a.append(item)
return a
h = remove(data_mass)
h
Out[42]:
[0.0014,
0.14190059099999999,
0.097536991700000006,
0.021999999999999999,
6.9000000000000004,
0.017000000000000001,
1.24,
0.0195,
1.8200000000000001,
2.1699999999999999,
0.080000000000000002,
0.52000000000000002,
1.99,
0.05074,
0.025951999999999999,
0.83999999999999997,
0.087999999999999995,
0.89200000000000002,
0.161,
2.9300000000000002,
0.78000000000000003,
3.71,
4.0099999999999998,
5.7599999999999998,
0.41999999999999998,
3.0,
1.8999999999999999,
3.6699999999999999,
3.8199999999999998,
5.0199999999999996,
6.0999999999999996,
0.68000000000000005,
0.094060000000000005,
0.10317999999999999,
0.46000000000000002,
0.56999999999999995,
7.3410000000000002,
1.6000000000000001,
21.420000000000002,
12.470000000000001,
4.8700000000000001,
2.4300000000000002,
0.22,
0.021999999999999999,
9.7100000000000009,
0.60299999999999998,
2.2999999999999998,
1.5700000000000001,
1.8300000000000001,
3.2000000000000002,
0.378,
1.02,
7.7999999999999998,
0.034098999999999997,
9.8334600000000005,
17.399999999999999,
2.4399999999999999,
85.200000000000003,
2.2599999999999998,
2.8199999999999998,
4.5899999999999999,
0.075999999999999998,
0.070000000000000007,
0.027,
0.66000000000000003,
1.45,
12.0,
0.27618999999999999,
0.20856,
2.2999999999999998,
10.390000000000001,
14.300000000000001,
0.5,
0.0086999999999999994,
0.0097000000000000003,
10.300000000000001,
2.0,
1.23,
0.016829,
0.62,
0.505,
0.28279799999999999,
0.58999999999999997,
0.95999999999999996,
4.0099999999999998,
1.6000000000000001,
6.0,
3.3100000000000001,
1.5,
1.077,
0.69999999999999996,
1.8200000000000001,
3.0,
0.058000000000000003,
7.2000000000000002,
2.4870000000000001,
0.028091000000000001,
0.011953999999999999,
1.169,
2.2440000000000002,
2.2599999999999998,
0.77800000000000002,
2.3700000000000001,
2.3700000000000001,
6.4299999999999997,
2.8599999999999999,
2.1469999999999998,
2.1000000000000001,
0.52600000000000002,
0.23699999999999999,
2.8199999999999998,
0.82999999999999996,
0.91700000000000004,
22.0,
6.5,
0.90000000000000002,
3.1909999999999998,
0.023900000000000001,
0.018599999999999998,
0.47799999999999998,
0.88400000000000001,
2.2755999999999998,
0.71419999999999995,
0.021000000000000001,
0.045999999999999999,
0.52000000000000002,
2.1800000000000002,
0.17799999999999999,
2.2400000000000002,
2.5800000000000001,
1.5600000000000001,
0.00017387419,
0.0025637401000000002,
0.0031457007000000002,
0.00033799524999999998,
1.0,
0.29899999999999999,
0.045699999999999998,
0.053953000000000001,
7.7581378000000002e-06,
0.71999999999999997,
7.0,
10.0,
10.0,
9.0,
0.015099,
0.022020000000000001,
4.0999999999999996,
1.8320000000000001,
0.66000000000000003,
0.38,
1.5600000000000001,
0.109,
0.35999999999999999,
0.91000000000000003,
1.4399999999999999,
15.039999999999999,
2.7000000000000002,
1.0569999999999999,
0.036804999999999997,
0.20231059900000001,
0.0191927629,
14.0,
0.62,
0.29999999999999999,
2.0299999999999998,
0.033000000000000002,
0.81799999999999995,
15.0,
10.0,
1.1499999999999999,
6.2919999999999998,
1.21,
2.2400000000000002,
0.97499999999999998,
6.0499999999999998,
1.26,
0.53000000000000003,
0.622,
0.079000000000000001,
1.47,
0.71399999999999997,
1.0,
1.4099999999999999,
8.7799999999999994,
0.62,
1.6000000000000001,
0.33000000000000002,
0.46999999999999997,
0.13,
0.019599999999999999,
0.37,
0.069000000000000006,
0.033000000000000002,
0.037999999999999999,
0.058000000000000003,
1.4039999999999999,
8.0999999999999996,
1.1699999999999999,
0.0167,
0.1416,
3.0600000000000001,
4.8499999999999996,
0.69999999999999996,
0.011167,
2.4900000000000002,
1.272,
0.249,
2.1200000000000001,
6.5599999999999996,
4.2400000000000002,
2.0,
1.8,
1.2529999999999999,
0.94999999999999996,
0.053999999999999999,
0.075999999999999998,
0.91400000000000003,
0.91000000000000003,
1.5,
22.0,
1.3300000000000001,
2.4900000000000002,
10.0,
7.0,
2.73,
0.26600000000000001,
19.399999999999999,
0.35599999999999998,
0.68000000000000005,
19.800000000000001,
0.63,
0.29999999999999999,
6.0,
6.5,
0.032500000000000001,
0.035999999999999997,
0.17999999999999999,
9.1799999999999997,
2.8300000000000001,
0.25,
1.8999999999999999,
10.43,
8.8200000000000003,
0.35999999999999999,
0.93000000000000005,
0.17199999999999999,
3.5299999999999998,
1.55,
0.95999999999999996,
1.21,
2.0,
1.3300000000000001,
1.22,
10.98,
5.9000000000000004,
1.3,
0.18720000000000001,
0.65790000000000004,
0.47999999999999998,
1.5,
14.0,
0.0053499999999999997,
0.019820000000000001,
0.016,
0.057299999999999997,
0.071999999999999995,
1.3080000000000001,
1.3700000000000001,
0.223,
0.45000000000000001,
6.96,
1.74,
2.3999999999999999,
13.0,
2.5,
0.45200000000000001,
0.61799999999999999,
1.3200000000000001,
2.3100000000000001,
0.070459999999999995,
0.10285999999999999,
0.58799999999999997,
2.54,
2.8999999999999999,
0.92000000000000004,
0.0084933000000000005,
0.0075496799999999996,
0.015099,
14.4,
0.5,
0.59999999999999998,
0.0038279999999999998,
0.012848,
0.0058820000000000001,
1.98,
0.76300000000000001,
0.67200000000000004,
0.46000000000000002,
0.95999999999999996,
3.48,
0.012579999999999999,
0.020761623999999999,
0.029884155999999999,
0.0110099,
0.01635764,
0.022334469999999999,
0.040000000000000001,
5.5,
4.21,
0.35999999999999999,
1.8500000000000001,
2.96,
3.0899999999999999,
5.9000000000000004,
2.5,
1.25,
0.46999999999999997,
2.6000000000000001,
0.20999999999999999,
13.65,
0.015963000000000001,
0.026041000000000002,
3.1000000000000001,
0.60999999999999999,
0.0052220000000000001,
3.8799999999999999,
0.502,
0.0166,
0.035799999999999998,
0.029999999999999999,
0.92000000000000004,
0.042000000000000003,
6.9699999999999998,
21.0,
7.5999999999999996,
1.0700000000000001,
0.033343999999999999,
0.021391,
0.092483999999999997,
0.023088999999999998,
0.019975,
0.0085249999999999996,
1.26,
0.63600000000000001,
3.5,
0.22,
2.101,
5.9000000000000004,
1.0680000000000001,
1.696,
0.433,
5.0099999999999998,
2.2000000000000002,
0.050000000000000003,
0.65000000000000002,
9.6099999999999994,
0.012048,
0.0031770000000000001,
0.035099999999999999,
0.1507,
6.9000000000000004,
1.3600000000000001,
0.13200000000000001,
7.5999999999999996,
0.42999999999999999,
1.7,
0.023754977,
9.0,
0.67500000000000004,
0.65200000000000002,
0.69599999999999995,
0.56000000000000005,
0.0263,
0.031800000000000002,
0.33300000000000002,
0.42999999999999999,
4.1929999999999996,
0.25900000000000001,
1.3700000000000001,
0.62,
0.54000000000000004,
6.54,
0.376,
0.20999999999999999,
0.85399999999999998,
0.86499999999999999,
5.1299999999999999,
0.019503,
1.54,
0.92000000000000004,
0.058999999999999997,
3.1499999999999999,
1.25,
6.1399999999999997,
12.0,
14.0,
1.55,
2.0600000000000001,
5.9000000000000004,
2.6000000000000001,
2.7000000000000002,
0.68500000000000005,
6.7999999999999998,
0.0040894108000000002,
0.040894100000000003,
0.0059768299999999998,
0.037433830000000001,
0.078642000000000004,
0.01604307,
0.071721900000000005,
0.069205409999999995,
0.206987,
1.5,
1.99,
0.015100000000000001,
0.0264,
30.0,
3.0600000000000001,
11.0,
0.84999999999999998,
14.5,
0.20799999999999999,
2.1299999999999999,
0.66900000000000004,
1.462,
0.157,
20.0,
3.8599999999999999,
1.8440000000000001,
9.7599999999999998,
0.91700000000000004,
2.3999999999999999,
0.81999999999999995,
11.09,
1.8,
23.039999999999999,
0.28999999999999998,
3.5,
1.8799999999999999,
8.0299999999999994,
6.0999999999999996,
0.59899999999999998,
0.94999999999999996,
2.5,
7.2999999999999998,
5.0999999999999996,
5.1600000000000001,
0.12347045,
9.0999999999999996,
0.038692110000000002,
0.027053020000000001,
0.78000000000000003,
17.699999999999999,
2.7999999999999998,
4.4000000000000004,
4.7999999999999998,
9.8800000000000008,
7.7999999999999998,
0.503,
0.186,
5.7000000000000002,
0.26100000000000001,
6.7999999999999998,
0.34000000000000002,
0.210762,
6.3700000000000001,
1.1679999999999999,
10.300000000000001,
10.1,
0.46000000000000002,
1.3600000000000001,
1.22,
0.68999999999999995,
0.67000000000000004,
0.29999999999999999,
9.9000000000000004,
0.73299999999999998,
1.6799999999999999,
0.53400000000000003,
1.3999999999999999,
0.5,
2.9399999999999999,
4.04,
5.0999999999999996,
0.0059769999999999997,
0.0090279999999999996,
0.022963999999999998,
0.025166000000000001,
0.0062909999999999997,
7.6589999999999998,
17.193000000000001,
0.015079,
0.033218999999999999,
0.024944999999999998,
2.0667249999999999,
1.1299999999999999,
50.0,
1.484,
13.0,
2.54,
12.1,
2.7000000000000002,
0.36699999999999999,
0.42999999999999999,
1.323,
5.6100000000000003,
1.0,
0.096100000000000005,
17.5,
0.20000000000000001,
0.53000000000000003,
1.1379999999999999,
0.040500000000000001,
0.89200000000000002,
0.017181999999999999,
0.020261999999999999,
0.021637,
6.8600000000000003,
3.0600000000000001,
0.02,
0.33000000000000002,
1.1200000000000001,
1.47,
11.789999999999999,
0.67000000000000004,
1.1299999999999999,
1.8999999999999999,
7.7999999999999998,
24.0,
27.0,
0.84999999999999998,
0.81999999999999995,
1.054,
0.39000000000000001,
0.62,
1.0600000000000001,
0.5,
2.71,
1.0600000000000001,
2.6000000000000001,
0.90000000000000002,
2.4500000000000002,
2.0,
4.2000000000000002,
1.24,
1.1899999999999999,
4.2000000000000002,
1.032,
0.19700000000000001,
1.0,
0.51400000000000001,
1.8700000000000001,
7.7000000000000002,
1.8,
1.3,
0.48599999999999999,
1.019836,
0.020132000000000001,
1.6000000000000001,
0.31900000000000001,
0.40000000000000002,
1.22,
1.925,
14.0,
0.73999999999999999,
2.5,
0.90000000000000002,
0.94999999999999996,
1.8999999999999999,
0.86899999999999999,
9.6999999999999993,
0.90700000000000003,
0.037182,
0.626,
0.017616,
0.00346,
0.011953999999999999,
0.0084930000000000005,
0.0084930000000000005,
0.016043000000000002,
0.01447,
2.1000000000000001,
2.7799999999999998,
1.71,
0.16800000000000001,
0.47999999999999998,
0.68890799999999996,
0.015729,
1.8999999999999999,
0.037900000000000003,
0.049599999999999998,
0.56999999999999995,
0.28000000000000003,
0.85499999999999998,
0.23000000000000001,
1.3500000000000001,
0.098000000000000004,
0.0035546417000000001,
0.54200000000000004,
1.2749999999999999,
7.2460000000000004,
6.5750000000000002,
0.54300000000000004,
0.49299999999999999,
2.0,
0.044999999999999998,
0.33000000000000002,
1.6799999999999999,
1.3,
12.0,
9.6999999999999993,
0.040894,
0.010475,
0.054106000000000001,
1.79,
0.23000000000000001,
4.5,
0.58999999999999997,
1.1214999999999999,
11.1,
10.5,
0.76100000000000001,
5.2999999999999998,
6.5999999999999996,
0.127,
1.486,
0.27600000000000002,
0.036299999999999999,
0.049799999999999997,
0.051900000000000002,
1.72,
0.072700000000000001,
0.00088079610000000002,
1.5,
0.032199999999999999,
0.06472,
0.11,
0.68000000000000005,
14.0,
2.5299999999999998,
0.54000000000000004,
1.6399999999999999,
0.38,
0.175787,
0.11386400000000001,
0.0239121542963,
1.3999999999999999,
0.34000000000000002,
1.1599999999999999,
0.011041,
1.1100000000000001,
1.9099999999999999,
0.069500000000000006,
0.56899999999999995,
3.2999999999999998,
0.40000000000000002,
19.100000000000001,
0.023800000000000002,
0.64000000000000001,
0.54000000000000004,
0.309,
0.35999999999999999,
0.43099999999999999,
0.94999999999999996,
2.6000000000000001,
12.5,
0.68000000000000005,
0.10100000000000001,
0.246,
1.2709999999999999,
1.8799999999999999,
6.2999999999999998,
0.115,
0.0327,
0.24399999999999999,
0.83999999999999997,
7.0,
2.2000000000000002,
0.77000000000000002,
2.29,
0.0052849999999999998,
0.043725229999999997,
1.25,
5.2999999999999998,
2.5099999999999998,
0.01,
0.8306,
0.1714,
3.8780000000000001,
0.025610000000000001,
0.14099999999999999,
4.0999999999999996,
0.021399999999999999,
0.0223,
0.0069199999999999999,
0.018599999999999998,
0.0071399999999999996,
0.027,
0.050999999999999997,
0.059999999999999998,
8.7400000000000002,
0.26700000000000002,
8.4000000000000004,
0.0078600000000000007,
0.0037699999999999999,
1.071,
10.6,
1.73,
12.582803,
0.0126,
21.5,
2.71,
0.10821,
0.23624000000000001,
0.88,
1.855,
0.048758299999999997,
0.38,
4.6399999999999997,
1.1599999999999999,
20.600000000000001,
0.27000000000000002,
1.345,
0.54000000000000004,
1.99,
0.85999999999999999,
1.76,
1.1499999999999999,
0.37,
0.71099999999999997,
2.3199999999999998,
0.029000000000000001,
3.2000000000000002,
0.76000000000000001,
0.71999999999999997,
1.75,
2.0099999999999998,
3.1200000000000001,
10.390000000000001,
0.34999999999999998,
0.56699999999999995,
1.02,
1.0600000000000001,
0.032841000000000002,
0.035137000000000002,
20.0,
2.2999999999999998,
1.778,
0.28000000000000003,
0.80000000000000004,
1.3400000000000001,
0.057000000000000002,
1.8799999999999999,
0.015814000000000002,
0.0077590000000000003,
0.0378,
0.042200000000000001,
2.2000000000000002,
0.56000000000000005,
1.1599999999999999,
0.89000000000000001,
1.0,
1.2,
4.0,
1.1499999999999999,
0.313,
0.46800000000000003,
1.78,
10.779999999999999,
8.8599999999999994,
1.0589999999999999,
1.24,
0.75,
0.023,
0.012999999999999999,
0.41499999999999998,
1.0800000000000001,
0.90000000000000002,
6.7000000000000002,
0.94099999999999995,
2.2999999999999998,
0.34000000000000002,
0.52400000000000002,
0.21099999999999999,
3.1499999999999999,
7.46,
16.0,
7.2000000000000002,
0.019345999999999999,
2.6000000000000001,
0.72699999999999998,
0.27100000000000002,
0.61499999999999999,
0.058000000000000003,
0.62,
0.57999999999999996,
3.8999999999999999,
3.4700000000000002,
2.75,
4.7999999999999998,
11.0,
11.0,
1.8200000000000001,
2.5,
1.47,
1.8999999999999999,
3.1000000000000001,
1.028,
0.51000000000000001,
0.45000000000000001,
1.49,
0.14999999999999999,
0.27550000000000002,
7.5,
2.0339999999999998,
0.049702000000000003,
0.017301,
0.019,
0.0061000000000000004,
0.022019899999999999,
0.0097515999999999992,
7.0999999999999996,
0.02894,
0.215,
2.1099999999999999,
2.4900000000000002,
0.0014,
0.0020999999999999999,
1.8,
2.0,
1.1379999999999999,
0.55400000000000005,
2.1709999999999998,
7.75,
7.7000000000000002,
0.64000000000000001,
2.3500000000000001,
2.1899999999999999,
0.47999999999999998,
0.83699999999999997,
1.1000000000000001,
4.0,
0.0292,
0.038199999999999998,
0.121,
0.026499999999999999,
3.2000000000000002,
0.035546000000000001,
2.0132479999999999,
0.072665999999999994,
0.28999999999999998,
1.6759999999999999,
0.033210000000000003,
0.52190000000000003,
1.8140000000000001,
7.5999999999999996,
0.081000000000000003,
1.1399999999999999,
0.70999999999999996,
2.0600000000000001,
0.77000000000000002,
263.0,
0.038385300317799999,
1.45,
1.1599999999999999,
0.033029799999999998,
0.049072930000000001,
0.33344426999999999,
0.11009952000000001,
0.66000000000000003,
0.12,
3.2999999999999998,
0.071669999999999998,
0.35060999999999998,
0.47999999999999998,
1.0069999999999999,
1.3500000000000001,
10.699999999999999,
17.0,
0.47999999999999998,
0.93999999999999995,
3.9399999999999999,
3.8799999999999999,
1.28,
0.56999999999999995,
0.32800000000000001,
1.8400000000000001,
0.094,
0.0055263999999999999,
0.76000000000000001,
0.68000000000000005,
4.5999999999999996,
0.019300000000000001,
1.5,
3.3700000000000001,
0.014,
0.035999999999999997,
4.9500000000000002,
3.0,
4.9000000000000004,
5.25,
0.29799999999999999,
1.27,
21.66,
1.373,
1.49,
2.242,
0.79000000000000004,
1.7,
0.035999999999999997,
0.40999999999999998,
0.52700000000000002,
0.013463589999999999,
0.025417260000000001,
1.6200000000000001,
0.57999999999999996,
0.096299999999999997,
0.027,
0.33000000000000002,
0.59499999999999997,
0.46700000000000003,
1.502,
0.057000000000000002,
1.2,
0.84999999999999998,
0.066000000000000003,
1.1100000000000001,
2.0,
0.0117,
0.018700000000000001,
0.016199999999999999,
0.26000000000000001,
2.98,
3.5499999999999998,
0.053999999999999999,
1.6799999999999999,
2.1000000000000001,
0.72999999999999998,
6.0999999999999996,
0.021700000000000001,
0.053999999999999999,
0.051999999999999998,
3.04,
0.39200000000000002,
1.6000000000000001,
1.8500000000000001,
0.90000000000000002,
8.0,
0.29199999999999998,
0.076999999999999999,
0.79000000000000004,
1.28,
2.5,
10.0,
4.0099999999999998,
1.7090000000000001,
0.069400000000000003,
0.59099999999999997,
0.02,
0.91700000000000004,
6.3799999999999999,
0.040000000000000001,
0.19600000000000001,
0.93999999999999995,
3.7000000000000002,
4.5,
1.1100000000000001,
7.5599999999999996,
1.3700000000000001,
11.0,
1.8300000000000001,
0.63,
0.86299999999999999,
2.8130000000000002,
3.379,
0.20000000000000001,
2.8300000000000001,
2.2799999999999998,
3.2799999999999998,
1.5900000000000001,
0.81999999999999995,
2.1139999999999999,
1.45,
2.8999999999999999,
1.76,
0.224,
1.8,
0.57099999999999995,
1.03,
3.0,
0.031600000000000003,
0.02610931,
0.015099359999999999,
0.94699999999999995,
2.0,
2.4500000000000002,
1.47,
2.2999999999999998,
2.7000000000000002,
...]
In [37]:
assert data.shape==(1993,24)
Make a histogram of the distribution of planetary masses. This will reproduce Figure 2 in the original paper.
In [60]:
plt.hist(h, bins = 1000, color = 'blue', alpha=0.7)
plt.xlim(0,30)
plt.ylim(0,300)
plt.ylabel('Number of Exoplanets')
plt.xlabel('Jupiter Masses')
Out[60]:
<matplotlib.text.Text at 0x7f7322f70eb8>
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 [81]:
data_orbit = data[:,6]
data_axis = data[:,5]
r = remove(data_orbit)
s = remove(data_axis)
s = s[0:880]
plt.figure(figsize=(25,6))
plt.scatter(s,r, color = 'green', alpha = 0.4)
plt.xlim(0,10)
plt.ylim(0,1)
plt.xlabel('Semimajor Axis')
plt.ylabel('Orbital Eccentricity')
plt.grid(True)
In [ ]:
assert True # leave for grading
Content source: geoneill12/phys202-2015-work
Similar notebooks: