Skip to content

Trajectory¤

Trajectory utilities for building source tracks in the center-of-mass frame, with independently optional annual parallax and circular orbital motion.

Classes¤

microlux.trajectory.TrajectoryParameters ¤

Bases: NamedTuple

A NamedTuple containing microlensing trajectory parameters.

Orbital rates follow VBMicrolensing and are defined at the center-of-mass t0. They are ignored unless orbital motion is enabled.

Attributes:

  • t0 (ndarray) –

    Time of closest approach, in days.

  • u0 (ndarray) –

    Impact parameter at t0.

  • tE (ndarray) –

    Einstein timescale in days.

  • rho (ndarray) –

    Source radius in units of Einstein radius.

  • alpha_rad (ndarray) –

    Trajectory angle in radians.

  • s (ndarray) –

    Projected lens separation in Einstein-radius units.

  • q (ndarray) –

    Lens mass ratio.

  • pi_E_N (ndarray) –

    North component of microlensing parallax vector. Only used when parallax is enabled.

  • pi_E_E (ndarray) –

    East component of microlensing parallax vector. Only used when parallax is enabled.

  • gamma1 (ndarray) –

    Fractional projected-separation rate (ds/dt)/s, in day^-1.

  • gamma2 (ndarray) –

    Angular rate in rad day^-1, with the sign following the VBM trajectory convention.

  • gamma3 (ndarray) –

    Fractional line-of-sight separation rate (ds_z/dt)/s, in day^-1.


microlux.trajectory.TrajectoryModel ¤

Bases: NamedTuple

A trajectory model with independent parallax and circular-orbit effects.

Attributes:

  • times (ndarray) –

    Observation times in Julian Date.

  • delta_s (ndarray | None) –

    Observer displacement in AU projected on the sky plane in (North, East), shape (N, 2). If None, parallax correction is disabled.

  • photo_center (bool) –

    Whether input parameters use the magnification center for s > 1. Output trajectories always use the center of mass.

  • orbital_motion (str | None) –

    None or "circular". Independent of delta_s.

calculate_trajectory(params: TrajectoryParameters | np.ndarray | jnp.ndarray) -> tuple[jnp.ndarray, jnp.ndarray] ¤

Return (source trajectory, lens separation), each with shape (N,).

The trajectory uses center-of-mass coordinates in the instantaneous binary-axis frame. Without orbital motion, separation is constant.

Parameters may be a TrajectoryParameters instance or a 1D array: [t0, u0, tE, rho, alpha_rad, s, q], followed by [pi_E_N, pi_E_E] when parallax is enabled. Circular motion appends [gamma1, gamma2, gamma3] (10/12 entries without/with parallax).

The returned trajectory is complex and separation is real; pass both to extended_light_curve. To plot only the source, unpack trajectory, _.

Reference frame

With photo_center=False, the orbital reference epoch is params.t0. With photo_center=True and s > 1, input parameters refer to the magnification center and are converted to the center of mass:

shift = q / (1 + q) * (s - 1 / s)
t0_com = t0 + tE * shift * cos(alpha_rad)
u0_com = u0 + shift * sin(alpha_rad)

The shift uses the reference separation s and stays fixed along the trajectory; it is not recomputed from s(t). For s <= 1 it is zero. The reference s, alpha_rad, and orbital rates refer to t0_com. The parallax reference epoch t0_par is independent of this epoch.

Circular orbit

Away from the numerical boundary handling below, the circular constraint fixes the line-of-sight separation s_z/s = -gamma1/gamma3 at the reference epoch. The projected separation can therefore vary even though the three-dimensional orbit is circular.

Following VBMicrolensing, hypot(gamma1, gamma3) <= 1e-8 selects a face-on orbit with constant separation and angular rate gamma2. All-zero rates recover the static/parallax model. Otherwise abs(gamma3) is floored at 1e-8 day^-1, preserving its sign and taking zero as positive. Opposite signs give the same projected orbit. This numerical convention does not uniquely continue the physical orbit through the degenerate parameters.

Fitting

Start a full orbital fit near static with (gamma1, gamma2, gamma3) = (0, 0, 1e-6), rather than all zeros. RTModel uses a gamma3 lower bound of 1e-7 day^-1 in its fitter; configure such a bound in your optimizer or sampler, since this forward model does not impose it. Derivatives in the floored region or across the branch boundary follow the numerical guard; avoid those regions for inference and Fisher calculations.


Functions¤

microlux.trajectory.get_trajectory_model(times: np.ndarray, coords: Coordinates | None = None, t0_par: float | None = None, photo_center: bool = False, *, orbital_motion: str | None = None) -> TrajectoryModel ¤

Build a trajectory model with optional annual parallax and circular orbit.

Parameters:

  • times (ndarray) –

    Observation epochs in full JD or reduced JD (JD - 2450000).

  • coords (Coordinates | None, default: None ) –

    Source sky coordinates; required only for annual parallax.

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

    Parallax reference epoch. If None, parallax is disabled.

  • photo_center (bool, default: False ) –

    Whether input parameters use the magnification center for s > 1; output is always in the center-of-mass frame.

  • orbital_motion (str | None, default: None ) –

    None or "circular", independently of parallax.

Returns:

Notes
  • Use the same full or reduced JD convention for times, t0, and t0_par.
  • Annual ephemerides are precomputed here, outside JAX differentiation. The returned model stores the observer displacement in delta_s, in AU projected onto North/East. This factory computes annual parallax only.
  • Named TrajectoryParameters work with every combination of effects. See TrajectoryModel.calculate_trajectory for array layouts, reference frames, and orbital boundary handling.