Skip to content

Instantly share code, notes, and snippets.

@j-faria
Last active Dec 5, 2019
Embed
What would you like to do?
The Keplerian and transit curves
Two small demonstration notebooks of how the Keplerian and transit curves respond to a change in the parameters.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from ipywidgets import interact, interactive\n",
"\n",
"# install batman from here: https://www.cfa.harvard.edu/~lkreidberg/batman/\n",
"from batman import TransitModel, TransitParams"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"t = np.linspace(-0.05, 0.05, 300)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"params = TransitParams()\n",
"params.t0 = 0. #time of inferior conjunction\n",
"params.per = 1. #orbital period\n",
"params.rp = 0.1 #planet radius (in units of stellar radii)\n",
"params.a = 15. #semi-major axis (in units of stellar radii)\n",
"params.inc = 87. #orbital inclination (in degrees)\n",
"params.ecc = 0. #eccentricity\n",
"params.w = 90. #longitude of periastron (in degrees)\n",
"params.u = [0.1, 0.3] #limb darkening coefficients [u1, u2]\n",
"params.limb_dark = \"quadratic\" #limb darkening model"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"m = TransitModel(params, t) #initializes model\n",
"\n",
"def plot_transit(rp=0.1, a=15, inc=87, ecc=0., u1=0.1, u2=0.3):\n",
" fig, ax = plt.subplots(1, 1, figsize=(14, 10))\n",
" params.rp = rp\n",
" params.a = a\n",
" params.inc = inc\n",
" params.ecc = ecc\n",
" params.u = [u1, u2]\n",
" flux = m.light_curve(params)\n",
" ax.plot(t, flux, lw=2)\n",
" ax.set(xlabel='Time [days]', ylabel='flux', ylim=(0.7, 1.1))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5b95477394c24119853b0810e366640a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.1, description='rp', max=0.7, min=0.1, step=0.05), IntSlider(value=1…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"w = interact(plot_transit, rp=(0.1, 0.7, 0.05), a=(2, 20), inc=(85, 90, 0.1), ecc=(0, 0.9, 0.1), u1=(0,1,0.1), u2=0.3);"
]
}
],
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment