Skip to content

Commit

Permalink
illustrations, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-cassese committed Apr 24, 2024
1 parent 845a103 commit 230e4e7
Show file tree
Hide file tree
Showing 18 changed files with 1,187 additions and 463 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
platform: [ubuntu-latest, macos]
python-version: ['3.9', '3.10', '3.11']

steps:
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
5 changes: 5 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing to the code

If you find a problem with the code or have any ideas for new features or improvements, feel free to get involved! We ask that all problems are reported as [Github issues](https://github.com/ben-cassese/squishyplanet/issues) and all code changes are submitted as [Pull requests](https://github.com/ben-cassese/squishyplanet/pulls). If submitting a pull request, please be sure to run the tests (either with [tox](https://tox.wiki/en/latest/) or [pytest](https://docs.pytest.org/en/8.1.x/)) and to adhere to the [black](https://black.readthedocs.io/en/stable/) python code style. ``squishyplanet`` uses Github Actions for continuous integration, so all pull requests and commits automatically trigger tests and formatting checks.

Though ``squishyplanet`` is not affiliated with [Astropy](http://www.astropy.org/), we still ask that all contributors follow the [Astropy Project Code of Conduct](http://www.astropy.org/code_of_conduct.html). If you have any questions or concerns, please feel free to reach out to the maintainer(s).
2 changes: 1 addition & 1 deletion docs/geometry.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Geometry Visualizations
# Geometry visualizations


```{figure} ./visualizations/SphereToEllipsoid.gif
Expand Down
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ ms per evaluation.
installation
quickstart
geometry
contributing
```

```{toctree}
:maxdepth: 1
:hidden:
:caption: Tutorials/Demos
tutorials/create_a_lightcurve.ipynb
tutorials/illustrations.ipynb
tutorials/lightcurve_compare.ipynb
tutorials/create_a_lightcurve.ipynb
tutorials/create_a_phase_curve.ipynb
tutorials/fit_a_transit.ipynb
```


Expand Down
2 changes: 1 addition & 1 deletion docs/oblate_system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ a system, then vary those parameters through built-in functions to generate diff
models and compare them to data.


.. automodule:: OblateSystem
.. automodule:: oblate_system
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"import jax\n",
"jax.config.update(\"jax_enable_x64\", True)\n",
"import jax.numpy as jnp\n",
"from squishyplanet.OblateSystem import OblateSystem\n",
"from squishyplanet import OblateSystem\n",
"import matplotlib.pyplot as plt\n",
"\n",
"state1 = {\n",
Expand Down
25 changes: 0 additions & 25 deletions docs/tutorials/fit_a_transit.ipynb

This file was deleted.

517 changes: 513 additions & 4 deletions docs/tutorials/illustrations.ipynb

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion squishyplanet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from squishyplanet.OblateSystem import *
from .oblate_system import OblateSystem

__all__ = ["OblateSystem"]
__url__ = "https://github.com/ben-cassese/squishyplanet"
__license__ = "MIT"
__description__ = "Modeling transits of non-spherical exoplanets"
__version__ = "0.1.0"
133 changes: 133 additions & 0 deletions squishyplanet/engine/development/test_emission_normalization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# still kind of confused by this: when applying this correction, the total emission
# looks correct but the spatial distribution gets weird/isn't a single hotspot anymore.
# leaving this off for now.

# # spent a while confused about how to normalize the total emission from the planet, so
# # this is a sanity check. When randomly sampling points on the surface of the planet,
# # the average emission should be 1.0, regardless of the shape of the planet or the
# # location/concentration of the hotspot. To make that happen, we have to weight points
# # based on the biases you'd get from uneven densities on the unit sphere after
# # un-squishing the planet. This test is admittedly a little circular, since when
# # generating uniform samples on the planet's surface we use a rejection sampling scheme
# # based on the same factor we'll then use to re-weight the points, but still, it helped
# # to write it out.

# # also note that this is all in the 3D geometry- when we sample/view the planet
# # projected onto the sky frame, need to divide by another factor of 4 since the
# # weighted, un-squished points can be equivalently thought of as samples of the unit
# # disk.

# import jax

# jax.config.update("jax_enable_x64", True)
# import jax.numpy as jnp

# from squishyplanet.engine.phase_curve_utils import (
# _emission_profile,
# emission_squish_correction,
# )

# from tqdm import tqdm


# nsamples = 1_000_000


# def sample_ellipsoid(key, n_samples, r, f1, f2):
# _, *keys = jax.random.split(key, 4)
# a = r
# b = r * (1 - f2)
# c = r * (1 - f1)

# # sample points uniformly on the sphere
# s = n_samples * 10
# theta = jnp.arccos(jax.random.uniform(keys[0], (s,), minval=-1, maxval=1))
# phi = jax.random.uniform(keys[1], (s,), minval=0, maxval=2 * jnp.pi)

# x = 1.0 * jnp.sin(theta) * jnp.cos(phi)
# y = 1.0 * jnp.sin(theta) * jnp.sin(phi)
# z = 1.0 * jnp.cos(theta)

# # project points to the ellipsoid
# x = a * x
# y = b * y
# z = c * z

# # compute rejection probability
# w = jnp.min(jnp.array([a, b, c])) * jnp.sqrt(
# x**2 / a**4 + y**2 / b**4 + z**2 / c**4
# )
# selected = jax.random.choice(
# keys[2], jnp.arange(s), p=w / jnp.sum(w), shape=(n_samples,)
# )
# x = x[selected]
# y = y[selected]
# z = z[selected]

# return x, y, z


# def test_normalization():
# planets = []
# for k in tqdm(range(100)):
# _, *keys = jax.random.split(jax.random.PRNGKey(k), 8)
# r = jax.random.uniform(keys[0], minval=0.5, maxval=1.5)
# f1 = jax.random.uniform(keys[1], minval=0.0, maxval=0.99)
# f2 = jax.random.uniform(keys[2], minval=0.0, maxval=0.99)
# hotspot_lat = jax.random.uniform(keys[3], minval=0, maxval=jnp.pi)
# hotspot_lon = jax.random.uniform(keys[4], minval=0, maxval=2 * jnp.pi)
# hotspot_concentration = jax.random.uniform(keys[5], minval=0.1, maxval=5.0)

# planet_x, planet_y, planet_z = sample_ellipsoid(
# key=keys[6],
# n_samples=nsamples,
# r=r,
# f1=f1,
# f2=f2,
# )

# assert jnp.allclose(
# planet_x**2 / (r**2)
# + planet_y**2 / (r**2 * (1 - f2) ** 2)
# + planet_z**2 / (r**2 * (1 - f1) ** 2),
# 1.0,
# )

# unnormalized_planet = _emission_profile(
# x=planet_x,
# y=planet_y,
# z=planet_z,
# r=r,
# f1=f1,
# f2=f2,
# hotspot_latitude=hotspot_lat,
# hotspot_longitude=hotspot_lon,
# hotspot_concentration=hotspot_concentration,
# )

# planet_correction = emission_squish_correction(
# x=planet_x,
# y=planet_y,
# z=planet_z,
# r=r,
# f1=f1,
# f2=f2,
# )

# planet = jnp.sum(unnormalized_planet * planet_correction) / jnp.sum(
# planet_correction
# )

# planets.append(planet)

# planets = jnp.array(planets)

# # the planet samples are all close to 1:
# assert jnp.abs(jnp.mean(planets) - 1) < 0.01

# # and that the distribution is close to normal:
# s = jnp.std(planets)
# assert jnp.abs(jnp.mean(planets) - 1) < 3 * s


# test_normalization()
Loading

0 comments on commit 230e4e7

Please sign in to comment.