Quickstart

This page gets you from a fresh install to a working King PDF evaluation in a few lines. See Examples for the deeper workflows (fitting PSF parameters from Monte Carlo, the end-to-end likelihood wrapper, and template smearing).

Evaluate a King PDF

KingPDF is the core class. It is constructed with an angular_cutoff (in radians, defaulting to \(\pi\), i.e. the full sphere) and exposes pdf/cdf methods that accept the King distribution parameters alpha (core scale, radians) and beta (tail weight, must be greater than 1):

import numpy as np
from kingmaker.pdf import KingPDF

# Full-sphere coverage; restrict via angular_cutoff to limit the
# PDF's support (e.g. to a search window) and renormalize accordingly.
king = KingPDF(angular_cutoff=np.pi)

alpha = np.radians(1.0)  # 1 degree core scale
beta = 2.0               # moderate tail weight

angles = np.linspace(0, np.radians(10), 100)
pdf_values = king.pdf(angles, alpha, beta)
cdf_values = king.cdf(angles, alpha, beta)

Compute a containment radius

Because the CDF is monotonic, standard root-finding gives containment radii directly:

from scipy.optimize import brentq

containment_68 = brentq(
    lambda x: king.cdf(x, alpha, beta) - 0.68,
    0, np.pi,
)
print(f"68% containment radius: {np.degrees(containment_68):.2f} degrees")

Next steps