{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# read in our usual things\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import ipywidgets" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# reading in a file reader for our simulation data\n", "from hermite_library import read_hermite_solution_from_file" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# use this data reader to read in Kepler 11 data\n", "planet_file = 'data/Kepler-11-savedSim.txt'\n", "\n", "# reading in time, energy, postion (3d), velocity (3d)\n", "t_h, E_h, r_h, v_h = read_hermite_solution_from_file(planet_file)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(7, 3, 8800)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r_h.shape\n", "# number of bodies (star + planets), in 3D space, 8800 time steps" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# read in planet dataset too\n", "planets = pd.read_csv('https://raw.githubusercontent.com/jnaiman/csci-p-14110_su2020/master/lesson08/planets_2020.06.22_10.10.17.csv', \n", " comment=\"#\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rowidpl_hostnamepl_letterpl_namepl_discmethodpl_controvflagpl_pnumpl_orbperpl_orbpererr1pl_orbpererr2...st_bmyst_bmyerrst_bmylimst_m1st_m1errst_m1limst_c1st_c1errst_c1limst_colorn
0111 Comb11 Com bRadial Velocity01326.030000.32-0.32...NaNNaNNaNNaNNaNNaNNaNNaNNaN7.0
1211 UMib11 UMi bRadial Velocity01516.219973.20-3.20...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
2314 Andb14 And bRadial Velocity01185.840000.23-0.23...NaNNaNNaNNaNNaNNaNNaNNaNNaN7.0
3414 Herb14 Her bRadial Velocity011773.400022.50-2.50...0.5370.0010.00.3660.0020.00.4380.0060.09.0
4516 Cyg Bb16 Cyg B bRadial Velocity01798.500001.00-1.00...0.4180.0030.00.2220.0030.00.3510.0030.017.0
\n", "

5 rows × 356 columns

\n", "
" ], "text/plain": [ " rowid pl_hostname pl_letter pl_name pl_discmethod pl_controvflag \\\n", "0 1 11 Com b 11 Com b Radial Velocity 0 \n", "1 2 11 UMi b 11 UMi b Radial Velocity 0 \n", "2 3 14 And b 14 And b Radial Velocity 0 \n", "3 4 14 Her b 14 Her b Radial Velocity 0 \n", "4 5 16 Cyg B b 16 Cyg B b Radial Velocity 0 \n", "\n", " pl_pnum pl_orbper pl_orbpererr1 pl_orbpererr2 ... st_bmy st_bmyerr \\\n", "0 1 326.03000 0.32 -0.32 ... NaN NaN \n", "1 1 516.21997 3.20 -3.20 ... NaN NaN \n", "2 1 185.84000 0.23 -0.23 ... NaN NaN \n", "3 1 1773.40002 2.50 -2.50 ... 0.537 0.001 \n", "4 1 798.50000 1.00 -1.00 ... 0.418 0.003 \n", "\n", " st_bmylim st_m1 st_m1err st_m1lim st_c1 st_c1err st_c1lim st_colorn \n", "0 NaN NaN NaN NaN NaN NaN NaN 7.0 \n", "1 NaN NaN NaN NaN NaN NaN NaN 5.0 \n", "2 NaN NaN NaN NaN NaN NaN NaN 7.0 \n", "3 0.0 0.366 0.002 0.0 0.438 0.006 0.0 9.0 \n", "4 0.0 0.222 0.003 0.0 0.351 0.003 0.0 17.0 \n", "\n", "[5 rows x 356 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are going to plot (in 3D) our simulated data, but we want to make aesthetical choices about how the planets/star will look based on the observed data.\n", "\n", "Select (based on a boolean mask) just the Kepler-11 data." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 11 Com\n", "1 11 UMi\n", "2 14 And\n", "3 14 Her\n", "4 16 Cyg B\n", " ... \n", "4159 tau Gem\n", "4160 ups And\n", "4161 ups And\n", "4162 ups And\n", "4163 xi Aql\n", "Name: pl_hostname, Length: 4164, dtype: object" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets['pl_hostname']" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rowidpl_hostnamepl_letterpl_namepl_discmethodpl_controvflagpl_pnumpl_orbperpl_orbpererr1pl_orbpererr2...st_bmyst_bmyerrst_bmylimst_m1st_m1errst_m1limst_c1st_c1errst_c1limst_colorn
15461547Kepler-11bKepler-11 bTransit0610.30390.0006-0.0010...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
15471548Kepler-11cKepler-11 cTransit0613.02410.0013-0.0008...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
15481549Kepler-11dKepler-11 dTransit0622.68450.0009-0.0009...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
15491550Kepler-11eKepler-11 eTransit0631.99960.0008-0.0012...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
15501551Kepler-11fKepler-11 fTransit0646.68880.0027-0.0032...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
15511552Kepler-11gKepler-11 gTransit06118.38070.0010-0.0006...NaNNaNNaNNaNNaNNaNNaNNaNNaN5.0
\n", "

6 rows × 356 columns

\n", "
" ], "text/plain": [ " rowid pl_hostname pl_letter pl_name pl_discmethod pl_controvflag \\\n", "1546 1547 Kepler-11 b Kepler-11 b Transit 0 \n", "1547 1548 Kepler-11 c Kepler-11 c Transit 0 \n", "1548 1549 Kepler-11 d Kepler-11 d Transit 0 \n", "1549 1550 Kepler-11 e Kepler-11 e Transit 0 \n", "1550 1551 Kepler-11 f Kepler-11 f Transit 0 \n", "1551 1552 Kepler-11 g Kepler-11 g Transit 0 \n", "\n", " pl_pnum pl_orbper pl_orbpererr1 pl_orbpererr2 ... st_bmy \\\n", "1546 6 10.3039 0.0006 -0.0010 ... NaN \n", "1547 6 13.0241 0.0013 -0.0008 ... NaN \n", "1548 6 22.6845 0.0009 -0.0009 ... NaN \n", "1549 6 31.9996 0.0008 -0.0012 ... NaN \n", "1550 6 46.6888 0.0027 -0.0032 ... NaN \n", "1551 6 118.3807 0.0010 -0.0006 ... NaN \n", "\n", " st_bmyerr st_bmylim st_m1 st_m1err st_m1lim st_c1 st_c1err \\\n", "1546 NaN NaN NaN NaN NaN NaN NaN \n", "1547 NaN NaN NaN NaN NaN NaN NaN \n", "1548 NaN NaN NaN NaN NaN NaN NaN \n", "1549 NaN NaN NaN NaN NaN NaN NaN \n", "1550 NaN NaN NaN NaN NaN NaN NaN \n", "1551 NaN NaN NaN NaN NaN NaN NaN \n", "\n", " st_c1lim st_colorn \n", "1546 NaN 5.0 \n", "1547 NaN 5.0 \n", "1548 NaN 5.0 \n", "1549 NaN 5.0 \n", "1550 NaN 5.0 \n", "1551 NaN 5.0 \n", "\n", "[6 rows x 356 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# subset the planets dataset based on having the hostname be Kepler-11\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11']" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
1546Kepler-11bKepler-11 b0.0060.161
1547Kepler-11cKepler-11 c0.0090.256
1548Kepler-11dKepler-11 d0.0230.278
1549Kepler-11eKepler-11 e0.0250.374
1550Kepler-11fKepler-11 f0.0060.222
1551Kepler-11gKepler-11 g0.0790.297
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "1546 Kepler-11 b Kepler-11 b 0.006 0.161\n", "1547 Kepler-11 c Kepler-11 c 0.009 0.256\n", "1548 Kepler-11 d Kepler-11 d 0.023 0.278\n", "1549 Kepler-11 e Kepler-11 e 0.025 0.374\n", "1550 Kepler-11 f Kepler-11 f 0.006 0.222\n", "1551 Kepler-11 g Kepler-11 g 0.079 0.297" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# only interested in a subset of columns -- planet name, letter, mass, etc\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Setting up our directory/file structure\n", "\n", "So Python will know where to look for things" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "# 1. set the path to where the generic planet files are\n", "generic_dir = './genericPlanetFiles/'" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# 2. tell Python where to look for a .py file\n", "#. Appending Pythons \"search\" path\n", "from sys import path" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['/Users/jillnaiman/csci-p-14110_su2020/lesson10',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python37.zip',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/lib-dynload',\n", " '',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/site-packages',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/site-packages/IPython/extensions',\n", " '/Users/jillnaiman/.ipython']" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path # this is where Python is looking for library files with a .py at the end of them" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "path.append(generic_dir) # adding to this search file path" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['/Users/jillnaiman/csci-p-14110_su2020/lesson10',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python37.zip',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/lib-dynload',\n", " '',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/site-packages',\n", " '/opt/anaconda3/envs/myNewEnv2/lib/python3.7/site-packages/IPython/extensions',\n", " '/Users/jillnaiman/.ipython',\n", " './genericPlanetFiles/']" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path # we can see genericPlanetFiles directory is now in this search list" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "from make3dplanets import make3dplanets" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_radj
15460.161
15470.256
15480.278
15490.374
15500.222
15510.297
\n", "
" ], "text/plain": [ " pl_radj\n", "1546 0.161\n", "1547 0.256\n", "1548 0.278\n", "1549 0.374\n", "1550 0.222\n", "1551 0.297" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# grabbing the radii information for Kepler-11\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']]\n", "# .loc[row, column]" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0.161],\n", " [0.256],\n", " [0.278],\n", " [0.374],\n", " [0.222],\n", " [0.297]])" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# start formatting by grabbing just the values (w/o the fancy Pandas formatting)\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(6, 1)" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.shape" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.161, 0.256, 0.278, 0.374, 0.222, 0.297])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# continuing formatting and making this \"list\" of numbers into just one array\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.ravel() # .flatten()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(6,)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.ravel().shape" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "# save this formatted data into a radii vector\n", "radii = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.ravel()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.161, 0.256, 0.278, 0.374, 0.222, 0.297])" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii # jupiter radii" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Based on prior knowledge we know that the star's radii (its 3D information) has to come last.\n", "\n", "We have to add in the star's radius information as well." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
st_rad
15461.06
15471.06
15481.06
15491.06
15501.06
15511.06
\n", "
" ], "text/plain": [ " st_rad\n", "1546 1.06\n", "1547 1.06\n", "1548 1.06\n", "1549 1.06\n", "1550 1.06\n", "1551 1.06" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']] # solar radii" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[1.06],\n", " [1.06],\n", " [1.06],\n", " [1.06],\n", " [1.06],\n", " [1.06]])" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# take off fancy Pandas formatting\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']].values" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([1.06])" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# only need the one radius measurement\n", "planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']].values[0]" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "star_radius = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']].values[0]" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.161, 0.256, 0.278, 0.374, 0.222, 0.297])" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# append this star_radius to our general radii array\n", "# append using a NumPy function because these are NumPy arrays\n", "radii = np.append(radii, star_radius)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.161, 0.256, 0.278, 0.374, 0.222, 0.297, 1.06 ])" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii\n", "# all but the last radii are in Jupiter radii\n", "# last radius is in solar radii" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have to define a folder where we are going to store our 3D planet+host star files." ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "out_planet_dir = './outPlanets/'" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "SystemName = 'kepler11_take1' # unique file where this particular planet system will be stored\n", "#systemName" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll start with just one time step (and go from there)." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "Nplot = 0 # the first time step -- initial conditions for our data" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Going to overwrite files in ./outPlanets/kepler11_take1/\n", "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n", "no colors/textures specified -- generating random colors!\n" ] } ], "source": [ "# put everything together to make our first system\n", "fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, generic_dir, Nplot=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because we can't see our system we're going to \"fudge\" our radii:" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([16.1 , 25.6 , 27.8 , 37.4 , 22.2 , 29.7 , 1.06])" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.ravel()*100\n", "star_radius = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']].values[0]\n", "radii = np.append(radii, star_radius)\n", "radii" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "# redo making these planets\n", "SystemName = 'kepler11_take2' # unique file where this particular planet system will be stored" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Going to overwrite files in ./outPlanets/kepler11_take2/\n", "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n", "no colors/textures specified -- generating random colors!\n" ] } ], "source": [ "fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, generic_dir, Nplot=0)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
4046WASP-47bWASP-47 b1.142431.127
4048WASP-47dWASP-47 d0.041220.319
4049WASP-47eWASP-47 e0.021490.161
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "4046 WASP-47 b WASP-47 b 1.14243 1.127\n", "4048 WASP-47 d WASP-47 d 0.04122 0.319\n", "4049 WASP-47 e WASP-47 e 0.02149 0.161" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# looking at WASP-47 system\n", "planets.loc[planets['pl_hostname'] == 'WASP-47', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']].dropna()" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "SystemName = 'wasp47_take1'" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([112.7 , 31.9 , 16.1 , 1.14])" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii = planets.loc[planets['pl_hostname'] == 'WASP-47', ['pl_radj']].dropna().values.ravel()*100\n", "star_radius = planets.loc[planets['pl_hostname'] == 'WASP-47', ['st_rad']].dropna().values[0]\n", "radii = np.append(radii, star_radius)\n", "radii" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Going to overwrite files in ./outPlanets/wasp47_take1/\n", "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n", "no colors/textures specified -- generating random colors!\n" ] } ], "source": [ "fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, generic_dir, Nplot=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Textures and texture mapping\n", "\n", "Pick some textures for our planets." ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
1546Kepler-11bKepler-11 b0.0060.161
1547Kepler-11cKepler-11 c0.0090.256
1548Kepler-11dKepler-11 d0.0230.278
1549Kepler-11eKepler-11 e0.0250.374
1550Kepler-11fKepler-11 f0.0060.222
1551Kepler-11gKepler-11 g0.0790.297
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "1546 Kepler-11 b Kepler-11 b 0.006 0.161\n", "1547 Kepler-11 c Kepler-11 c 0.009 0.256\n", "1548 Kepler-11 d Kepler-11 d 0.023 0.278\n", "1549 Kepler-11 e Kepler-11 e 0.025 0.374\n", "1550 Kepler-11 f Kepler-11 f 0.006 0.222\n", "1551 Kepler-11 g Kepler-11 g 0.079 0.297" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'Kepler-11', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']].dropna()" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "# Host star mass is 1.06 Solar masses -- just a little bigger than our sun" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In theory we would want to look at the ratio of densities (mass/radius^3) -- this will tell us if we have gas planets or rocky planets.\n", "\n", "We can make choices based on mass or radii -- as long as we are clear about what we are doing and why." ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "# approximate textures: Earth, Uranus, Uranus, Uranus, Earth, Saturn, Sun\n", "planet_textures = ['earth_1200.jpg', \n", " 'uranus_1024.jpg',\n", " 'uranus_1024.jpg',\n", " 'uranus_1024.jpg',\n", " 'earth_1200.jpg',\n", " 'saturn_1024.jpg',\n", " 'sun_texture1.jpg']" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "# overwrite take2 directory\n", "SystemName = 'kepler11_take3' # unique file where this particular planet system will be stored" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([16.1 , 25.6 , 27.8 , 37.4 , 22.2 , 29.7 , 1.06])" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "radii = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['pl_radj']].values.ravel()*100\n", "star_radius = planets.loc[planets['pl_hostname'] == 'Kepler-11', ['st_rad']].values[0]\n", "radii = np.append(radii, star_radius)\n", "radii" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n" ] } ], "source": [ "fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, \n", " generic_dir, Nplot=0,\n", " texture_file = planet_textures)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making 3D animations\n", "\n", "Start with just 2 frames of our animation and use that to debug and then we can go from there." ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(7, 3, 8800)" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r_h.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We could play some games with downsampling, but we are going to just (right now) choose 2 particular time steps." ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[5, 100]" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Nplots = [5,100] # 6th time step and the 101 timestep\n", "#Nplots = np.arange(5,100,5)\n", "Nplots" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "SystemName = 'kepler11-movie'" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "dt_movie = 0.5 # seconds -- the time between showing different \"frames\" of my movie" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [], "source": [ "# loop and create a bunch of obj files for each of our frames\n", "# save the info we need for the sketchfab.timeframe file during this loop\n", "# save the info to a file called sketchfab.timeframe" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Going to overwrite files in ./outPlanets/kepler11-movie/\n", "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n", "Assuming radii are in Jupiter units except for the last particle which should have solar units, distances in AU... if not things are going to look weird!\n" ] } ], "source": [ "time_list = [] # store info for the sketcfab.timeframe file as a list\n", "\n", "# fancy loop\n", "for iplot, Nplot in enumerate(Nplots): # counting up the number of the file we have AND our selected timestep\n", " #print(iplot, Nplot)\n", " # this call here is creating the obj files\n", " fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, \n", " generic_dir, Nplot=Nplot,\n", " texture_file = planet_textures, \n", " fnum=iplot)\n", " # have to save information for the sketchfab.timeframe file\n", " time_list.append( str(dt_movie) + ' ' + fname + '\\n')" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['0.5 kepler11-movie0000.obj\\n', '0.5 kepler11-movie0001.obj\\n']" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "time_list" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "# save the sketchfab.timeframe file\n", "# make sure I'm saving to the correct location\n", "timeframe_filename = out_planet_dir + SystemName + '/sketchfab.timeframe' # defining the name of the file\n", "\n", "ftime = open(timeframe_filename,'w') # opening the file to write\n", "\n", "for tobj in time_list: # looping over our saved information\n", " ftime.write(tobj) # printing to that file\n", " \n", "# close file\n", "ftime.close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Trying to make a 10-step one:" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Nplots = [5,100] # 6th time step and the 101 timestep\n", "Nplots = np.arange(0,100,10) # start, stop, step -- first 100 timesteps of the simulation in steps of 10\n", "#Nplots = np.arange(0,8800,100) # start, stop, step - full sim, every 100 timesteps\n", "len(Nplots)" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90])" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Nplots" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [], "source": [ "SystemName = 'kepler11-movie-10step'" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [], "source": [ "time_list = [] # store info for the sketcfab.timeframe file as a list\n", "\n", "# fancy loop\n", "for iplot, Nplot in enumerate(Nplots): # counting up the number of the file we have AND our selected timestep\n", " #print(iplot, Nplot)\n", " # this call here is creating the obj files\n", " fname = make3dplanets(SystemName, r_h, radii, out_planet_dir, \n", " generic_dir, Nplot=Nplot,\n", " texture_file = planet_textures, \n", " fnum=iplot, verbose=False)\n", " # have to save information for the sketchfab.timeframe file\n", " time_list.append( str(dt_movie) + ' ' + fname + '\\n')" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [], "source": [ "# make sure I'm saving to the correct location\n", "timeframe_filename = out_planet_dir + SystemName + '/sketchfab.timeframe' # defining the name of the file\n", "\n", "ftime = open(timeframe_filename,'w') # opening the file to write\n", "\n", "for tobj in time_list: # looping over our saved information\n", " ftime.write(tobj) # printing to that file\n", " \n", "# close file\n", "ftime.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
1505Kepler-107bKepler-107 b0.011040.137
1506Kepler-107cKepler-107 c0.029540.142
1507Kepler-107dKepler-107 d0.011960.077
1508Kepler-107eKepler-107 e0.027060.259
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "1505 Kepler-107 b Kepler-107 b 0.01104 0.137\n", "1506 Kepler-107 c Kepler-107 c 0.02954 0.142\n", "1507 Kepler-107 d Kepler-107 d 0.01196 0.077\n", "1508 Kepler-107 e Kepler-107 e 0.02706 0.259" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'Kepler-107', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']]\n", "# Kepler 107" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "55_Cnc-savedSim.txt HD_215152-savedSim.txt Kepler-411-savedSim.txt\r\n", "DMPP-1-savedSim.txt HD_219134-savedSim.txt Kepler-62-savedSim.txt\r\n", "GJ_3293-savedSim.txt HD_34445-savedSim.txt Kepler-79-savedSim.txt\r\n", "GJ_667_C-savedSim.txt HD_40307-savedSim.txt Kepler-80-savedSim.txt\r\n", "GJ_676_A-savedSim.txt K2-266-savedSim.txt Kepler-82-savedSim.txt\r\n", "GJ_876-savedSim.txt K2-285-savedSim.txt TRAPPIST-1-savedSim.txt\r\n", "HD_10180-savedSim.txt KOI-94-savedSim.txt WASP-47-savedSim.txt\r\n", "HD_141399-savedSim.txt Kepler-107-savedSim.txt myPlanetarySystem.txt\r\n", "HD_160691-savedSim.txt Kepler-11-savedSim.txt tau_Cet-savedSim.txt\r\n", "HD_20781-savedSim.txt Kepler-20-savedSim.txt\r\n", "HD_20794-savedSim.txt Kepler-32-savedSim.txt\r\n" ] } ], "source": [ "!ls ../lesson09/data" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
3905TRAPPIST-1bTRAPPIST-1 b0.002670.097
3906TRAPPIST-1cTRAPPIST-1 c0.004340.094
3907TRAPPIST-1dTRAPPIST-1 d0.001290.069
3908TRAPPIST-1eTRAPPIST-1 e0.001950.082
3909TRAPPIST-1fTRAPPIST-1 f0.002140.093
3910TRAPPIST-1gTRAPPIST-1 g0.004220.101
3911TRAPPIST-1hTRAPPIST-1 hNaN0.067
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "3905 TRAPPIST-1 b TRAPPIST-1 b 0.00267 0.097\n", "3906 TRAPPIST-1 c TRAPPIST-1 c 0.00434 0.094\n", "3907 TRAPPIST-1 d TRAPPIST-1 d 0.00129 0.069\n", "3908 TRAPPIST-1 e TRAPPIST-1 e 0.00195 0.082\n", "3909 TRAPPIST-1 f TRAPPIST-1 f 0.00214 0.093\n", "3910 TRAPPIST-1 g TRAPPIST-1 g 0.00422 0.101\n", "3911 TRAPPIST-1 h TRAPPIST-1 h NaN 0.067" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'TRAPPIST-1', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']]\n" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pl_hostnamepl_letterpl_namepl_bmassjpl_radj
3905TRAPPIST-1bTRAPPIST-1 b0.002670.097
3906TRAPPIST-1cTRAPPIST-1 c0.004340.094
3907TRAPPIST-1dTRAPPIST-1 d0.001290.069
3908TRAPPIST-1eTRAPPIST-1 e0.001950.082
3909TRAPPIST-1fTRAPPIST-1 f0.002140.093
3910TRAPPIST-1gTRAPPIST-1 g0.004220.101
\n", "
" ], "text/plain": [ " pl_hostname pl_letter pl_name pl_bmassj pl_radj\n", "3905 TRAPPIST-1 b TRAPPIST-1 b 0.00267 0.097\n", "3906 TRAPPIST-1 c TRAPPIST-1 c 0.00434 0.094\n", "3907 TRAPPIST-1 d TRAPPIST-1 d 0.00129 0.069\n", "3908 TRAPPIST-1 e TRAPPIST-1 e 0.00195 0.082\n", "3909 TRAPPIST-1 f TRAPPIST-1 f 0.00214 0.093\n", "3910 TRAPPIST-1 g TRAPPIST-1 g 0.00422 0.101" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "planets.loc[planets['pl_hostname'] == 'TRAPPIST-1', \n", " ['pl_hostname', 'pl_letter', 'pl_name', 'pl_bmassj', 'pl_radj']].dropna()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }