Models API Reference
This page provides detailed API documentation for the microlensing models in GCMicrolensing.
Single Lens Models
High level models for simulating microlensing events.
This module provides simple classes for single-, double-, and triple-lens microlensing scenarios. The focus is on producing light curves, centroid shifts and animated visualisations for teaching or exploratory analyses.
The implementations rely heavily on the VBMicrolensing and TripleLensing packages for the low level calculations of image positions and magnifications.
- class GCMicrolensing.models.OneL1S(t0, tE, rho, u0_list)[source]
Bases:
objectSimple single-lens single-source (1L1S) model.
- Parameters:
Examples
>>> model = OneL1S(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1]) >>> model.plot_light_curve()
- plot_light_curve_on_ax(ax)[source]
Plot magnification curve on an existing axis.
- Parameters:
ax (matplotlib.axes.Axes) – Axis instance to plot on.
- plot_centroid_shift_on_ax(ax)[source]
Plot centroid shift versus time on
ax.- Parameters:
ax (matplotlib.axes.Axes) – Axis to draw the centroid shift curve on.
- class GCMicrolensing.models.TwoLens1S(t0, tE, rho, u0_list, q, s, alpha)[source]
Bases:
objectBinary-lens, single-source (2L1S) model.
Examples
>>> model = TwoLens1S(t0=0.0, tE=20.0, rho=0.01, ... u0_list=[0.1], q=0.1, s=1.5, alpha=45) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q, s, alpha)[source]
Create a binary-lens system.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in units of the Einstein radius.
u0_list (list of float) – Impact parameters of the source trajectory.
q (float) – Lens mass ratio
m2/m1.s (float) – Separation between the lenses in Einstein radii.
alpha (float) – Angle of the source trajectory in degrees.
- class GCMicrolensing.models.ThreeLens1SVBM(t0, tE, rho, u0_list, q2, q3, s12, s23, alpha, psi)[source]
Bases:
objectTriple-lens, single-source model using VBMicrolensing.
Examples
>>> model = ThreeLens1SVBM(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1], ... q2=0.1, q3=0.1, s12=1.2, s23=1.0, ... alpha=45.0, psi=30.0) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q2, q3, s12, s23, alpha, psi)[source]
Initialise the VBMicrolensing triple-lens model.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source size in Einstein radii.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s12 (float) – Separation between lens 1 and 2 in Einstein radii.
s23 (float) – Separation between lens 2 and 3 in Einstein radii.
alpha (float) – Source trajectory angle in degrees.
psi (float) – Angle between the second and third lens in degrees.
- plot_different_q3_lc(q3_values, reference_q3=None, colormap='RdPu')[source]
Compare light curves for multiple
q3values.- Parameters:
q3_values (sequence of float) – Values of the third mass fraction to compute light curves for.
reference_q3 (float, optional) – Value used as a baseline when plotting residuals. If
Nonethe first entry ofq3_valuesis used.colormap (str, optional) – Name of a matplotlib colormap for the different curves.
- class GCMicrolensing.models.ThreeLens1S(t0, tE, rho, u0_list, q2, q3, s2, s3, alpha_deg, psi_deg, rs, secnum, basenum, num_points)[source]
Bases:
objectTriple-lens model using a direct solver.
Examples
>>> model = ThreeLens1S(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1], ... q2=0.1, q3=0.1, s2=1.2, s3=1.0, ... alpha_deg=45.0, psi_deg=30.0, ... rs=0.01, secnum=10, basenum=50, num_points=100) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q2, q3, s2, s3, alpha_deg, psi_deg, rs, secnum, basenum, num_points)[source]
Initialise the direct triple-lens solver.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in Einstein units.
u0_list (list of float) – Impact parameters for which to compute trajectories.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s2 (float) – Separation of lens 2 from lens 1 in Einstein radii.
s3 (float) – Separation of lens 3 from lens 1 in Einstein radii.
alpha_deg (float) – Source trajectory angle in degrees.
psi_deg (float) – Orientation angle of the third lens in degrees.
rs (float) – Source radius used by the solver.
secnum (int) – Number of annuli used in contour integration.
basenum (int) – Number of base points used in integration.
num_points (int) – Number of time samples for the source trajectory.
OneL1S
- class GCMicrolensing.models.OneL1S(t0, tE, rho, u0_list)[source]
Bases:
objectSimple single-lens single-source (1L1S) model.
- Parameters:
Examples
>>> model = OneL1S(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1]) >>> model.plot_light_curve()
- plot_light_curve_on_ax(ax)[source]
Plot magnification curve on an existing axis.
- Parameters:
ax (matplotlib.axes.Axes) – Axis instance to plot on.
- plot_centroid_shift_on_ax(ax)[source]
Plot centroid shift versus time on
ax.- Parameters:
ax (matplotlib.axes.Axes) – Axis to draw the centroid shift curve on.
Binary Lens Models
TwoLens1S
- class GCMicrolensing.models.TwoLens1S(t0, tE, rho, u0_list, q, s, alpha)[source]
Bases:
objectBinary-lens, single-source (2L1S) model.
Examples
>>> model = TwoLens1S(t0=0.0, tE=20.0, rho=0.01, ... u0_list=[0.1], q=0.1, s=1.5, alpha=45) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q, s, alpha)[source]
Create a binary-lens system.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in units of the Einstein radius.
u0_list (list of float) – Impact parameters of the source trajectory.
q (float) – Lens mass ratio
m2/m1.s (float) – Separation between the lenses in Einstein radii.
alpha (float) – Angle of the source trajectory in degrees.
- __init__(t0, tE, rho, u0_list, q, s, alpha)[source]
Create a binary-lens system.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in units of the Einstein radius.
u0_list (list of float) – Impact parameters of the source trajectory.
q (float) – Lens mass ratio
m2/m1.s (float) – Separation between the lenses in Einstein radii.
alpha (float) – Angle of the source trajectory in degrees.
Triple Lens Models
ThreeLens1SVBM
- class GCMicrolensing.models.ThreeLens1SVBM(t0, tE, rho, u0_list, q2, q3, s12, s23, alpha, psi)[source]
Bases:
objectTriple-lens, single-source model using VBMicrolensing.
Examples
>>> model = ThreeLens1SVBM(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1], ... q2=0.1, q3=0.1, s12=1.2, s23=1.0, ... alpha=45.0, psi=30.0) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q2, q3, s12, s23, alpha, psi)[source]
Initialise the VBMicrolensing triple-lens model.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source size in Einstein radii.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s12 (float) – Separation between lens 1 and 2 in Einstein radii.
s23 (float) – Separation between lens 2 and 3 in Einstein radii.
alpha (float) – Source trajectory angle in degrees.
psi (float) – Angle between the second and third lens in degrees.
- __init__(t0, tE, rho, u0_list, q2, q3, s12, s23, alpha, psi)[source]
Initialise the VBMicrolensing triple-lens model.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source size in Einstein radii.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s12 (float) – Separation between lens 1 and 2 in Einstein radii.
s23 (float) – Separation between lens 2 and 3 in Einstein radii.
alpha (float) – Source trajectory angle in degrees.
psi (float) – Angle between the second and third lens in degrees.
- plot_different_q3_lc(q3_values, reference_q3=None, colormap='RdPu')[source]
Compare light curves for multiple
q3values.- Parameters:
q3_values (sequence of float) – Values of the third mass fraction to compute light curves for.
reference_q3 (float, optional) – Value used as a baseline when plotting residuals. If
Nonethe first entry ofq3_valuesis used.colormap (str, optional) – Name of a matplotlib colormap for the different curves.
ThreeLens1S
- class GCMicrolensing.models.ThreeLens1S(t0, tE, rho, u0_list, q2, q3, s2, s3, alpha_deg, psi_deg, rs, secnum, basenum, num_points)[source]
Bases:
objectTriple-lens model using a direct solver.
Examples
>>> model = ThreeLens1S(t0=0.0, tE=20.0, rho=0.01, u0_list=[0.1], ... q2=0.1, q3=0.1, s2=1.2, s3=1.0, ... alpha_deg=45.0, psi_deg=30.0, ... rs=0.01, secnum=10, basenum=50, num_points=100) >>> model.plot_light_curve()
- __init__(t0, tE, rho, u0_list, q2, q3, s2, s3, alpha_deg, psi_deg, rs, secnum, basenum, num_points)[source]
Initialise the direct triple-lens solver.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in Einstein units.
u0_list (list of float) – Impact parameters for which to compute trajectories.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s2 (float) – Separation of lens 2 from lens 1 in Einstein radii.
s3 (float) – Separation of lens 3 from lens 1 in Einstein radii.
alpha_deg (float) – Source trajectory angle in degrees.
psi_deg (float) – Orientation angle of the third lens in degrees.
rs (float) – Source radius used by the solver.
secnum (int) – Number of annuli used in contour integration.
basenum (int) – Number of base points used in integration.
num_points (int) – Number of time samples for the source trajectory.
- __init__(t0, tE, rho, u0_list, q2, q3, s2, s3, alpha_deg, psi_deg, rs, secnum, basenum, num_points)[source]
Initialise the direct triple-lens solver.
- Parameters:
t0 (float) – Time of closest approach.
tE (float) – Einstein crossing time.
rho (float) – Source radius in Einstein units.
u0_list (list of float) – Impact parameters for which to compute trajectories.
q2 (float) – Mass ratio of lens 2 relative to lens 1.
q3 (float) – Mass ratio of lens 3 relative to lens 1.
s2 (float) – Separation of lens 2 from lens 1 in Einstein radii.
s3 (float) – Separation of lens 3 from lens 1 in Einstein radii.
alpha_deg (float) – Source trajectory angle in degrees.
psi_deg (float) – Orientation angle of the third lens in degrees.
rs (float) – Source radius used by the solver.
secnum (int) – Number of annuli used in contour integration.
basenum (int) – Number of base points used in integration.
num_points (int) – Number of time samples for the source trajectory.
Model Parameters
Common Parameters
All microlensing models share these common parameters:
t0 (float): Time of closest approach in days
tE (float): Einstein crossing time in days
rho (float): Source radius in units of Einstein radius
u0_list (array-like): List of impact parameters
Binary Lens Parameters
q (float): Mass ratio of the second lens to the first lens
s (float): Separation between the two lenses in units of Einstein radius
alpha (float): Source trajectory angle in degrees
Triple Lens Parameters
q2 (float): Mass ratio of the second lens to the first lens
q3 (float): Mass ratio of the third lens to the first lens
s12 (float): Separation between first and second lenses
s23 (float): Separation between second and third lenses (VBM)
s2 (float): Separation between first and second lenses (TripleLensing)
s3 (float): Separation between first and third lenses (TripleLensing)
alpha (float): Source trajectory angle in degrees
psi (float): Angle between lens triangle and source trajectory (VBM)
psi_deg (float): Angle between second and third lenses (TripleLensing)
TripleLensing-Specific Parameters
rs (float): Source radius for image calculations
secnum (int): Number of sectors for image finding
basenum (int): Base number for image finding algorithm
num_points (int): Number of time points for calculations
Model Methods
All models provide these common methods:
plot_light_curve(): Plot light curves for all impact parameters
animate(): Create an animation of the microlensing event
show_all(): Create a comprehensive view with all plots
Additional methods vary by model:
OneL1S Methods
plot_centroid_shift(): Plot astrometric centroid shifts
plot_light_curve_on_ax(ax): Plot on provided matplotlib axis
plot_centroid_shift_on_ax(ax): Plot centroid shift on provided axis
TwoLens1S Methods
plot_caustic_critical_curves(): Plot caustic and critical curves
plot_centroid_trajectory(): Plot centroid shift trajectories
plot_centroid_shift(): Plot centroid shift magnitude vs time
ThreeLens1SVBM Methods
plot_caustic_critical_curves(): Plot caustic and critical curves
plot_different_q3_lc(): Plot light curves for different q3 values
ThreeLens1S Methods
plot_caustics_and_critical(): Plot caustics using VBMicrolensing
plot_centroid_trajectory(): Plot centroid shift trajectories
plot_shift_vs_time(): Plot centroid shift magnitude vs time
animate_combined(): Combined animation with both backends
get_lens_geometry(): Get lens geometry parameters
Mathematical Background
The models implement the gravitational lens equation:
where: * \(\vec{\beta}\) is the source position * \(\vec{\theta}\) is the image position * \(\vec{\alpha}\) is the deflection angle
For multiple lenses, the deflection angle is the sum of individual lens contributions:
where \(m_i\) and \(\vec{\theta}_i\) are the mass and position of the i-th lens.