---
title: 'Pysersic: Bayesian Galaxy Fitting'
url: https://www.emergentmind.com/topics/pysersic-8083cdae-64b2-4077-8f89-ae306e4b9141
type: topic
---

# Pysersic: Bayesian Galaxy Fitting

Searching arXiv for papers on pysersic and recent uses.
`pysersic` is a Python package for determining galaxy structural properties via Bayesian inference, accelerated with jax. It was introduced as a framework for fitting parametric galaxy light profiles directly to imaging data, with explicit treatment of the point-spread function and posterior uncertainty, and it is designed for both interactive use and integration into survey-scale analysis pipelines [2306.05454]. Across subsequent work, it has been used for single-source fitting, multi-source fitting, wavelength-dependent morphology, catalog production, and methodological development for faster Fourier-space rendering [2306.05454; 2508.20266].

## 1. Software definition and scope

At its core, `pysersic` addresses a standard task in extragalactic astronomy: inferring structural parameters such as total flux, effective radius, Sérsic index, ellipticity, position angle, and centroid from galaxy images. The package is written in pure Python and built using `jax`, which provides just-in-time compilation, auto-differentiation, and execution on CPUs, GPUs, or TPUs. Inference is performed with `numpyro`, enabling gradient-based posterior estimation through methods such as No-U-Turn Sampling, as well as optimization-based point estimation and stochastic variational inference [2306.05454].

The software was presented as a Bayesian alternative within the ecosystem of profile-fitting tools that also includes GALFIT, IMFIT, ProFit, GaLight, PetroFit, and PyAutoGalaxy. Its distinguishing emphasis is the combination of probabilistic programming, hardware acceleration, and direct access to full posterior distributions rather than only point estimates [2306.05454]. This suggests that `pysersic` is intended not merely as a fitting executable but as an inference framework whose outputs can be propagated into downstream population-level analyses.

The package has since been used in distinct observational regimes: HST imaging of post-starburst galaxies at \(1<z<1.3\) [2407.21257], optical and ultraviolet morphology from JWST at \(4<z<8\) [2412.06957], low-mass galaxy size measurements across environments in the SAGA survey [2509.25335], and large morphology catalogs in Abell 2744 [2603.00380]. Those applications establish `pysersic` as a general-purpose structural fitting framework rather than one tied to a single instrument or redshift range.

## 2. Parametric model and computational methods

The standard profile used by `pysersic` is the Sérsic law,
\[
I(R) = I_e \exp\left\{ -b_n \left[ \left(\frac{R}{R_e}\right)^{1/n} - 1 \right] \right\},
\]
where \(I(R)\) is the surface brightness at radius \(R\), \(I_e\) is the surface brightness at the effective radius \(R_e\), \(R_e\) is the half-light radius, \(n\) is the Sérsic index, and \(b_n\) is chosen so that half the total luminosity lies within \(R_e\) [2407.21257; 2306.05454]. In practical fits, the free parameters commonly include flux, \(R_e\), \(n\), ellipticity or axis ratio, position angle, central coordinates, and a flat sky background [2407.21257; 2509.25335].

A central computational issue in Sérsic fitting is rendering the model accurately enough for PSF convolution and likelihood evaluation. `pysersic` was described with multiple rendering strategies: oversampled real-space rendering, Fourier-space rendering via a sum of Gaussians, and a hybrid real-Fourier algorithm intended to improve speed and reduce aliasing while handling steep inner profiles [2306.05454]. Because `jax` supplies automatic differentiation, these rendering pipelines are compatible with gradient-based optimization and sampling [2306.05454].

A later development replaced expensive approximations to the radial Fourier transform with a symbolic-regression emulator implemented in `pysersic`. In injection-recovery tests on 500 synthetic galaxies, the emulator achieved residual scatter in \(n\) and \(R_{\rm eff}\) below \(2\%\) and average bias below \(0.5\%\); on a real sample of 100 galaxies in HSC-SSP imaging, recovered parameters were nearly identical to the default hybrid renderer, with \(<1\%\) median difference, \(2.6\%\) scatter in \(R_{\rm eff}\), and \(4.9\%\) scatter in \(n\). The median MCMC runtime per galaxy decreased from 64 seconds to 23.5 seconds, a \(2.5\times\) speed-up [2508.20266]. A plausible implication is that rendering, rather than only inference, has become a primary optimization target for survey-scale morphology pipelines.

## 3. Bayesian inference workflow

The generic `pysersic` workflow consists of providing an image cutout and, optionally, a PSF; configuring priors and the model; running inference; and inspecting best-fit parameters and posterior samples [2306.05454]. The package supports automatic priors derived from the image as well as user-specified priors, and the outputs include best-fit parameters, posterior samples, and diagnostic products [2306.05454].

Published applications show how this abstract workflow is operationalized. In HST/WFC3 F110W imaging of DESI post-starburst galaxies, source extraction and deblending were performed with SEP, segmentation maps were used for masking, empirical PSFs were constructed to account for spatial variation and drizzling artifacts, and all unmasked sources plus the sky were fitted simultaneously in each cutout [2407.21257]. In the SAGA size-mass study, `pysersic` fits were performed independently in each of the \(g\), \(r\), and \(z\) bands, with contaminating sources masked using `sep` and priors informed by image statistics from `photutils` [2509.25335]. In the Abell 2744 catalog, sources were fit independently in each band using empirical PSFs, simultaneous modeling of bright neighbors when needed, and two inference regimes: SVI-MVN for all \(\mathrm{SNR}>10\) sources and NUTS additionally for \(10<\mathrm{SNR}<100\) objects [2603.00380].

The package’s Bayesian formulation matters scientifically because it makes uncertainty and parameter covariance first-class outputs rather than afterthoughts. That property was explicitly used in applications requiring error propagation into scaling-relation fits, injection-recovery validation, or comparison between subtle environmental or evolutionary effects [2509.25335; 2412.06957; 2603.00380].

## 4. Multiband fitting and survey-scale extensions

`pysersic` has also been extended beyond independent single-band fits. In JWST UNCOVER and MegaScience analyses of galaxies at \(4<z<8\), a `multiband` module was developed from v0.1.4 onward to fit six NIRCam wide filters simultaneously. In that implementation, central position and position angle were fixed across bands, each band’s total flux was fitted independently, and effective radius, Sérsic index, and ellipticity were allowed to vary smoothly with wavelength through a 2nd-order B-spline with 3 knots [2412.06957]. The joint model increased the precision of measured radii by \(50\%\) [2412.06957].

Large-catalog work has stressed a different form of extensibility: scale. In Abell 2744, `pysersic` was used to derive spectrally resolved structural measurements for 29,608 sources over observed \(0.7\,\mu{\rm m}-4.8\,\mu{\rm m}\), mainly from 20 JWST NIRCam broad and medium bands. Through quality evaluation criteria, robust structural parameters were inferred for more than \(90\%\) of selected \(\mathrm{SNR}>10\) sources, and injection-recovery tests established fractional error below \(10\%-20\%\) above \(\mathrm{SNR}>10\) [2603.00380]. The same study used the fitted size-wavelength relations to infer rest-frame UV, optical, and near-infrared sizes [2603.00380].

Independent-band fitting remains important where direct wavelength coupling is not desired. In JADES imaging used to study galaxies at \(z\approx4-6\), `pysersic` was applied band by band with stochastic variational inference and posterior checks against MCMC, producing continuum sizes, Sérsic indices, axis ratios, and position angles that were later compared across rest-frame FUV, NUV, and optical bands [2510.06315]. The coexistence of these strategies indicates that `pysersic` functions both as a single-image fitter and as a substrate for higher-level modeling of wavelength-dependent morphology.

## 5. Scientific applications

The package’s scientific role is best understood through representative studies.

| Study | Dataset or regime | `pysersic` contribution |
|---|---|---|
| DESI post-starburst galaxies [2407.21257] | 171 massive PSBs at \(1<z<1.3\) with HST/WFC3 F110W | Structural fitting showed PSBs are \(\sim0.1\) dex smaller than quiescent galaxies, have \(\log(\Sigma_{1\,\rm kpc}/(M_\odot/{\rm kpc}^2))\sim10.1\), \(b/a_{\rm median}\sim0.8\), and \(n_{\rm median}\sim3\) |
| SAGA Survey VI [2509.25335] | Low-mass galaxies across environments | Uniform fits showed SAGA satellites are larger than isolated galaxies by \(0.05\) to \(0.12\) dex, with similar Sérsic index distributions |
| UNCOVER high-\(z\) sizes [2412.06957] | 995 galaxies at \(4<z<8\) from JWST | Simultaneous multiband fitting yielded \(50\%\) better radius precision and supported growth from 400 pc at \(z=8\) to 830 pc at \(z=4\) at \(\log M_*/M_\odot=8.5\) |
| Abell 2744 global catalog [2603.00380] | 29,608 sources over 20 NIRCam bands | Produced quality-flagged posteriors and rest-frame size estimates over \(0.3<z<8\) |
| Cosmic-noon quiescent galaxies [2605.02493] | 14 massive quiescent galaxies at \(2<z<3\) | Morphological analysis found median \(n\sim4\) and mean \(R_e = 1.95 \pm 0.13\) kpc |

In the DESI post-starburst study, `pysersic` underpinned the conclusion that massive PSBs are more compact than the general quiescent population while having similar central surface mass densities, which the authors reconciled through later ex-situ growth via minor mergers or slight progenitor bias [2407.21257]. In SAGA, a uniform `pysersic` pipeline was necessary because the environmental size offsets under investigation were as small as \(0.04\)–\(0.12\) dex, making method-dependent systematics a major concern [2509.25335].

At very high redshift, the package enabled direct population-level size-mass analyses. The UNCOVER work used joint multiband modeling to show rapid growth in average size for low-mass galaxies in the first billion years, while the JADES-based study in \(z\approx4-6\) galaxies found no significant differences between stellar continuum sizes at FUV, NUV, and optical wavelengths, with \(r_{\rm e,cont}\approx0.9\) kpc at \(\log(M_\star [{\rm M_\odot}])=9.5\) [2412.06957; 2510.06315]. These results illustrate that `pysersic` has been used both to detect wavelength dependence and to establish its absence.

## 6. Validation, limitations, and interpretive cautions

The package has repeatedly been validated against external methods and simulated data. In the DESI post-starburst analysis, cross-checks with single-component GALFIT fits found no significant systematic differences, with median \(\log(R_{e,{\rm pysersic}})-\log(R_{e,{\rm GALFIT}})\sim0.03\) dex [2407.21257]. In the SAGA analysis, comparisons with Tractor, NSA, and SGA showed only very small global offsets below \(0.1\) dex, and \(88\%\) of `pysersic` sizes were within \(0.1\) dex of Tractor values [2509.25335]. In the Abell 2744 catalog, injection-recovery tests showed systematic bias below \(2\%\) for \(\mathrm{SNR}>10\) [2603.00380].

At the same time, the literature emphasizes important limits. Many studies fit all galaxies with a single-component Sérsic model; this is standard for statistical work, but it cannot capture complex morphologies, barred systems, or strongly clumpy structures in detail [2509.25335; 2510.06315]. Some applications therefore added residual corrections or adopted two-component models. In the DESI post-starburst study, a residual-correction method based on adding the masked residual profile to the analytic Sérsic profile altered sizes only slightly, with \(|R_{e,\rm corrected}-R_{e,\rm direct}|\sim0.04\) arcsec [2407.21257]. In the cosmic-noon quiescent-galaxy analysis, `pysersic` was used with a Sérsic-plus-exponential two-component model to extract bulge-to-total ratios alongside Sérsic indices and axis ratios [2605.02493].

The most explicit caution concerns extremely compact JWST “little red dots.” Simulations showed that `pysersic` and GALFIT have difficulty recovering input parameters at \(\mathrm{SNR}\lesssim25\), that estimated PSF fraction may be a more robust physically motivated description of compactness, and that almost all modeled LRDs with \(\mathrm{SNR}\lesssim50\) cannot be differentiated from a point source regardless of intrinsic extent [2509.21236]. That work reported that \(\sim85\%\) of observed LRDs are PSF-dominated and \(\sim15\%\) show lower estimated PSF fractions or fitted sizes \(\gtrsim150\) pc, implying morphological diversity rather than a homogeneous population [2509.21236].

A further caution arises from uncertainty calibration. In the Abell 2744 catalog, the width of the posterior distribution underestimated the true error by a factor of \(\sim2\) for flux and size and \(\sim1.5\) for Sérsic index in injection-recovery tests, and users were advised to inflate the reported \(1\sigma\) uncertainties accordingly [2603.00380]. This suggests that posterior precision in practical survey pipelines must be interpreted together with empirical calibration, especially near the detection limit or under model mismatch.

Source: https://www.emergentmind.com/topics/pysersic-8083cdae-64b2-4077-8f89-ae306e4b9141