In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from astropy import units as u
from astropy import constants as const
from astropy.units import imperial
imperial.enable()
from astropy.table import QTable
In [ ]:
def log_10_product(x, pos):
if (x < 1.0):
return '%4.2f' % (x)
else:
return '%i' % (x)
In [ ]:
tfont = {
'family' : 'DejaVu Serif',
'weight' : 'bold',
'size' : 22}
plt.rc('font', **tfont)
plt.rc("axes", linewidth=3.0)
plt.rc('axes', grid=False)
formatter = plt.FuncFormatter(log_10_product)
In [ ]:
#plt.style.available
In [ ]:
#plt.style.use('fivethirtyeight')
In [ ]:
PlanetR = QTable.read('PlanetsRotate.csv', format='ascii.csv')
In [ ]:
PlanetR
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
ax.invert_yaxis()
ax.set_ylim(34,2)
ax.set_xscale('log')
ax.set_xlim(0.5,50)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Distance [AU]")
ax.set_ylabel("Rotation Period [hr]")
#ax.text(1.1, 5.2, 'Earth-Moon', color='blue', fontsize=28)
#ax.text(1.62, 25.1, 'Mars', color='green', fontsize=28)
#ax.text(4.7, 11.1, 'Jup', color='green', fontsize=28)
#ax.text(8.5, 12.2, 'Sat', color='green', fontsize=28)
#ax.text(17.3, 18.3, 'Urn', color='green', fontsize=28)
#ax.text(26.0, 12.7, 'Nep', color='green', fontsize=28)
#ax.text(25.8, 31.5, 'Pluto', color='green', fontsize=28)
ax.plot(PlanetR['a'], PlanetR['rot_per'],color="r",marker="o",linestyle="None",markersize=18)
In [ ]:
fig.savefig('PlanetRot.png', bbox_inches='tight')
In [ ]:
AstR = QTable.read('AsteroidRotate.csv', format='ascii.csv')
In [ ]:
AstR[0:3]
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
ax.invert_yaxis()
ax.set_ylim(10,0.5)
ax.set_xscale('log')
ax.set_xlim(0.5,8)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Distance [AU]")
ax.set_ylabel("Rotation Period [hr]")
ax.plot(PlanetR['a'], PlanetR['rot_per'],color="r",marker="o",linestyle="None",markersize=18)
ax.plot(AstR['a'], AstR['rot_per'],color="b",marker="o",linestyle="None",markersize=8)
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
ax.set_yscale('log')
ax.invert_yaxis()
ax.set_ylim(100,0.9)
ax.set_xscale('log')
ax.set_xlim(0.2,1000)
ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Diameter [km]")
ax.set_ylabel("Rotation Period [hr]")
#ax.plot(PlanetR['diameter'], PlanetR['rot_per'],color="r",marker="o",linestyle="None",markersize=18)
ax.plot(AstR['diameter'], AstR['rot_per'],color="b",marker="o",linestyle="None",markersize=8)
In [ ]:
fig.savefig('AstRot.png', bbox_inches='tight')
In [ ]:
JupInc = np.array([0.050,0.471,0.204,0.205])
SatInc = np.array([1.566,0.010,0.168,0.002,0.327,0.3485,7.570])
UrnInc = np.array([4.232,0.260,0.205,0.340,0.058])
#Io 0.050 5.204267
#Europa 0.471 5.204267
#Ganymede 0.204 5.204267
#Callisto 0.205 5.204267
#Mimas 1.566 9.582
#Enceladus 0.010 9.582
#Tethys 0.168 9.582
#Dione 0.002 9.582
#Rhea 0.327 9.582
#Titan 0.3485 9.582
#Iapetus 7.570 9.582
#Miranda 4.232 19.229
#Ariel 0.260 19.229
#Umbriel 0.205 19.229
#Titania 0.340 19.229
#Oberon 0.058 19.229
JupInc_Ave = JupInc.mean()
JupInc_Std = JupInc.std()
SatInc_Ave = SatInc.mean()
SatInc_Std = SatInc.std()
UrnInc_Ave = UrnInc.mean()
UrnInc_Std = UrnInc.std()
JupInc_Ave
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(-4,30)
ax.set_xscale('log')
ax.set_xlim(0.5,35)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Distance [AU]")
ax.set_ylabel("Orbital Inclination [deg]")
ax.axhline(0,0.01,100,linestyle="--", linewidth=3)
ax.errorbar(5.204267, JupInc_Ave, yerr=JupInc_Std, fmt='-', ecolor='k', capthick=4,capsize=10,elinewidth=4)
ax.plot(5.204267,JupInc_Ave,color="r",marker="o",linestyle="none",markersize=18)
ax.errorbar(9.582, SatInc_Ave, yerr=SatInc_Std, fmt='-', ecolor='k', capthick=4,capsize=10,elinewidth=4)
ax.plot(9.582,SatInc_Ave,color="r",marker="o",linestyle="none",markersize=18)
ax.errorbar(19.229, UrnInc_Ave, yerr=UrnInc_Std, fmt='-', ecolor='k', capthick=4,capsize=10,elinewidth=4)
ax.plot(19.229,UrnInc_Ave,color="r",marker="o",linestyle="none",markersize=18)
ax.errorbar(1.0, 23.5, yerr=5.0, fmt='-', ecolor='k', capthick=4,capsize=10,elinewidth=4)
ax.plot(1.0,23.5,color="r",marker="o",linestyle="none",markersize=18)
In [ ]:
fig.savefig('SatInc.png', bbox_inches='tight')
In [ ]:
KData = QTable.read('K_Planets.csv', format='ascii.csv')
In [ ]:
KData
In [ ]:
colormap = np.array(['r', 'g', 'b', 'm', 'b'])
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0.18,0.42)
ax.set_xscale('log')
ax.set_xlim(0.3,35)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Distance [AU]")
ax.set_ylabel("Moment-of-Inertia [K]")
ax.axhline(0.4,0.01,100,linestyle="--", linewidth=3)
ax.scatter(KData['a'], KData['K'],c = colormap[KData['color']],marker="o",s=200)
In [ ]:
fig.savefig('K.png', bbox_inches='tight')
In [ ]:
ExoData = QTable.read('exoplanet_date.csv', format='ascii.csv')
In [ ]:
ExoData[0:2]
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
#ax.set_ylim(0.18,0.42)
#ax.set_xscale('log')
#ax.set_xlim(0.3,35)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
mask = np.where(ExoData['R'] > 0.0001)
ax.set_xlabel("Date")
ax.set_ylabel("Radius [Jupiter]")
ax.scatter(ExoData['DATE'][mask], ExoData['R'][mask],marker="o",s=200)
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0.8,1000)
#ax.set_xscale('log')
ax.set_xlim(0.0,2.0)
ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
mask2009 = np.where((ExoData['DATE'] > 1999) & (ExoData['DATE'] <= 2009))
mask2013 = np.where((ExoData['DATE'] > 2009) & (ExoData['DATE'] <= 2013))
mask2017 = np.where((ExoData['DATE'] > 2013) & (ExoData['DATE'] <= 2017))
ax.set_xlabel("Exoplanet Radius [Jupiter]")
ax.set_ylabel("Number of Transiting Exoplanets")
ax.text(1.25, 600, 'Discovery Date', color='k', fontsize=28)
ax.text(1.30, 400, '1999-2009', color='ForestGreen', fontsize=28)
ax.text(1.30, 280, '2010-2013', color='FireBrick', fontsize=28)
ax.text(1.30, 200, '2014-2017', color='CornflowerBlue', fontsize=28)
BINS = 20
ax.hist(ExoData['R'][mask2017], bins=BINS, color="CornflowerBlue")
ax.hist(ExoData['R'][mask2013], bins=BINS, color="FireBrick")
ax.hist(ExoData['R'][mask2009], bins=BINS, color="ForestGreen")
ax.vlines(0.08921,0,2000,colors='k', linestyles='dashed', linewidth=5 );
In [ ]:
fig.savefig('SizeDate.png', bbox_inches='tight')
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
#ax.set_ylim(0.18,0.42)
ax.set_xscale('log')
#ax.set_xlim(0.3,35)
#ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
mask = np.where(ExoData['A'] > 0.0001)
ax.set_xlabel("Average Distance [AU]")
ax.set_ylabel("Radius [Jupiter]")
ax.scatter(ExoData['A'][mask], ExoData['R'][mask],marker="o",s=200)
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0,400)
#ax.set_xscale('log')
ax.set_xlim(0.025,1.7)fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0,400)
#ax.set_xscale('log')
ax.set_xlim(0.025,1.7)
#ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
mask = np.where(ExoData['A'] > 0.0001)
ax.set_xlabel("Average Distance [AU]")
ax.set_ylabel("Number of Transiting Exoplanets")
ax.vlines(1.0,0,500,colors='g', linestyles='dashed' )
ax.vlines(0.72,0,500,colors='g', linestyles='dashed' )
ax.vlines(0.39,0,500,colors='g', linestyles='dashed' )
ax.vlines(1.52,0,500,colors='g', linestyles='dashed' )
ax.vlines(5.2,0,500,colors='g', linestyles='dashed' )
ax.hist(ExoData['A'][mask], bins=100);
#ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
mask = np.where(ExoData['A'] > 0.0001)
ax.set_xlabel("Average Distance [AU]")
ax.set_ylabel("Number of Transiting Exoplanets")
ax.vlines(1.0,0,500,colors='g', linestyles='dashed' )
ax.vlines(0.72,0,500,colors='g', linestyles='dashed' )
ax.vlines(0.39,0,500,colors='g', linestyles='dashed' )
ax.vlines(1.52,0,500,colors='g', linestyles='dashed' )
ax.vlines(5.2,0,500,colors='g', linestyles='dashed' )
ax.hist(ExoData['A'][mask], bins=100);
In [ ]:
fig.savefig('ExoDist.png', bbox_inches='tight')
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0,400)
#ax.set_xscale('log')
ax.set_xlim(0.025,1.7)
#ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
mask = np.where(ExoData['R'] > 0.0001)
ax.set_xlabel("Radius [Jupiter]")
ax.set_ylabel("Number of Transiting Exoplanets")
ax.vlines(1.0,0,500,colors='g', linestyles='dashed' )
ax.vlines(0.0892140244,0,500,colors='g', linestyles='dashed' )
ax.hist(ExoData['R'][mask], bins=100);
In [ ]:
TNOData = QTable.read('TNO_Date.csv', format='ascii.csv')
In [ ]:
TNOData[1:5]
In [ ]:
Bins = np.arange(1990,2018,1)
In [ ]:
Bins
In [ ]:
Width = (Bins[1:] - Bins[:-1])
In [ ]:
year = TNOData['year']
In [ ]:
Hist,BinEdge = np.histogram(year, bins=Bins)
CHist = np.cumsum(Hist) + 1
for i,j in enumerate(CHist):
print(j, Bins[i])
In [ ]:
fig, ax = plt.subplots(1,1)
fig.set_size_inches(16,9)
#ax.grid(b=True, which='major')
#ax.set_ylim(0,200)
ax.set_xlim(1991,2017)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
#ax.xaxis.set_tick_params('minor',width=2,length=0)
#ax.get_xaxis().tick_bottom()
#ax.get_yaxis().tick_left()
ax.set_xlabel('Year')
ax.set_ylabel('Cumulative Number of KBOs')
ax.bar(Bins[:-1], CHist, width=Width, color='c', edgecolor='k');
In [ ]:
fig.savefig('TNODiscovery.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
NepRes = [39.4,47.72,62.52]
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0,320)
#ax.set_xscale('log')
ax.set_xlim(30,60)
#ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Average Distance [AU]")
ax.set_ylabel("Number of TNO's")
ax.vlines(39.4,0,500,colors='g', linestyles='dashed' )
ax.vlines(47.72,0,500,colors='g', linestyles='dashed' )
ax.vlines(62.52,0,500,colors='g', linestyles='dashed' )
#ax.vlines(1.52,0,500,colors='g', linestyles='dashed' )
#ax.vlines(5.2,0,500,colors='g', linestyles='dashed' )
mask = np.where(TNOData['a'] < 100)
ax.hist(TNOData['a'][mask], bins=100, color='c', edgecolor='k');
In [ ]:
fig.savefig('TNO_A.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
n_half = np.arange(0,11,1)
In [ ]:
n_half
In [ ]:
percent_left = 100 / (2 ** n_half)
In [ ]:
percent_left
In [ ]:
percent_right = (100 - (100 / (2 ** n_half))) + percent_left
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
#ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0,105)
#ax.set_xscale('log')
ax.set_xlim(-0.5,11)
#ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Number of half-lives")
ax.set_ylabel("% Element Remaining")
ax.bar(n_half, percent_left, align='center', alpha=1.0, color = 'b')
ax.bar(n_half, percent_right, align='center', alpha=0.35, color = "r");
In [ ]:
fig.savefig('RadioDecay_Lin.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0.05,120)
#ax.set_xscale('log')
ax.set_xlim(-0.5,11)
ax.yaxis.set_major_formatter(formatter)
#ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Number of half-lives")
ax.set_ylabel("% Element Remaining")
ax.bar(n_half, percent_left, align='center', alpha=1.0, color = 'b')
ax.bar(n_half, percent_right, align='center', alpha=0.35, color = "r");
In [ ]:
fig.savefig('RadioDecay_Log.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
AtmEsc = QTable.read('AtmEscape_Data.csv', format='ascii.csv')
In [ ]:
AtmEsc
In [ ]:
temp = np.logspace(0.0, 3.0, num=100)
In [ ]:
def gas_line(mass,temp):
speed = ( 157 / 1000 * np.sqrt ( temp / mass ))
return speed
In [ ]:
fig,ax = plt.subplots(1,1) # One window
fig.set_size_inches(16,9) # (width,height) - letter paper landscape
fig.tight_layout() # Make better use of space on plot
ax.set_yscale('log')
#ax.invert_yaxis()
ax.set_ylim(0.1,8)
ax.set_xscale('log')
ax.set_xlim(30,1000)
ax.yaxis.set_major_formatter(formatter)
ax.xaxis.set_major_formatter(formatter)
#ax.xaxis.set_minor_formatter(formatter)
ax.set_xlabel("Temperature [K]")
ax.set_ylabel("RMS Speed [km/s]")
ax.plot(temp,gas_line(1,temp), color="0.5",marker="None",linestyle="--",linewidth=4)
ax.plot(temp,gas_line(4,temp), color="0.5",marker="None",linestyle="--",linewidth=4)
ax.plot(temp,gas_line(18,temp),color="0.5",marker="None",linestyle="--",linewidth=4)
ax.plot(temp,gas_line(32,temp),color="0.5",marker="None",linestyle="--",linewidth=4)
ax.plot(temp,gas_line(46,temp),color="0.5",marker="None",linestyle="--",linewidth=4)
ax.scatter(AtmEsc['temp'],0.11 * AtmEsc['vesc'],color=AtmEsc['color'],marker="o",s=300);
#ax.scatter(AtmEsc['temp'][2],0.11 * AtmEsc['vesc'][2],color=AtmEsc['color'][2],marker="o",s=300);
In [ ]:
fig.savefig('Speed_Earth.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
def Maxwell(T):
v = np.arange(0,2000,1) * (u.m / u.s)
m = 32 * const.m_p
a = np.sqrt(const.k_B * T / m)
f1 = np.sqrt(2 / np.pi) * ( v**2 / a**3)
f2 = np.exp(-(v**2) / (2 * a**2))
return f1 * f2 * v
In [ ]:
fig, ax = plt.subplots(1,1)
fig.set_size_inches(16,9)
fig.tight_layout
#ax.set_ylim(0,1.0)
ax.set_xlim(0,1500)
ax.set_xlabel('Speed of Molecules [m/s]')
ax.set_ylabel('Number of Molecules')
T1 = Maxwell(T = 173 * u.K).value # -100C
T2 = Maxwell(T = 293 * u.K).value # 20C
T3 = Maxwell(T = 773 * u.K).value # 500C
v = np.arange(0,2000,1) * (u.m / u.s)
ax.plot(v, T1*1000, color='r', linewidth=5, linestyle= "-", label = "-100 C")
ax.plot(v, T2*750, color='g', linewidth=5, linestyle= "-", label = " 20 C")
ax.plot(v, T3*500, color='b', linewidth=5, linestyle= "-", label = " 500 C")
ax.legend(loc=0);
In [ ]:
fig.savefig('Speed_T.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
def Maxwell_MT(T,M):
v = np.arange(0,10000,1) * (u.m / u.s)
m = M * const.m_p
a = np.sqrt(const.k_B * T / m)
f1 = np.sqrt(2 / np.pi) * ( v**2 / a**3)
f2 = np.exp(-(v**2) / (2 * a**2))
return f1 * f2 * v
In [ ]:
fig, ax = plt.subplots(1,1)
fig.set_size_inches(16,9)
fig.tight_layout
#ax.set_ylim(0,1.0)
ax.set_xlim(0,5000)
ax.set_xlabel('Speed of Molecules [m/s]')
ax.set_ylabel('Number of Molecules')
T1 = Maxwell_MT(T = 173 * u.K,M = 1).value # -100C
T2 = Maxwell_MT(T = 173 * u.K,M = 4).value # 20C
T3 = Maxwell_MT(T = 173 * u.K,M = 32).value # 500C
v = np.arange(0,10000,1) * (u.m / u.s)
ax.plot(v, T1*1000, color='r', linewidth=5, linestyle= "-", label = "H")
ax.plot(v, T2*1000, color='g', linewidth=5, linestyle= "-", label = "He")
ax.plot(v, T3*1000, color='b', linewidth=5, linestyle= "-", label = "O")
ax.legend(loc=0);
In [ ]:
fig.savefig('Speed_M.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]:
fig, ax = plt.subplots(1,1)
fig.set_size_inches(16,9)
fig.tight_layout
#ax.set_ylim(0,1.0)
ax.set_xlim(0,5000)
ax.set_xlabel('Speed of Molecules [m/s]')
ax.set_ylabel('Number of Molecules')
T1 = Maxwell_MT(T = 173 * u.K,M = 1).value # -100C
T2 = Maxwell_MT(T = 173 * u.K,M = 4).value # 20C
T3 = Maxwell_MT(T = 173 * u.K,M = 32).value # 500C
v = np.arange(0,10000,1) * (u.m / u.s)
ax.plot(v, T1*1000, color='r', linewidth=5, linestyle= "-", label = "H")
#ax.plot(v, T2*1000, color='g', linewidth=5, linestyle= "-", label = "He")
#ax.plot(v, T3*1000, color='b', linewidth=5, linestyle= "-", label = "O")
#ax.legend(loc=0);
In [ ]:
fig.savefig('Speed_One.png', dpi=200, bbox_inches='tight',pad_inches=0.05)
In [ ]: