Skip to content

Commit 00d0bff

Browse files
committed
Merge branch 'limb_darkening'
- Add limb darkening effect. Currently only suppurt the linear limb darkening law and not in an adaptive scheme. - Add tests for contour integral and limb darkening effect. - Update docstring format. - Rename some functions and refactor the file structures.
2 parents 0ac4cb8 + 6c14801 commit 00d0bff

18 files changed

+1023
-766
lines changed

docs/api/model.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Magnification Model
22

33
Light curve for the binary lens with adaptive contour integration and point sorce approximation.
4-
::: microlux.extended_light_curve
4+
::: microlux.binary_mag
55
---
66
Light curve with point source approximation.
77
::: microlux.point_light_curve
88
---
9+
Adaptive contour integration for the light curve.
10+
::: microlux.extended_light_curve
11+
---
912
Adaptive contour integration for the single epoch.
10-
::: microlux.contour_integral
13+
::: microlux.contour_integral

example/KB0371.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"import numpyro.distributions as dist\n",
210210
"from numpyro.infer import MCMC, NUTS\n",
211211
"from numpyro.diagnostics import print_summary\n",
212-
"from BinaryJax import model\n",
212+
"from microlux import binary_mag\n",
213213
"\n",
214214
"import VBBinaryLensing\n",
215215
"from MulensModel import caustics\n",
@@ -699,7 +699,7 @@
699699
" alpha_deg = parms[4]\n",
700700
" s = 10.**parms[5]\n",
701701
" q = 10.**parms[6]\n",
702-
" mag_Jax = model(t0, u0, tE, rho, q, s, alpha_deg, times)\n",
702+
" mag_Jax = binary_mag(t0, u0, tE, rho, q, s, alpha_deg, times)\n",
703703
" return mag_Jax\n",
704704
"initial_guess = [8.59238794e+03, 1.42915228e-01, 6.61567944e+00, -2.23131913e+00, 2.71714918e+02, -7.73128397e-02, -1.14229367e+00]\n",
705705
"times,flux,ferr = HJD,flux,ferr\n",
@@ -788,7 +788,7 @@
788788
" alpha_deg = parms[4]\n",
789789
" s = 10.**parms[5]\n",
790790
" q = 10.**parms[6]\n",
791-
" mag_Jax = model(t0, u0, tE, rho, q, s, alpha_deg, times)\n",
791+
" mag_Jax = binary_mag(t0, u0, tE, rho, q, s, alpha_deg, times)\n",
792792
" return mag_Jax\n",
793793
"def light_curve_Jax_pmap(times,parms,i):\n",
794794
" times = jnp.reshape(times,(-1,N_pmap),order='C')\n",

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ plugins:
7474
show_root_heading: true
7575
show_root_full_path: true
7676
show_if_no_docstring: false
77-
show_signature_annotations: false
77+
show_signature_annotations: true
7878
members_order: source
7979
heading_level: 2
8080
# rendering:

src/microlux/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# # -*- coding: utf-8 -*-
22
all = [
3-
"model",
43
"point_light_curve",
4+
"extended_light_curve",
55
"contour_integral",
6+
"binary_mag",
67
"Iterative_State",
78
"Error_State",
89
"to_lowmass",
@@ -13,8 +14,9 @@
1314
to_centroid as to_centroid,
1415
to_lowmass as to_lowmass,
1516
)
17+
from .countour import contour_integral as contour_integral
1618
from .model import (
17-
contour_integral as contour_integral,
19+
binary_mag as binary_mag,
1820
extended_light_curve as extended_light_curve,
1921
point_light_curve as point_light_curve,
2022
)

src/microlux/basic_function.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def to_lowmass(s, q, x):
3838

3939

4040
def Quadrupole_test(rho, s, q, zeta, z, cond, tol=1e-2):
41+
"""
42+
The quadrupole test, ghost image test, and planetary caustic test proposed by Bozza 2010 to check the validity of the point source approximation.
43+
The coefficients are fine-tuned in our implementation.
44+
45+
"""
4146
m1 = 1 / (1 + q)
4247
m2 = q / (1 + q)
4348
cQ = 2
@@ -93,6 +98,9 @@ def Quadrupole_test(rho, s, q, zeta, z, cond, tol=1e-2):
9398

9499

95100
def get_poly_coff(zeta_l, s, m2):
101+
"""
102+
get the polynomial cofficients of the polynomial equation of the lens equation. The low mass object is at the origin and the primary is at s.
103+
"""
96104
zeta_conj = jnp.conj(zeta_l)
97105
c0 = s**2 * zeta_l * m2**2
98106
c1 = -s * m2 * (2 * zeta_l + s * (-1 + s * zeta_l - 2 * zeta_l * zeta_conj + m2))
@@ -140,6 +148,11 @@ def dot_product(a, b):
140148

141149

142150
def basic_partial(z, theta, rho, q, s, caustic_crossing):
151+
"""
152+
153+
basic partial derivatives of the lens equation with respect to zeta, z, and theta used in the error estimation.
154+
155+
"""
143156
z_c = jnp.conj(z)
144157
parZetaConZ = 1 / (1 + q) * (1 / (z_c - s) ** 2 + q / z_c**2)
145158
par2ConZetaZ = -2 / (1 + q) * (1 / (z - s) ** 3 + q / (z) ** 3)
@@ -198,8 +211,8 @@ def refine_gradient(zeta_l, q, s, z):
198211
@refine_gradient.defjvp
199212
def refine_gradient_jvp(primals, tangents):
200213
"""
201-
use the custom jvp to refine the gradient of roots respect to zeta_l, based on the equation on V.Bozza 2010 eq 20.
202-
The necessity of this function is still under investigation.
214+
use the custom jvp to refine the gradient of roots respect to zeta_l, based on the equation on V.Bozza 2010 eq 20 and also see our paper for the details
215+
This will simplify the computational graph and accelerate the gradient calculation
203216
"""
204217
zeta, q, s, z = primals
205218
tangent_zeta, tangent_q, tangent_s, tangent_z = tangents

0 commit comments

Comments
 (0)