Skip to content

Magnification Model¤

Light curve for the binary lens with adaptive contour integration and point sorce approximation.

microlux.extended_light_curve(t_0, u_0, t_E, rho, q, s, alpha_deg, times, tol=0.01, retol=0.001, return_info=False, default_strategy=(30, 30, 60, 120, 240), analytic=True) ¤

Compute the light curve of a binary lens system with finite source effects. This function will dynamically choose full contour integration or point source approximation based on the quadrupole test.

Parameters:

Name Type Description Default
t_0 float

The time of the peak of the microlensing event.

required
u_0 float

The impact parameter of the source trajectory.

required
t_E float

The Einstein crossing time.

required
rho float

The source radius normalized to the Einstein radius.

required
q float

The planet to host mass ratio of the binary lens system.

required
s float

The projected separation of the binary lens system normalized to the Einstein radius.

required
alpha_deg float

The angle between the source trajectory and the binary axis in degrees.

required
times array - like

The times at which to compute the model.

required
tol float

The tolerance for the adaptive contour integration. Defaults to 1e-2.

0.01
retol float

The relative tolerance for the adaptive contour integration. Defaults to 0.001.

0.001
return_info bool

Whether to return additional information about the computation. Defaults to False.

False
default_strategy tuple

The default strategy for the hierarchical contour integration. Defaults to (60,80,150).

(30, 30, 60, 120, 240)
analytic bool

Whether to use the analytic chain rule to simplify the computation graph. Set this to True will accelerate the computation of the gradient and will support the reverse mode differentiation containing the while loop. But set this to True will slow down if only calculate the model without differentiation. Defaults to True.

True

Returns:

Name Type Description
magnification array

The magnification of the source at the given times.

info tuple

Additional information about the computation if return_info is True.


Light curve with point source approximation.

microlux.point_light_curve(trajectory_l, s, q, rho, tol, return_num=False) ¤

Calculate the point source light curve.

Parameters:

Name Type Description Default
trajectory_l ndarray

The trajectory of the lensing event.

required
s float

The projected separation between the lens and the source.

required
q float

The mass ratio between the lens and the source.

required
rho float

The source radius in units of the Einstein radius.

required
tol float

The absolute tolerance for the quadrupole test.

required
return_num bool

Whether to return the number of real roots. Defaults to False.

False

Returns:

Name Type Description
result tuple

A tuple containing the magnitude of the light curve and a boolean array indicating the validity of the calculation. if the quadrupole test is passed, the corresponding element in the boolean array is True. If the return_num is True, the tuple will also contain the number of real roots.

cond array

A boolean array indicating whether the quadrupole test is passed. True means the quadrupole test is passed.

mask (optional, array)

A integer array indicating the number of real roots.


Adaptive contour integration for the single epoch.

microlux.contour_integral(trajectory_l, tol, retol, rho, s, q, default_strategy=(60, 80, 150), analytic=True) ¤

Perform hierarchical sampling for adaptive contour integration. This function is used to reduce the memory usage and improve the performance of the contour integration. The reason is that the optimal fixed array length is hard to determine before the code runs which the basic requirement for JIT compilation.

Parameters:

Name Type Description Default
trajectory_l complex

The trajectory of the lensing event at the low mass coordinate system.

required
tol float

The tolerance value.

required
retol float

The relative tolerance value.

required
rho float

The source radius normalized to the Einstein radius.

required
s float

The projected separation of the binary lens system normalized to the Einstein radius.

required
q float

The planet to host mass ratio of the binary lens system.

required
default_strategy tuple

The default strategy for array length. Defaults to (60,80,150).

(60, 80, 150)
analytic bool

Whether to use the analytic chain rule to simplify the computation graph.

True

Returns:

Name Type Description
result tuple

A tuple containing the magnitude and the result of the contour integration.