Skip to content

Fitting¤

Fit source and blend fluxes for several photometric data sets and compute a Fisher matrix from the resulting residuals.


microlux.fit_grouped_fluxes(magnification: jax.Array, flux: jax.Array, flux_err: jax.Array, group_ids: jax.Array, *, n_groups: int) -> GroupedFluxFit ¤

Fit source and blend fluxes for each group with JAX.

Parameters:

  • magnification (Array) –

    Finite magnifications of shape (N,).

  • flux (Array) –

    Finite observed fluxes of shape (N,).

  • flux_err (Array) –

    Positive uncertainties of shape (N,). Use infinity for zero-weight padding with finite flux and magnification.

  • group_ids (Array) –

    Integer labels of shape (N,), contiguous from zero to n_groups - 1. Observations may be interleaved.

  • n_groups (int) –

    Number of groups, fixed when tracing a JIT function.

Returns:

  • result ( GroupedFluxFit ) –

    Weighted least-squares solution of flux = source_flux[group_ids] * magnification + blend_flux[group_ids]. Differentiation includes the dependence of the fitted fluxes on the supplied magnifications.

Notes

Accepts NumPy or JAX arrays and supports JIT and automatic differentiation. Each group needs a full-rank weighted source/blend design. Validate data values and handle degenerate fits in the caller. Only shapes and label dtype are checked here.


microlux.GroupedFluxFit ¤

Bases: NamedTuple

Analytic source/blend-flux fit for independent photometric groups.

Attributes:

  • source_flux (Array) –

    Source flux for each group, shape (G,).

  • blend_flux (Array) –

    Blend flux for each group, shape (G,).

  • covariance (Array) –

    Source/blend covariance per group, shape (G, 2, 2), conditional on the supplied magnifications and errors.

  • model_flux (Array) –

    Fitted fluxes in observation order, shape (N,).

  • residuals (Array) –

    (flux - model_flux) / flux_err, shape (N,).

  • chi2_by_group (Array) –

    Sum of squared residuals per group, shape (G,).


microlux.fisher_information(residual_fn: Callable[[jax.Array], jax.Array], params: jax.Array) -> jax.Array ¤

Return the Gauss--Newton Fisher matrix of normalized residuals.

Parameters:

  • residual_fn (Callable) –

    Function mapping params to one-dimensional normalized residuals of shape (N,).

  • params (Array) –

    Parameter vector of shape (P,).

Returns:

  • fisher_matrix ( Array ) –

    J.T @ J of shape (P, P), where J is the residual Jacobian. Supports JIT compilation.