0% found this document useful (0 votes)
15 views7 pages

Exoplanets Python Lab

Uploaded by

Julia Joseph
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Exoplanets Python Lab

Uploaded by

Julia Joseph
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

‭ ame: _______________‬

N
‭Date: ________________‬
‭Lab (M/T): ___________‬

‭Exoplanets Lab‬
‭_____________________________________________________________________________‬

‭Part 1: The Radial Velocity Method‬


‭ cience objective:‬‭find the period of the orbital‬‭motion.‬
S
‭Computational objective:‬‭Beginners‬‭: data visualization,‬‭plotting;‬‭Intermediate‬‭: data analysis:‬
‭goodness of fit;‬‭Advanced‬‭: fitting and exploring the‬‭parameter space to find the best-fit‬
‭parameters.‬

I‭ n this section of the lab, you will use python to create plots of radial velocity versus time for a‬
‭known exoplanet system, and find its orbital period. The data set you will be using is‬
‭‘51_Peg.csv’. The goal of this lab is to familiarize yourself with the coding language Python -‬
‭which is widely used in Astronomy for handling data, making calculations, plotting, running‬
‭simulations, etc.‬

‭ here are 3 versions of this part of the lab, depending on your comfort level with the coding‬
T
‭language Python, and your familiarity with numerical techniques (like fitting functions). Pick‬
‭whichever version you feel the most comfortable with. In all cases, you will open a python‬
‭notebook using Google Colab (a Google Documents/Sheets/Slides version of coding notebooks).‬
‭If you are a strong programmer but primarily use a different language, you can take this‬
‭opportunity to learn some Python. If you have plenty of experience with numerical techniques,‬
‭you can work through the most challenging version of the activity.‬

I‭ f you create a new notebook or use Jupyter Notebooks instead, please indicate at the beginning‬
‭of your code which version you are doing.‬

‭ on’t forget that you’ve done some coding in previous labs. While each project is unique, code‬
D
‭snippets are not. The best code is made of pieces you can copy, and use somewhere else. Start by‬
‭opening up those previous notebooks so you can use them.‬
‭1 - Beginner‬
‭(a) Review your past work‬
1‭ .‬ S ‭ et yourself a 10 minute timer so you don’t spend too long on this part.‬
‭2.‬ ‭Open the previous notebook.‬
‭a.‬ ‭Identify the parts you can copy directly, like loading the packages or importing‬
‭files.‬
‭b.‬ ‭Look for the skills used in each, like making a graph, fitting a function, and doing‬
‭calculations. You may want to take a moment to make yourself a note of which‬
‭section to find which skill.‬
‭(b) Analysis of exoplanet data‬
‭3.‬ ‭Make a‬‭copy‬‭of the‬‭beginner notebook‬‭. It has steps matching this procedure to guide you,‬
‭but no code.‬
‭4.‬ ‭Add the code to load in the applicable packages and data (‘51_Peg.csv’) into your python‬
‭notebook.‬
‭5.‬ ‭Save each of the columns of data as their own named data set.‬
‭6.‬ ‭Make a scatter plot (just points, no connecting line) of radial velocity (y-axis) versus date‬
‭(x-axis). Make sure to include x and y-labels‬‭with‬‭units‬‭, as well as a title. You’ll notice‬
‭that the date is in units of‬ ‭Reduced Julian Days‬‭(JD)‬‭. 2450000 was subtracted from the‬
‭absolute date in order to express the values in more convenient numbers.‬
‭7.‬ ‭Recall from the intro that an exoplanet should induce a sinusoidal variation in the radial‬
‭velocity of the star. In your plot, there should be variation visible, but it should be‬
‭difficult to tell if it is sinusoidal, or what the period is, because the observations were‬
‭essentially random. Recall also that the “theoretical expectation” is a sine function with‬
‭some period and amplitude. A fitting code is usually used in order to find the best‬
‭solution, or the closest match between the data and the theoretical expectation from the‬
‭function, and find the best-fit period. We will do‬‭a simplified version of this type of‬
‭analysis‬‭; To find the period, we will try a few guesses‬‭and check by eye to see if the data‬
‭match the guess. For 51 Peg, we will examine two possible “guesses” for the period of‬
‭the planet: 4.2 days, and 6.7 days. To make it easier to see which guess is better, we want‬
‭to “fold” our data so all points fall within one orbital “phase”. For example, if the date of‬
‭the observation is 7.3, and the period being tested is 4.2, the “phase date” of this‬
‭datapoint is 7.3 - 4.2 = 3.1 days after the beginning of the cycle. Note the 3.05 is less than‬
‭the period being tested. If the observation date is 12.2, folding it once gives 8.0. We need‬
‭to fold it again, giving a phased date of 3.8 days after the beginning of the cycle.‬
‭Mathematically, this is the same as dividing by the proposed period and using the‬
‭remainder, so:‬
‭a.‬ ‭Calculate the phased date by dividing the date of each observation by the period‬
‭guess, and recording the‬‭remainder‬‭. Tip: Python has‬‭a math function for this.‬
‭Replace the division command with ‘%’.‬
‭b.‬ M ‭ ake two scatter plots of the radial velocity (y-axis) versus the phased date‬
‭(x-axis) - i.e. two sets of points, one for each phased date column.‬
‭c.‬ ‭Make sure to include x and y-labels‬‭with units‬‭, as‬‭well as a title that specifies‬
‭which data set refers to which period.‬
‭8.‬ ‭Of course only one of these guesses is correct. To tell which it is, look and see which set‬
‭of data gives a nice sinusoidal curve in your plot. Congratulations, this is the‬
‭unmistakable signature of an exoplanet! Based on your data, which is the correct period‬
‭for the planet?‬
‭(c) Check for goodness of fit‬
‭9.‬ ‭Let’s create a sine function‬
‭a.‬ ‭Write a function to calculate a sine function:‬‭𝑦‬‭‬ = ‭‭𝐴 ‬ ‬‭‭𝑠‬ 𝑖𝑛‬(ν‭𝑥‬) ‭, where A is the‬
‭amplitude,‬ν ‭is the frequency, and x is the input‬‭x-value. In your function, A,‬ν‭,‬
‭and x should be variables that you can change.‬
‭b.‬ ‭Test out your function: using A=15,‬ ν‭=3, and x=10,‬‭what value do you calculate‬
‭with your function? Calculate the answer for the same values analytically‬
‭(meaning, on paper, or calculator) and check that the code gives the expected‬
‭answer. If not, you have discovered a bug! Fix it!‬
‭10.‬‭Take a look at your plot of the radial velocity (y-axis) versus the correct phase date‬
‭(x-axis).‬
‭a.‬ ‭What is the amplitude?‬
‭b.‬ ‭What is the period in units of days?‬
‭c.‬ ‭What is the frequency (frequency = 2π/period)?‬
‭11.‬‭Create an array of 1000 data points that start at 0 and end at 35.‬
‭a.‬ ‭Use your sine function to calculate a sine curve using this array, your estimated‬
‭amplitude and frequency.‬
‭12.‬‭Plot your calculated sine curve on the same plot as radial velocity (y-axis) versus the‬
‭correct phase date (x-axis). Make sure to include x and y-labels‬‭with units‬‭, and a title.‬
‭a.‬ ‭Zoom into the x-limits to better see the data points.‬
‭13.‬‭Plot your calculated sine curve on the same plot as radial velocity (y-axis) versus the‬
‭julian date (x-axis). Make sure to include x and y-labels‬‭with units‬‭, and a title. Does the‬
‭model fit the data?‬
‭a.‬ ‭Zoom into the x-limits to better see the data points.‬
‭14.‬‭Use your sine curve model to estimate the following:‬
‭a.‬ ‭What is the expected radial velocity at a reduced Julian Date of 8?‬
‭b.‬ ‭What is the expected radial velocity at a reduced Julian Date of 20?‬
‭(d) Calculate the mass‬
‭15.‬‭Use equations 2 and 5 from the introduction to calculate the mass of the planet.‬
‭16.‬‭Check to make sure your answer is sensible (e.g. the planet should be big - maybe even‬
‭bigger than Jupiter, but not the size of a star.)‬
‭2 - Intermediate:‬
‭ his is a similar activity to the Beginner, except with less instructions, and an added step of‬
T
‭calculating the goodness of fit between the data and a sine function.‬
‭(a) Review your past work‬
1‭ .‬ S ‭ et yourself a 10 minute timer so you don’t spend too long on this part.‬
‭2.‬ ‭Open the previous notebook.‬
‭a.‬ ‭Identify the parts you can copy directly, like loading the packages or importing‬
‭files.‬
‭b.‬ ‭Look for the skills used in each, like making a graph, fitting a function, and doing‬
‭calculations. You may want to take a moment to make yourself a note of which‬
‭section to find which skill.‬
‭(b) Analysis of exoplanet data‬
‭3.‬ ‭Make a‬‭copy‬‭of the‬‭Intermediate python notebook‬‭and download the dataset‬
‭‘51_Peg.csv’.‬
‭4.‬ ‭Make a scatter plot (just points, no connecting line) of radial velocity (y-axis) versus date‬
‭(x-axis). Make sure to include the errors on the y-values, x and y-labels‬‭with units‬‭, as‬
‭well as a title.‬
‭5.‬ ‭Recall from the figures in the pre-lab that an exoplanet should induce a sinusoidal‬
‭variation in the radial velocity of the tar. In your plot, there should be variation visible,‬
‭but it should be difficult to tell if it is sinusoidal, or what the period is. To find the period,‬
‭astronomers fit the data points with a function, or the “theoretical expectation”, in this‬
‭case, a sine function with some period and amplitude. A fitting code is usually used in‬
‭order to find the best solution, or the closest match between the data and the theoretical‬
‭expectation from the function, and find the best-fit period. We will do a‬‭simplified version‬
‭of this type of analysis‬‭; To find the period, we will‬‭try only a few guesses, and not explore‬
‭the entire parameter space of possible periods.‬
‭For 51 Peg, we will examine two possible “guesses” for the period of the planet: 4.2‬
‭days, and 6.7 days.‬
‭a.‬ ‭Calculate the phased date by dividing the date of each observation by the period‬
‭guess, and recording the‬‭remainder‬‭. (Tip: use the‬‭“%” operator in Python).‬
‭b.‬ ‭Make two scatter plots of the radial velocity (y-axis) versus the phased date‬
‭(x-axis) - i.e. two sets of points, one for each phased date column.‬
‭c.‬ ‭Make sure to include errors on the y-values, x and y-labels‬‭with units‬‭, as well as‬
‭a title.‬
‭6.‬ ‭Only one of these guesses is correct. To tell which it is, look and see which set of data‬
‭gives a nice sinusoidal curve in your plot. Congratulations, this is the unmistakable‬
‭signature of an exoplanet! Based on your data, which is the correct period for the planet?‬
‭(c)‬‭Check for goodness of fit‬
‭7.‬ ‭Write a function to calculate a sine function:‬‭𝑦‬‭‬ = ‭‭𝐴 ‬ ‬‭‭𝑠‬ 𝑖𝑛‬(ν‭𝑥‬)‭. , where A is the‬
‭amplitude,‬ν ‭is the frequency, and x is the input‬‭x-value. In your function, A,‬ν‭, and x‬
‭should be variables that you can change.‬
‭8.‬ ‭To quantify the goodness of the fit, calculate the goodness of fit between the data and the‬
‭sine function using a fitting function of your choice (for example, a chi^2 estimator).‬
‭a.‬ ‭Report the goodness of fit of each of the guesses (4.2 and 6.7 days).‬
‭b.‬ ‭Is the result of your code consistent with what you determined by eye?‬

‭(d) Calculate the mass‬


‭9.‬ ‭Use equations 2 and 5 from the introduction to calculate the mass of the planet.‬
‭10.‬‭Check to make sure your answer is sensible (e.g. the planet should be big - bigger even‬
‭than Jupiter, but not the size of a star.)‬

‭3 - Advanced:‬
‭ his activity asks you to write a fitting function and explore the parameter space to find the‬
T
‭best-fit period of 51 Peg. Please check with your GSI before attempting this version.‬
‭Tip: Advanced programmers can start with the “intermediate” activity, and once the code‬
‭to calculate the goodness of fit is in place, write a function that explores the parameter‬
‭space and finds the period and amplitude that give the best fit.‬
‭1.‬ ‭Make a copy of‬‭the advanced notebook‬‭and download‬‭the dataset ‘51_Peg.csv’.‬
‭2.‬ ‭Make a scatter plot (just points, no connecting line) of radial velocity (y-axis) versus date‬
‭(x-axis). Make sure to include the errors on the y-values, x and y-labels‬‭with units‬‭, as‬
‭well as a title.‬
‭3.‬ ‭Recall from the figures in the pre-lab that an exoplanet should induce a sinusoidal‬
‭variation in the radial velocity of the tar. In your plot, there should be variation visible,‬
‭but it should be difficult to tell if it is sinusoidal, or what the period is. To find the period,‬
‭astronomers fit the data points with a function, or the “theoretical expectation”, in this‬
‭case, a sine function with some period and amplitude.‬
‭Write a function that fits the data with a sine function with parameters P (period) and A‬
‭(amplitude) and reports back the orbital parameters of the exoplanet. Look for the best-fit‬
‭period in the range from 1 to 10. You can choose which range of amplitudes to explore.‬
‭a.‬ ‭For each value, report the goodness of fit of a sine function to the data.‬
‭b.‬ ‭What period results in the best fit of the data?‬
‭Calculate the mass‬
‭4.‬ ‭Use equations 2 and 5 from the introduction to calculate the mass of the planet.‬
‭5.‬ C
‭ heck to make sure your answer is sensible (e.g. the planet should be big - bigger even‬
‭than Jupiter, but not the size of a star.)‬

‭Part 2: The Transit Method‬


‭ cience objective‬‭: calculate the effective temperature‬‭of different planets.‬
S
‭Computational objective‬‭: use one code on several sets‬‭of input, thus saving time and effort by‬
‭letting the computer do the work for you instead of calculating the same thing for different inputs‬
‭by hand.‬

I‭ n this part of the lab you will examine data outputs of simulations of Kepler lightcurves of main‬
‭sequence stars and the transits of planets around the stars, to see what they can tell you about‬
‭exoplanets.‬

‭1.‬ L ‭ oad in the data set ‘Star_transit.csv’. This data set contains the day number on which a‬
‭planet transits its host star (counting starts at 0 for each case), the peak brightness drop of‬
‭the star in percent, the mass of the star (M_sun), the radius of the star (R_sun), and the‬
‭effective temperature (K).‬
‭2.‬ ‭With your group, pick a star to work on.‬
‭3.‬ ‭What is the period of the planet?‬
‭4.‬ ‭Using the data available in the csv file, calculate (in python) the semi-major orbit of the‬
‭planet.‬‭Make sure you are paying attention to units!‬
‭5.‬ ‭The drop in the star’s brightness as the planet passes in front of it is given by the ratio of‬
‭the planet’s area to the star’s area. Using the star’s radius and the peak drop in brightness‬
‭from the lightcurve, estimate the radius of the transiting exoplanet in cm‬
‭10‬
‭(‭𝑅
‬ ‬‭𝑠𝑢𝑛‬ = ‭‭6 ‬ ‬ ‭𝑐𝑚‬‭).‬
‬ .‬ ‭96‬ × ‭1‭0
‭8‬
‭a.‬ ‭What is the radius of the planet in Earth radii (‬‭𝑅‬‭𝐸𝑎𝑟𝑡ℎ‬ = ‭‭6 ‬ ‬ ‭𝑐𝑚‬‭)?‬
‬ .‬ ‭37‬ × ‭1‭0
‭9‬
‭b.‬ ‭What is the radius of the planet in Jupiter radii (‬‭𝑅‬‭𝐽𝑢𝑝‬ = ‭‬‭6.‬ ‭99‬ × ‭1‭0
‬ ‬ ‭𝑐𝑚‬‭)?‬
‭6.‬ W ‭ rite a function that will calculate the effective temperature of your exoplanet using‬
‭equation 10 from the introduction.‬
‭a.‬ ‭Determine the temperature of your planet.‬
‭b.‬ ‭Check your answers to make sure they make sense (e.g. a planet shouldn’t be‬
‭hotter than a star, or have Pluto-like temperatures at Mercury-like distances.)‬
‭7.‬ ‭In order for an exoplanet to be habitable, it needs to have liquid water. Water exists in the‬
‭liquid state between 273 and 373 K. Is your exoplanet in the right range to be considered‬
‭as “candidate” life-supporting planets? If not, is it too hot or too cold?‬
‭How to submit your lab‬
‭ ou should be able to save the notebook as a pdf under the print option. Upload the pdf to‬
Y
‭Gradescope with the following outline:‬
‭1.‬ ‭Loading the libraries and data file (2 pts)‬
‭2.‬ ‭Scatter plot of data (5 pts)‬
‭3.‬ ‭Phased date calculation (3 pts)‬
‭4.‬ ‭Phased date plots (5 pts)‬
‭5.‬ ‭Goodness test [beginner steps 9 - 14, intermediate step 7, advanced step 3a] (5 pts)‬
‭6.‬ ‭Planet mass (5 pt)‬
‭7.‬ ‭Loading transit data and picking a star (2 pt)‬
‭8.‬ ‭determining the period and semi-major axis (4 pt)‬
‭9.‬ ‭Radii (4 pt)‬
‭10.‬‭Temperature calculation (5 pt)‬
‭11.‬‭Habitability (5 pt)‬

You might also like