Skip to content

Commit

Permalink
fix: add projected area
Browse files Browse the repository at this point in the history
fix: add projected area
  • Loading branch information
lgrcia authored Jan 9, 2024
2 parents 082710f + 3994787 commit 030b594
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 112 deletions.
59 changes: 24 additions & 35 deletions docs/source/notebooks/amplitude_constraints.ipynb

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions docs/source/notebooks/experiments.ipynb

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions docs/source/notebooks/jax_features.ipynb

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions docs/source/notebooks/rotation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"7.10442 s\n"
"7.33934 s\n"
]
}
],
Expand Down Expand Up @@ -156,7 +156,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1.15852 s\n"
"1.67400 s\n"
]
}
],
Expand Down Expand Up @@ -185,7 +185,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0.03229 s\n"
"0.05315 s\n"
]
}
],
Expand All @@ -204,6 +204,11 @@
"source": [
"Way faster!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand All @@ -222,7 +227,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
19 changes: 13 additions & 6 deletions docs/source/notebooks/simple_example.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spotter"
version = "0.0.4-beta"
version = "0.0.5-beta"
description = "Stellar contamination estimates from rotational light curves"
authors = ["Lionel Garcia", "Benjamin Rackham"]
license = "MIT"
Expand Down Expand Up @@ -29,6 +29,7 @@ myst-nb = "*"
sphinx-copybutton = "*"
toml = "*"
ipywidgets = "*"
tqdm = "*"

[build-system]
requires = ["poetry-core"]
Expand Down
7 changes: 7 additions & 0 deletions spotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def ld(u, phase):
return 1 - jnp.sum(terms, 0)

return ld


def projected_area(thetas, phis):
def area(phase):
return jnp.cos(thetas - phase) * jnp.sin(phis)

return area
17 changes: 12 additions & 5 deletions spotter/star.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __post_init__(self):
self.polynomial_limb_darkening = jax.vmap(
core.polynomial_limb_darkening(self._thetas, self._phis), in_axes=(None, 0)
)
self.projected_area = jax.vmap(core.projected_area(self._thetas, self._phis))

# Define transit chord if impact parameter (b) and planet radius (r) provided
self._map_chord = np.zeros(self.n)
Expand Down Expand Up @@ -331,11 +332,13 @@ def jax_flux(self, phases):
"""
mask = self.hemisphere_mask(phases)
limb_darkening = self.polynomial_limb_darkening(self.u, phases)
projected_area = self.projected_area(phases)

@jax.jit
def flux(spot_map):
m = (1 - spot_map) * mask * limb_darkening
return m.sum(1) / (mask * limb_darkening).sum(1)
_spot = (1 - spot_map) * limb_darkening
_geometry = mask * projected_area
return (_spot * _geometry).sum(1) / _geometry.sum(1)

return flux

Expand Down Expand Up @@ -440,16 +443,20 @@ def flux(self, phases):
mask = np.vectorize(core.hemisphere_mask(self._thetas), signature="()->(n)")(
phases
)
projected_area = np.vectorize(
core.projected_area(self._thetas, self._phis), signature="()->(n)"
)(phases)
limb_darkening = np.vectorize(
core.polynomial_limb_darkening(self._thetas, self._phis),
signature="()->(n)",
excluded={0},
)(self.u, phases)
m = (1 - self.map_spot) * mask * limb_darkening
_spot = (1 - self.map_spot) * limb_darkening
_geometry = mask * projected_area
# faculae contribution, with same ld for now (TODO)
m += self.map_faculae * mask * limb_darkening
_faculae = self.map_faculae * limb_darkening

return m.sum(1) / (mask * limb_darkening).sum(1)
return ((_spot + _faculae) * _geometry).sum(1) / _geometry.sum(1)

def map(self, phase=None, limb_darkening=False):
"""
Expand Down

0 comments on commit 030b594

Please sign in to comment.