Skip to content

Commit

Permalink
docs: new and updated tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrcia committed Feb 6, 2024
1 parent b0bf869 commit f1736ba
Show file tree
Hide file tree
Showing 10 changed files with 588 additions and 597 deletions.
32 changes: 17 additions & 15 deletions docs/notebooks/combined.ipynb

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions docs/notebooks/multi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
" CpuDevice(id=6),\n",
" CpuDevice(id=7),\n",
" CpuDevice(id=8),\n",
" CpuDevice(id=9),\n",
" CpuDevice(id=10),\n",
" CpuDevice(id=11)]"
" CpuDevice(id=9)]"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -81,7 +79,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/lgarcia/code/dev/nuance/nuance/combined.py:7: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
"/Users/lgrcia/code/dev/nuance/nuance/combined.py:7: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
" from tqdm.autonotebook import tqdm\n"
]
},
Expand Down Expand Up @@ -152,12 +150,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "52a1143ec15c42d0ac62c8c4da2e0d77",
"model_id": "b48b609eac8c478cb5630c685587f851",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/84 [00:00<?, ?it/s]"
" 0%| | 0/100 [00:00<?, ?it/s]"
]
},
"metadata": {},
Expand Down Expand Up @@ -211,13 +209,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "99bdae816415436eb32eecaf88d2bf80",
"model_id": "1126a6088496485f9d1a3f090a166c66",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -240,10 +238,10 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x2d46a2290>"
"<matplotlib.legend.Legend at 0x17768e580>"
]
},
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -317,7 +315,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -344,13 +342,13 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "73de98f383484957acc59fa4a045bd1e",
"model_id": "e1ce39b180d447d6be6e1c0b4cbde82d",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -373,10 +371,10 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x2d46447d0>"
"<matplotlib.legend.Legend at 0x2b51d74f0>"
]
},
"execution_count": 11,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -455,7 +453,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.8.13"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
18 changes: 8 additions & 10 deletions docs/notebooks/periodic.ipynb

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions docs/notebooks/single.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
" CpuDevice(id=6),\n",
" CpuDevice(id=7),\n",
" CpuDevice(id=8),\n",
" CpuDevice(id=9),\n",
" CpuDevice(id=10),\n",
" CpuDevice(id=11)]"
" CpuDevice(id=9)]"
]
},
"execution_count": 1,
Expand All @@ -61,7 +59,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/lgarcia/code/dev/nuance/nuance/combined.py:7: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
"/Users/lgrcia/code/dev/nuance/nuance/combined.py:7: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
" from tqdm.autonotebook import tqdm\n"
]
},
Expand Down Expand Up @@ -109,12 +107,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0d08808b1e0a4879ba363307b474c9d8",
"model_id": "61fb5d6d76c048dfb2d842a437de8f10",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/167 [00:00<?, ?it/s]"
" 0%| | 0/200 [00:00<?, ?it/s]"
]
},
"metadata": {},
Expand Down Expand Up @@ -247,7 +245,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.8.13"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
458 changes: 458 additions & 0 deletions docs/notebooks/tutorials/ground_based.ipynb

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions docs/notebooks/tutorials/tess_search.ipynb

Large diffs are not rendered by default.

45 changes: 0 additions & 45 deletions docs/source/multi.ipynb

This file was deleted.

279 changes: 0 additions & 279 deletions docs/source/periodic.ipynb

This file was deleted.

215 changes: 0 additions & 215 deletions docs/source/single.ipynb

This file was deleted.

69 changes: 69 additions & 0 deletions nuance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tinygp

from nuance import core
from nuance.core import transit_protopapas


def interp_split_times(time, p, dphi=0.01):
Expand Down Expand Up @@ -161,3 +162,71 @@ def binn_time(time, flux, bins=7 / 24 / 60):
binned_flux = np.array([np.mean(flux[i]) for i in indexes])
binned_error = np.array([np.std(flux[i]) / np.sqrt(len(i)) for i in indexes])
return binned_time, binned_flux, binned_error


def simulated_ground_based(n=500, N=4):
true = {
"t0": 0.3,
"D": 38 / 60 / 24,
"depth": 0.005,
"P": 0.65,
}
idxs = np.arange(1, N) * n
times = [np.linspace(0 + i, 0.5 + i, n) for i in range(N)]
time = np.concatenate(times)
error = 1e-3
kernel = tinygp.kernels.quasisep.SHO(np.pi / true["D"] / 3, 1, true["depth"] / 2)
variability_gp = tinygp.GaussianProcess(kernel, time, diag=0)
jax_key = jax.random.PRNGKey(0)
variability = variability_gp.sample(jax_key)
variabilities = [
np.random.normal(0, error) + v for v in np.split(variability, idxs)
]

airmasses = [0.2 * (t - t.min()) ** 2 for t in times]
bkgs = [
tinygp.GaussianProcess(
tinygp.kernels.quasisep.SHO(20, 1, 0.005), t, diag=(1e-4) ** 2
).sample(jax.random.PRNGKey(i))
for i, t in enumerate(times)
]
fwhms = [
tinygp.GaussianProcess(
tinygp.kernels.quasisep.SHO(45, 1, 0.005), t, diag=(5e-4) ** 2
).sample(jax.random.PRNGKey(i))
for i, t in enumerate(times)
]

transits = np.split(
true["depth"] * transit_protopapas(time, 0.3, true["D"], true["P"]), idxs
)

systematics = [
0.2 * np.random.normal(0, 0.9, 3) @ np.vstack([airmasses[i], bkgs[i], fwhms[i]])
for i in range(N)
]

fluxes = [systematics[i] + variabilities[i] + transits[i] + 1.0 for i in range(N)]

fluxes = [f - np.median(f) + 1.0 for f in fluxes]

observations = [
{
"time": times[i],
"flux": fluxes[i],
"error": np.ones_like(times[i]) * error,
"airmass": airmasses[i],
"bkg": bkgs[i],
"fwhm": fwhms[i],
}
for i in range(N)
]

signals = {
"transits": transits,
"variabilities": variabilities,
"systematics": systematics,
"transit_params": true,
}

return observations, signals

0 comments on commit f1736ba

Please sign in to comment.