Last active
June 15, 2020 13:54
-
-
Save seba-perez/ed26aa78b22529a9b42485fd1d5d20d4 to your computer and use it in GitHub Desktop.
Script to plot exoplanet mass vs semi major axis (or any other quantity).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exodata | |
import numpy as np | |
import matplotlib | |
from matplotlib import pyplot as plt | |
import pickle | |
""" Script to plot exoplanet mass vs semi major axis (or any other | |
quantity). | |
for exoplanet data we need "pip install exodata". | |
""" | |
# [if first time] Load database from exoplanets.org: | |
# exocat = exodata.load_db_from_url() | |
# pickle.dump(exocat, open('./exocat', 'wb')) | |
# Load from local pickle. | |
exocat = pickle.load(open('./exocat', 'rb')) | |
# Example to extract info from a particular system. | |
# print(exocat.planetDict["HR 8799 b"].discoveryMethod) | |
# Example to extract a and M for planets detected by RV only. | |
# detected_by_rv = [planet for planet in exocat.planets if planet.discoveryMethod =="RV"] | |
# a_rv = [planet.a for planet in detected_by_rv] | |
# M_rv = [planet.M for planet in detected_by_rv] | |
f, ax = plt.subplots(ncols=1, nrows=1, figsize=(6.0, 5.2)) | |
methods = ["RV", "transit", "imaging", "microlensing"] # zero "timings" | |
styles = ["o", "o", "o", "o", "o", "o"] | |
mkrcol = ["#EF476F", "#FFD166", "#06D6A0", "#118AB2", "#073b4c"] | |
mkrsize = ["4", "4", "6", "4", "4", "4"] | |
for k in np.arange(len(methods)): | |
detected_by = [planet for planet in exocat.planets if planet.discoveryMethod==methods[k]] | |
print("number of detections by", methods[k],"=",len(detected_by)) | |
ax.plot([planet.a for planet in detected_by], [planet.M for planet in detected_by], | |
styles[k], markerfacecolor=mkrcol[k], markeredgecolor="black", # mkrcol[k], | |
markersize=mkrsize[k], markeredgewidth=.8, label=methods[k]) | |
ax.legend() | |
ax.set_xscale('log') | |
ax.set_yscale('log') | |
ax.set_ylim(10e-4,1000) | |
ax.set_xlim(10e-3,1000) | |
ax.set_xlabel('Semi major axis [au]') | |
ax.set_ylabel(r'Planet mass [M$_{\rm Jup}$]') | |
f.savefig('exoplanets.png', bbox_inches='tight', dpi=300, transparent=True) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exodata | |
import numpy as np | |
import matplotlib | |
matplotlib.use('Agg') | |
from matplotlib import pyplot as plt | |
import pickle | |
""" Script to plot exoplanet mass vs semi major axis (or any other | |
quantity). | |
for exoplanet data we need "pip install exodata". | |
exodata docs: https://arxiv.org/pdf/1510.02738.pdf | |
""" | |
# Solar system data. | |
ssp_names = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] | |
ssp_a = [0.46, 0.73, 1.02, 1.4, 5.17, 10.03, 19.79, 29.91] | |
ssp_M = [0.00017, 0.00256, 0.00315, 0.00034, 1, 0.299, 0.046, 0.054] | |
# Dwarf planets. | |
ssdp_names = ["Ceres", "Pluto", "Haumean", "Eris"] | |
ssdp_a = [2.768, 39.48, 43.22, 67.78] | |
ssdp_M = [4.94e-07, 6.89e-06, 2.11e-06, 8.74e-06] | |
# [if first time] Load database from exoplanets.org: | |
# exocat = exodata.load_db_from_url() | |
# pickle.dump(exocat, open('./exocat', 'wb')) | |
# Load from local pickle. | |
exocat = pickle.load(open('./exocat', 'rb')) | |
# Example to extract info from a particular system. | |
# print(exocat.planetDict["HR 8799 b"].discoveryMethod) | |
# Example to extract a and M for planets detected by RV only. | |
# detected_by_rv = [planet for planet in exocat.planets if planet.discoveryMethod =="RV"] | |
# a_rv = [planet.a for planet in detected_by_rv] | |
# M_rv = [planet.M for planet in detected_by_rv] | |
# print([planet for planet in exocat.planets if planet.a is not np.nan if planet.discoveryMethod=="imaging" and planet.a < 0.1]) | |
f, ax = plt.subplots(ncols=1, nrows=1, figsize=(6.0, 5.2)) | |
methods = ["RV", "transit", "imaging", "microlensing"] # zero "timings" | |
styles = ["o", "o", "o", "o", "o", "o"] | |
mkrcol = ["#EF476F", "#FFD166", "#06D6A0", "#118AB2", "#b388eb", "#f48668"] | |
mkrsize = ["4", "4", "6", "4", "6", "3"] | |
for k in np.arange(len(methods)): | |
detected_by = [planet for planet in exocat.planets if planet.discoveryMethod==methods[k]] | |
if methods[k]=="imaging": | |
detected_by = [planet for planet in exocat.planets if planet.discoveryMethod=="imaging" and planet.a > 0.1] | |
print("number of detections by", methods[k],"=",len(detected_by)) | |
ax.plot([planet.a for planet in detected_by], [planet.M for planet in detected_by], | |
styles[k], markerfacecolor=mkrcol[k], markeredgecolor="black", # mkrcol[k], | |
markersize=mkrsize[k], markeredgewidth=.8, label=methods[k]) | |
ax.plot(ssp_a, ssp_M, "o", markerfacecolor=mkrcol[4], markeredgecolor="black", | |
markersize=mkrsize[4], markeredgewidth=.8, label="Solar System planets") | |
ax.plot(ssdp_a, ssdp_M, "o", markerfacecolor=mkrcol[5], markeredgecolor="black", | |
markersize=mkrsize[5], markeredgewidth=.8, label="Solar System dwarf planets") | |
M_Sun = 1.98844e30 # [M_Sun] = kg | |
M_Earth = 5.9723e24 # [M_Earth] = kg | |
M_Jup = 1.8986e27 # [M_Jup] = kg | |
M_Sat = 5.6846e26 # [M_Sat] = kg | |
ax.plot(65., 10*M_Earth/M_Jup, "^", markerfacecolor=mkrcol[5], markeredgecolor="black", | |
markersize="5", markeredgewidth=.8, label="HD 169142 miniNeptune") | |
ax.legend() | |
ax.set_xscale('log') | |
ax.set_yscale('log') | |
ax.set_ylim(10e-7,1000) | |
ax.set_xlim(10e-4,1000) | |
ax.set_xlabel('Semi major axis [au]') | |
ax.set_ylabel(r'Planet mass [M$_{\rm Jup}$]') | |
f.savefig('exoplanets.pdf', bbox_inches='tight', dpi=300, transparent=True) |
Author
seba-perez
commented
Jun 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment