-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
845a103
commit 230e4e7
Showing
18 changed files
with
1,187 additions
and
463 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
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 |
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,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). |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Geometry Visualizations | ||
# Geometry visualizations | ||
|
||
|
||
```{figure} ./visualizations/SphereToEllipsoid.gif | ||
|
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
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -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
133
squishyplanet/engine/development/test_emission_normalization.py
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,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() |
Oops, something went wrong.