Skip to content

Magnification Model¤

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

microlux.binary_mag(t_0, u_0, t_E, rho, q, s, alpha_deg, times: jnp.ndarray, tol=0.01, retol=0.001, default_strategy: Tuple[int] = (30, 30, 60, 120, 240), analytic: bool = True, return_info: bool = False, limb_darkening_coeff: float | None = None) ¤

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 point-source validity checks.

Note

The coordinate system is consistent with the MulensModel(Center of mass).

Warning

Currently, to deal with limb-darkening effect, we only use 10 annuli which are uniformly distributed in terms of the area, which is not in an adaptive scheme. So the tolerance of the limb darkening effect is not guaranteed.

Parameters:

  • t_0 –

    The time of closest approach to the center of mass.

  • u_0 –

    The impact parameter of the source trajectory.

  • t_E –

    The Einstein crossing time.

  • rho –

    The source radius normalized to the Einstein radius.

  • q –

    The mass ratio of the secondary lens to the primary lens.

  • s –

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

  • alpha_deg –

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

  • times (ndarray) –

    The times at which to compute the model.

  • tol –

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

  • retol –

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

  • default_strategy (Tuple[int], default: (30, 30, 60, 120, 240) ) –

    The default strategy for the contour integration. Defaults to (30, 30, 60, 120, 240). more details can be found in the microlux.contour_integral.

  • analytic (bool, default: True ) –

    Use implicit root derivatives on the final contour mesh to support forward- and reverse-mode differentiation. Defaults to True. If False, differentiate through the adaptive iterations in forward mode.

  • return_info (bool, default: False ) –

    Whether to return additional information about the computation. Defaults to False. when set to True, the function will return a tuple containing (magnification, info), where info is a tuple containing additional information about the computation used for debugging.

  • limb_darkening_coeff (float | None, default: None ) –

    The limb darkening coefficient for the source star. Defaults to None for a uniformly bright source. Currently only supports linear limb darkening.

Returns:

  • magnification –

    The magnification of the source at the given times.

  • info –

    Additional information about the computation used for debugging if return_info is True. The structure is (trajectory_l, rho, s, q, roots_state, error_state), with an epoch axis on the arrays. trajectory_l uses the low-mass lens coordinate system. Point-source epochs contain placeholder contour states; use the returned magnification array for the light curve. See microlux.utils.Iterative_State and microlux.utils.Error_State for state fields.


Light curve with point source approximation.

microlux.point_light_curve(trajectory, s, q, rho, tol, return_num: bool = False) ¤

Calculate the point source light curve.

Note

The trajectory parameter should be in the center-of-mass coordinate system (consistent with MulensModel). The function internally transforms to low-mass coordinates for the calculation.

Parameters:

  • trajectory –

    The trajectory of the lensing event in center-of-mass coordinates.

  • s –

    Binary lens separation, scalar or shape (N,) matching trajectory.

  • q –

    The mass ratio of the secondary lens to the primary lens.

  • rho –

    The source radius in units of the Einstein radius.

  • tol –

    The absolute tolerance for the point-source validity checks.

  • return_num (bool, default: False ) –

    Whether to return the number of physical images. Defaults to False.

Returns:

  • magnification –

    The magnification array.

  • cond –

    A boolean array. True means the point-source approximation passes the validity checks.

  • image_count –

    The number of physical images at each epoch, included only when return_num=True.

A tuple (magnification, cond), or (magnification, cond, image_count) if return_num=True.


Adaptive contour integration for the light curve.

microlux.extended_light_curve(trajectory, s, q, rho, tol=0.01, retol=0.001, default_strategy: Tuple[int] = (30, 30, 60, 120, 240), analytic: bool = True, return_info: bool = False, limb_darkening: AbstractLimbDarkening | None = None, n_annuli: int = 10) ¤

Compute the light curve of a binary lens system with finite source effects.

Note

The trajectory parameter should be in the center-of-mass coordinate system (consistent with MulensModel). The function internally transforms to low-mass coordinates for the calculation.

Parameters:

  • trajectory –

    The trajectory in the center-of-mass coordinate system.

  • s –

    Binary lens separation, scalar or shape (N,) matching trajectory.

  • limb_darkening (AbstractLimbDarkening | None, default: None ) –

    An AbstractLimbDarkening instance providing profile and cumulative_profile, or None for a uniformly bright source. Defaults to None.

  • n_annuli (int, default: 10 ) –

    The number of equal-area annuli for the limb darkening calculation. Defaults to 10. Increase this value to check convergence.

For the definition of the other parameters, please see microlux.binary_mag.

Returns:

  • magnification –

    The magnification of the source at the given trajectory points.

  • info –

    Additional information about the computation used for debugging if return_info is True. See microlux.binary_mag for the layout and point-source placeholders. For epochs using contour integration with limb darkening, the states are from the outermost source radius.


Adaptive contour integration for the single epoch.

microlux.contour_integral(trajectory_l, tol, retol, rho, s, q, default_strategy=(60, 80, 150), analytic=True) -> Tuple[jnp.ndarray, Tuple] ¤

Perform adaptive contour integration with pre-define shaped array. 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. If the array length is too small, the adaptive contour integration will stop early and the error will be larger than the tolerance. If the array length is too large, it will cause the waste of memory and time. This waste is linear with the array length. So we use this pre-define shaped array to solve this problem.

Parameters:

  • trajectory_l –

    Source position in the low-mass lens coordinate system. Convert center-of-mass coordinates with to_lowmass before calling this function.

  • default_strategy –

    The default strategy for the contour integration. The array length will be added gradually according to this strategy. For example, if the default_strategy is (60, 80, 150), the array length in each layer will be 60, 140, 290, respectively.

  • analytic –

    Use implicit root derivatives on the final sampling mesh to support forward- and reverse-mode differentiation. Defaults to True. If False, differentiate through the adaptive iterations in forward mode.

For other parameters: please see at microlux.binary_mag

Returns:

  • result ( Tuple[ndarray, Tuple] ) –

    A tuple (magnification, info), where info = (trajectory_l, rho, s, q, roots_state, error_state).

If the contour capacity is exhausted, error_state.exceed_flag is True and the requested tolerance may be unmet. Increase default_strategy and recompute to allow further refinement.