-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from rodluger/oblate
Transits across oblate stars
- Loading branch information
Showing
58 changed files
with
5,506 additions
and
736 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ arguments passed to it. | |
LimbDarkenedMap | ||
RadialVelocityMap | ||
ReflectedLightMap | ||
OblateMap |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Oblate Maps | ||
=========== | ||
|
||
.. autoclass:: starry._OblateMap() | ||
:noindex: | ||
:members: | ||
:inherited-members: |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%run ../notebook_setup.py" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"import starry\n", | ||
"import pymc3 as pm\n", | ||
"import pymc3_ext as pmx" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Generate" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"map = starry.Map(oblate=True, lazy=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"truths = {\n", | ||
" \"f\": 0.3,\n", | ||
" \"omega\": 0.5,\n", | ||
" \"inc\": 60,\n", | ||
" \"obl\": 30,\n", | ||
" \"b0\": 0.5,\n", | ||
" \"ro\": 0.1\n", | ||
"}\n", | ||
"\n", | ||
"ferr = 3e-4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"map.f = truths[\"f\"]\n", | ||
"map.omega = truths[\"omega\"]\n", | ||
"map.inc = truths[\"inc\"]\n", | ||
"map.obl = truths[\"obl\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"xo = np.linspace(-1, 1, 300)\n", | ||
"yo = truths[\"b0\"] * np.ones_like(xo)\n", | ||
"ro = truths[\"ro\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots(1)\n", | ||
"ax.plot(xo, yo, \"k-\")\n", | ||
"ax.plot(xo, yo - ro, \"k--\")\n", | ||
"ax.plot(xo, yo + ro, \"k--\")\n", | ||
"map.show(ax=ax)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"flux0 = map.flux(xo=xo, yo=yo, ro=ro)\n", | ||
"flux = flux0 + ferr * np.random.randn(len(flux0))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plt.plot(flux0);\n", | ||
"plt.plot(flux, \"k.\", ms=3, alpha=0.75);" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Infer" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"with pm.Model() as model:\n", | ||
" f = pm.Uniform(\"f\", lower=0.0, upper=0.9, testval=truths[\"f\"])\n", | ||
" omega = pm.Uniform(\"omega\", lower=0.0, upper=0.9, testval=truths[\"omega\"])\n", | ||
" inc = pm.Uniform(\"inc\", lower=0.0, upper=90.0, testval=truths[\"inc\"])\n", | ||
" obl = pm.Uniform(\"obl\", lower=-90, upper=90.0, testval=truths[\"obl\"])\n", | ||
" b0 = pm.Uniform(\"b0\", lower=-1.0, upper=1.0, testval=truths[\"b0\"])\n", | ||
" ro = pm.Uniform(\"ro\", lower=1e-5, upper=0.5, testval=truths[\"ro\"])\n", | ||
" map = starry.Map(oblate=True)\n", | ||
" map.f = f\n", | ||
" map.omega = omega\n", | ||
" map.inc = inc\n", | ||
" map.obl = obl\n", | ||
" yo = b0 * np.ones_like(xo)\n", | ||
" flux_model = map.flux(xo=xo, yo=yo, ro=ro)\n", | ||
" pm.Normal(\"obs\", mu=flux_model, sd=ferr, observed=flux)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"np.random.seed(42)\n", | ||
"with model:\n", | ||
" trace = pmx.sample(\n", | ||
" tune=1000,\n", | ||
" draws=1000,\n", | ||
" chains=2,\n", | ||
" cores=1,\n", | ||
" target_accept=0.9,\n", | ||
" return_inferencedata=True,\n", | ||
" )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pm.summary(trace)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pm.plot_trace(trace);" | ||
] | ||
} | ||
], | ||
"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.8.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.