Michele Cappellari Python Programs


The software below is freely available. However, if you use it for published research, you are requested to cite the paper highlighted in red where the method is described.

You are not allowed to re-distribute any of these programs (modified or not) without explicit permission from the author.

All my packages below are on the Python Package Index PyPI.

See my review on galaxy structure and evolution image


1 MgeFit: Multi-Gaussian Expansion Fitting

Robust technique to perform Multi-Gaussian Expansion (MGE) fits to galaxy images

1.1 The Method

Figure 1: Illustration of the steps involved in the MGE fit to the S0 galaxy NGC 4342 using the MgeFit package. The figures were produced by the mge_fit_example.py script included in the Python distribution of the software.

This software obtains an accurate Multi-Gaussian Expansion (MGE) parametrization (Cappellari 2002; Emsellem et al. 1994) for a galaxy surface brightness with the fitting algorithm of Cappellari (2002). Given that Gaussians are not orthogonal functions, MGE fits are in general strongly degenerate, with difficult global convergence, but the mge_fit_sectors method solves all problems, making MGE fitting an automated, reliable and robust process (Figure 1).

See Cappellari et al. (2013b) and Zhu et al. (2024) for large scale applications of this software to the study of the M/L ratio and the Fundamental Plane of early-type galaxies and Cappellari et al. (2012) for an application to the study of the stellar IMF. The MGE parametrization is useful in the construction of realistic dynamical models of galaxies (see JAM in Section 2), for PSF deconvolution of images, for the correction and estimation of dust absorption effects, or for galaxy photometry.

1.2 The MgeFit package in Python

The pure-Python code of the MgeFit package, including four test galaxy images, is on the Python Package Index PyPI.

How to install: Use pip install mgefit. Without write access to the global site-packages directory, use pip install --user mgefit.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

MgeFit requires the scientific core packages NumPy, SciPy and Matplotlib, and the examples use Astropy to read FITS images.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download the above procedures.


2 JAM: Jeans Anisotropic Modelling JAM

Jeans Anisotropic Modelling of the dynamics, stellar kinematics or proper motions of axisymmetric or spherical galaxies

2.1 The Method

Figure 2: (a) Including both proper motions and radial velocities. Top Panels: the components of the symmetric velocity second moment tensor measured from the particles of a realistic N-body simulation. Bottom Panels: the corresponding JAM model predictions. Note the striking agreement! (Cappellari et al. 2012). (b) The JAM package includes an implementation for both the cylindrically-aligned solution JAMcyl of Cappellari (2008) and the spherically-aligned solution JAMsph of Cappellari (2020). Comparisons between these two extreme solutions allows for a robust assessment of possible systematic modeling uncertainties (see Cappellari 2020, for some examples). (c) Validating black hole (BH) recovery with JAM. A detailed JAM modelling accurately recovers the “benchmark” BH mass in NGC4258, as inferred from maser observations (Drehmer et al. 2015, fig. 11). An equally good agreement was found with JAM for the “benchmark” BH in the Milky Way (Feldmeier-Krause et al. 2017, sec. 4.1.2). Other successful BH comparisons, between JAM and Schwarzschild’s method, were presented e.g. in Cappellari et al. (2010), for 25 galaxies, and Krajnović et al. (2018), for 7 galaxies. (d) This is the first dynamical modelling (using JAMsph) of the high-quality Gaia DR2 kinematics of the Milky Way, with full 6D phase-space coordinates. For the first time, there is no dynamical degeneracy and the model has no freedom to fit the data, yet all features are reproduced. This is an important test of galaxy dynamics (Nitschai et al. 2020, fig. 1).
Figure 3: Examples of JAM data-model comparisons. The bi-symmetrized SAURON stellar kinematics of 6 Elliptical (left) and 6 S0 (right) fast-rotator early-type galaxies is compared to the predictions of the anisotropic Jeans models with JAM. The kinematics varies widely for different galaxies, yet these two-parameter models are able to correctly predict the shape of a pair of two-dimensional functions (V and Vrms), once the observed surface brightness is given (Cappellari 2016, fig. 10).
Figure 4: Left Panel: JAM works better than Schwarzschild’s method on simulated galaxies. A detailed comparison using the Illustris simulations with the JAM and Schwarzschild’s (SCH) dynamical models, found that JAM recovers the known enclosed total mass within 1Re more accurately than SCH. Specifically, the 68th percentile deviation (1σ error) over all 45 model fits is 1.6× smaller for JAM than SCH (Jin et al. 2019, fig. 4). Right Panel: JAM works better than Schwarzschild’s method on real galaxies. A detailed comparison, for 54 real disk galaxies with CALIFA data, between the circular velocity VCO measured from CO gas and the corresponding VJAM and VSCH from dynamical modelling of integral-field stellar kinematics using the JAM and Schwarzschild’s (SCH) methods, found that JAM recovers the densities more accurately than SCH. Specifically, between 0.8–1.6 Re (inside the red boxes), where the gas is well-resolved and Vc is better determined, the mean 1σ error is 1.7× smaller for JAM than SCH (Leung et al. 2018, fig. 8).

The JAM software in this section can be used for the dynamical modelling of galaxies or other gravitationally-bound systems of particles. It was used e.g. to measure the mass of supermassive black holes in galaxies, to infer their dark-matter content or to measure galaxy masses and density profiles.

JAM implements a solution of the Jeans equations which allows for orbital anisotropy (three-integrals distribution function) and also provides the full second moment tensor, including both proper motions and radial velocities (Figure 2a), for both axisymmetric (Cappellari et al. 2012) and spherical geometry (Cappellari 2015). The technique was introduced in Cappellari (2008), for the cylindrically-aligned case, and in Cappellari (2020), for the spherically-aligned case (Figure 2b), and I called it the Jeans Anisotropic Modelling (JAM) method. It relies on the Multi-Gaussian Expansion parametrization (Cappellari 2002; Emsellem et al. 1994) for the galaxy surface brightness.

With the addition of a single extra parameter βz = 1 − (σz/σR)2 (in cylindrical alignment) or βr = 1 − (σθ/σr)2 (in spherical alignment), the simple and user-friendly three-integrals JAM method already provides a dramatic improvement over the classic but less general two-integrals f(E, Lz) Jeans (1922) models. However, JAM also allows for tangential anisotropy γ = 1 − (σϕ/σR)2 and/or for spatially varying anisotropy (different for every MGE Gaussian). The JAM models provide an excellent description of state-of-the-art integral-field stellar kinematics of real galaxies (Figure 3). This makes the technique well suited to measure the inclination, the dynamical M/L and angular momenta of early-type fast-rotators and spiral galaxies. JAM was found to be more accurate than Schwarzschild modelling when measuring the density profiles of both real and simulated galaxies (Figure 4).

The JAM routines are designed for axisymmetric or spherical geometry, (i) they can provide the proper motion dispersion tensor (Cappellari 2012, 2015) (Figure 2a), (ii) allow for the inclusion of dark matter, (iii) variable stellar M/L, (iv) spatially varying anisotropy and (v) multiple kinematic components and (vi) supermassive black holes (BH; Figure 2c). The JAM package also includes a routine to compute the circular velocity from the MGE models. Some sample applications of the JAM method are given below:

To construct dynamical models with the JAM method one needs to describe the galaxies surface brightness via the Multi-Gaussian Expansion parametrization using my MgeFit package in Section 1.

2.2 The JAM package in Python

The source code of the JamPy package is on the Python Package Index PyPI.

How to install: Use pip install jampy. Without write access to the global site-packages directory, use pip install --user jampy.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

Also required is my plotbin package (automatically installed by pip).

The pure-python JamPy package only requires the scientific core packages NumPy, SciPy and Matplotlib.

2.3 The JAM method (cylindrical-only) in the C language

Note that the JAM Python code is extremely well vectorized. You should not assume the C version will be significantly faster without benchmarking with identical setup. Also note that the C version only implements the cylindrically aligned JAM solution, not the spherically-aligned one. Laura Watkins has translated the JAM procedures into the C language. Laura’s code is available here.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download the above procedures.


3 VorBin: Voronoi Binning VorBin

Adaptively spatial bin two-dimensional data to a constant signal-to-noise ratio per bin

3.1 The Method

Figure 5: Left: Four-coloring of Voronoi binning; Middle: Unbinned versus Voronoi binned stellar kinematics from Integral-Field Spectroscopy (Cappellari & Copin 2003); Right: Voronoi binning of abundance from X-ray data (Sanders et al. 2004).

The Voronoi Binning method by Cappellari & Copin (2003) optimally solves the problem of preserving the maximum spatial resolution of general two-dimensional data (or higher dimensions), given a constraint on the minimum signal-to-noise ratio (Figure 5).

The Voronoi binning method has been applied to a variety of types of data. A review of the concepts and applications to (i) X-ray data, (ii) integral-field spectroscopy, (iii) Fabry-Perot interferometry, (iv) N-body simulations, (v) standard images and (vi) other regularly or irregularly sampled data is given in Cappellari (2009).

3.2 The VorBin package in Python

The source code of the VorBin package, with examples and instructions, is on the Python Package Index PyPI.

How to install: Use pip install vorbin. Without write access to the global site-packages directory, use pip install --user vorbin.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

The VorBin package requires the scientific core packages NumPy, SciPy and Matplotlib.

My optional plotbin package contains routines to visualize Voronoi 2D-binned or unbinned data like in Figure 5.

3.3 The VorBin package in Julia

VorBin was ported to the Julia language by Michael Reefe. You can find it HERE.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download the above procedures.


4 pPXF: Penalized Pixel-Fitting pPXF

Stellar or gas kinematics and stellar population from galaxy spectra via full spectrum fitting with photometry

4.1 The Method

Figure 6: Left: Stellar and gas kinematics fit with pPXF. The black line (mostly hidden by the fit) is the relative flux of the observed spectrum. The red line is the pPXF fit for the stellar component, while the orange line is a fit to the gas emission lines. The green symbols at the bottom are the fit residuals, while the blue lines is the gas-only best-fitting spectrum. The main absorption and emission features are indicated at the top of the plot (Cappellari 2017, fig. 1). Right: Spectra and photometry with pPXF. The top panel shows a fit to the 28-bands COSMOS photometry for a galaxy in the LEGA-C survey at redshift z ≈ 0.7. The grey band indicates where the spectrum is also available. The middle panel is the fit to the spectrum and gas emission. The bottom panel shows the recovered star formation history (SFH) using 43(Ages)×9([M/H])=387 FSPS population templates (Cappellari 2023, fig. 5).

This software implements the Penalized PiXel-Fitting method (pPXF) to extract the stellar or gas kinematics (Figure 6 Left) and stellar population (Figure 6 Right) from absorption-line spectra of galaxies, using a maximum penalized likelihood approach. The method was originally described in Cappellari & Emsellem (2004) and was significantly upgraded in subsequent years and particularly in Cappellari (2017) and with the inclusion of photometry and linear constraints in Cappellari (2023). The method is very general and robust. For this reason it was applied to a variety of situations. The following key features are implemented in the current pPXF program:

  • Optimal template: Fitted together with the kinematics to minimize template-mismatch errors. Also, useful to extract gas kinematics or derive emission-corrected line-strengths indexes. One can use synthetic templates to study the stellar population of galaxies via “Full-Spectrum Fitting” instead of using traditional line-strengths;
  • Regularization of template weights: To reduce the noise in the recovery of the stellar population parameters and attach a physical meaning to the output weights assigned to the templates in term of the star formation history (SFH) or metallicity distribution of an individual galaxy;
  • Multiple gaseous/stellar components: Each template in pPXF can be assigned to a different kinematic component, with a different LOSVD (Johnston et al. 2013). This allows one to extract multiple kinematic components and to fit the gas emission lines together with the stellar kinematics and population; Penalization applies to both gas and stars and regularization can still be enforced to the stellar templates;
  • Fitting photometry and spectra: One can fit multiple photometric bands (SED) simultaneously with a spectrum (Cappellari 2023);
  • Kinematic bulge/disk decomposition: One can enforce a ratio between the flux of two kinematic components, e.g., to try to infer the kinematic of bulge and disk components (Tabor et al. 2017);
  • Linear constraints on templates or kinematics: One can enforce general linear constraints on either the stellar templates (e.g., require the total weights in one kinematic component to be larger than a certain fraction) or the kinematic parameters (e.g., requiring the dispersion of one kinematic component to be larger than a certain fraction of that of another component) (Cappellari 2023);
  • Iterative sigma clipping: To clean the spectra from residual bad pixels or cosmic rays;
  • Two-sided LOSVD fitting: To reduce systematic errors in the kinematics, using two spectra taken at the opposite sides of the galaxy nucleus (Rix et al. 1992, sec. 3.6);
  • Additive/multiplicative polynomials: To correct low frequency continuum variations. Also useful for calibration purposes;
  • Inclusion of sky spectrum: To deal with spectra heavily contaminated by the sky spectrum (Weijmans et al. 2009, sec. 3.1);
  • Reddening fit: To determine the reddening of the spectrum using the extinction curve of (Calzetti et al. 2000);
  • Inclusion of covariance matrix: To account for correlated errors in the spectral pixels (e.g. due to rebinning and interpolations).

See Emsellem et al. (2004, SAURON), Cappellari et al. (2011, ATLAS3D), Falcón-Barroso et al. (2017, CALIFA), van de Sande et al. (2017, SAMI) and Westfall et al. (2019, MaNGA) for some ever-increasing large-scale applications of the pPXF method to the measurement of the stellar or gas kinematics of galaxies.

4.2 Libraries of models for stellar-population with pPXF

image

Figure 7: pPXF is the most accurate full-spectrum fitting method (and the fastest too). In a detailed study, pPXF was found to produce the smallest errors (compared to the known true values) and to be significantly faster than all other full-spectrum fitting codes (Woo et al. 2024, fig. 14).

pPXF is the most efficient, reliable and flexible implementation of the “Full-Spectrum Fitting” method to study stellar populations (see Figure 7). This technique has effectively rendered the traditional line-strength indices obsolete, facilitated by the development of high-quality spectral models. pPXF was designed to be independent on any specific set of stellar-population models and has already been used with nearly every available one. Here is an incomplete list of stellar population models that were used with pPXF:

pPXF allows one to extract multiple kinematic components, with different stellar populations, from a spectrum. Gas emission lines can be fitted simultaneously, avoiding the need for masking them. This is particularly useful when studying the stellar population of galaxies with prominent emission lines (e.g., the Balmer lines) filling important absorption features (see Figure 6).

Please also cite the source of the stellar population models HERE if you use pPXF with any of the included libraries of spectral templates.

4.3 Libraries of stellar templates for stars/gas kinematics with pPXF

The ability of the pPXF method to fit a large set of stellar templates together with the kinematics allows the template mismatch problem to be virtually eliminated. This is particularly useful given the current availability of large stellar libraries spanning wide ranges of physical parameters and having good spectral resolution. Excellent results have been obtained by using a few hundred template stars with pPXF, from which generally about 10-20 are selected by the program to provide detailed fits to high S/N galaxy spectra. An incomplete list of libraries that have been successfully used with pPXF for the kinematics extraction is given below:

  • Indo-U.S. Coudé Feed Spectral Library: 1273 stars covering the region from 3460 – 9464 Å at a spectral resolution of 1.35 Å (FWHM), σ ≈ 30 km/s, R ≈ 4200. From Valdes et al. (2004)
  • Ca II triplet : 706 stars covering the region from 8348 – 9020 Å at a spectral resolution of 1.5 Å (FWHM), σ ≈ 22 km/s, R ≈ 5700. From Cenarro et al. (2001)
  • ELODIE: 1388 stars covering the region from 4000 – 6800 Å at a spectral resolution of 0.5 Å (FWHM), σ ≈ 13 km/s, R ≈ 10, 000. From Prugniel & Soubiran (2001)
  • MILES Library of Stellar Spectra: 985 well-calibrated stars covering the region from 3525 – 7500 Å at a spectral resolution of 2.51 Å (FWHM), σ ≈ 64 km/s, R ≈ 2000. From Sánchez-Blázquez et al. (2006) and Falcón-Barroso et al. (2011)
  • MaStar Stellar Library: 10K well-calibrated stars covering the region from 3,622 – 10,354 Å at a spectral resolution of 3.5 Å (FWHM), σ ≈ 70 km/s, R ≈ 1800. From Yan et al. (2019).
  • X-Shooter Spectral Library: 683 stars covering three segments from 3,000 – 24,500 Å at a spectral resolution with σ ≈ 13 km/s, R ≈ 10, 000. From Verro et al. (2022b).
  • GNIRS library of late spectral templates: 40 stars with a range of CO equivalent widths, covering the K-band region from 2.18 – 2.43 μm at a spectral resolution of 3.4 Å (FWHM), σ ≈ 19 km/s, R ≈ 6600. From Winge et al. (2009)
  • MARCS synthetic library of stellar spectra covering the wavelength region from 1300 Å to 20 μm at a spectral resolution of σ ≈ 6.4 km/s, R ≈ 20, 000. This is not as reliable as an empirical stellar library but it can be very useful in special situations, due to the wide wavelength coverage and high spectral resolution. From Gustafsson et al. (2008)
  • SYNTHE synthetic library of stellar spectra covering the wavelength region from 2500 Å to 1.05 μm at a spectral resolution of σ ≈ 6.4 km/s, R ≈ 20, 000. The same caveats and advantages apply to this synthetic library as to the previous one. From Munari et al. (2005)

4.4 The pPXF package in Python

The source code of the ppxf package, with examples and instructions, is on the Python Package Index PyPI.

How to install: Use pip install ppxf. Without write access to the global site-packages directory, use pip install --user ppxf.

Usage examples: Jupyter image Notebooks ppxf examples are available HERE. Python examples are in the directory “examples” inside the main ppxf package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

ppxf is written in pure Python and only requires the scientific core packages NumPy, SciPy and Matplotlib, and the examples use Astropy to read FITS data.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download the above procedures.


5 CapFit: Constrained Nonlinear Least-Squares CapFit

A Python package for efficient and robust constrained nonlinear least-squares fitting

5.1 The Method

Figure 8: This is the kind of linearly-constrained non-linear least-squares problems that CapFit is designed to solve. The contours show the Rosenbrock function, which is a popular benchmark for non-linear least-squares methods. The magenta dot is the unconstrained minimum; the red dot is the minimum subject to the linear equality constraints (red line); the green dot is the minimum subject to the linear inequality constraints (green triangle), while the yellow dot satisfies both the equality and inequality constraints. The white line shows the feasible steps taken by CapFit to reach the inequality constrained solution, starting from (x, y) = (−1.9, 1.7).

CapFit solves linearly-constrained (and some classes of non-linearly-constrained) non-linear least-squares optimization problems. It was designed to be extremely robust to degeneracy in the Jacobian of the fitted function.

It supports linear inequality/equality constraints and bound constraints. Additionally, parameters can be tied (enforcing non-linear constraints) or fixed without modifying the fitting function. CapFit implements Algorithm 2 of Cappellari (2023). It combines two very successful ideas:

  1. The Sequential Quadratic Programming (SQP);
  2. The Levenberg-Marquardt (LM) method.

CapFit can be described as a Levenberg-Marquardt algorithm with constraints (which include simple bounds as a special case). It is designed for situations where the user function is complex and computationally expensive compared to the small quadratic subproblem. CapFit generally outperforms the best unconstrained or bound-constrained least-squares algorithms in terms of robustness and number of function evaluations (Figure 8). Additionally, it supports more general constraints.

Figure 9: Application of CapFit to the fit of multiple gas emission line components in a galaxy spectrum with pPXF. This fit optimizes eight non-linear parameters while enforcing linear constraints to avoid degeneracy in the model (Cappellari 2023, fig. 2).

Figure 9 illustrates a relatively complex real-world non-linear least-squares fit with CapFit. It is an application of the software from within pPXF (Section 4), which uses it as its main optimization algorithm. The CapFit procedure is also used for the nonlinear optimization of MgeFit in Section 1 above.

5.2 The CapFit package in Python

The pure-Python CapFit package is on the Python Package Index PyPI.

How to install: Use pip install capfit. Without write access to the global site-packages directory, use pip install --user capfit.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.


6 PaFit: Fitting Kinematic PA

Fit the global kinematic position-angle of galaxies

6.1 The Method

Figure 10: Left Panel: Best fitting symmetrized kinematics at the optimal position angle determined by PaFit. Right Panel: The corresponding mock observed stellar kinematics, with overlaid the best-fitting kinematic PA. The black dots indicate the location where the kinematics was sampled.

This software implements the method presented in Appendix C of Krajnović et al. (2006) to measure the global kinematic position-angle (PA) from integral field observations of a galaxy stellar or gas kinematics (Figure 10).

See Cappellari et al. (2007), Krajnović et al. (2011) and Graham et al. (2018) for large scale applications of this software to the study of the stellar kinematic misalignment of early-type galaxies. See Davor’s Krajnović page for the related Kinemetry package.

6.2 The PaFit package in Python

The PaFit package is on the Python Package Index PyPI.

How to install: Use pip install pafit. Without write access to the global site-packages directory, use pip install --user pafit.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

Also required is my plotbin package (automatically installed by pip).

PaFit requires the scientific core packages NumPy and Matplotlib.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download PaFit.


7 LtsFit: Robust Linear Regression with Scatter in Arbitrary Dimension

Fit lines, planes, or hyperplanes to data with errors in all variables, possible outliers and intrinsic scatter

7.1 The Method

Figure 11: Fitting of the (M/L)-σ relation in the Virgo cluster using ltsfit (Cappellari et al. 2013b, fig. 16). The green outliers above the relation are automatically removed from the fit. They turn out to be background galaxies and for this reason they do not follow the cluster relation.

This software implements the method presented in Sec. 3.2 of Cappellari et al. (2013b) to perform extremely robust fit of lines or planes to data with errors in all variables, possible large outliers (bad data) and unknown intrinsic scatter.

The code combines the Least Trimmed Squares (LTS) robust technique, proposed by Rousseeuw (1984) and speeded up in Rousseeuw & Van Driessen (2006), into a least-squares fitting algorithm which allows for intrinsic scatter and errors in all coordinates. This method makes the fit converge to the correct solution even in the presence of numerous catastrophic outliers (like in Figure 11), where the much simpler σ-clipping approach can converge to the wrong solution.

7.2 The LtsFit package in Python

The LtsFit package is on the Python Package Index PyPI.

How to install: Use pip install ltsfit. Without write access to the global site-packages directory, use pip install --user ltsfit.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

LtsFit requires the scientific core packages NumPy, SciPy and Matplotlib.

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download LtsFit.


8 LOESS: Adaptive Smoothing in One or Two Dimensions

Recover mean trends from noisy data in one or two dimension

8.1 The Method

Figure 12: Application of the loess_2d routine (with frac=0.6) to the recovery of two underlying functions from a noisy distribution of 200 scattered values. For comparison, the right panels show the distribution obtained via simple averaging on a grid, but using 100× more values than the ones used for the LOESS recovery. The LOESS approach achieves a comparable result while requiring a much smaller number of input values.

This software provides an improved implementation of the one-dimensional (Cleveland 1979) and two-dimensional (Cleveland & Devlin 1988) Locally Weighted Regression (LOESS) method to recover the mean trends of the population from noisy data in one or two dimensions (Figure 12). It includes a robust approach to deal with outliers (bad data).

These programs were implemented and used to produce the two-dimensional maps and the one-dimensional mean trends in Cappellari et al. (2013a).

8.2 The loess package in Python

The loess package is on the Python Package Index PyPI.

How to install: Use pip install loess. Without write access to the global site-packages directory, use pip install --user loess.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Changelog: All changes are documented HERE.

Also required to run the 2D example is my plotbin package (automatically installed by pip).

NOTE: I would appreciate it if you drop me an e-mail (address at the bottom) when you download the code.


9 AdaMet: Adaptive Metropolis for Bayesian Analysis

A Python package for efficient Bayesian analysis

9.1 The Method

Figure 13: Corner plot for the posterior of the model parameters obtained when fitting the black hole mass in the galaxy NGC1277 using the JAM modelling method and the AdaMet Bayesian code (Krajnović et al. 2018, fig. A1). The Python code to produce this figure is included in the JamPy package in Section 2.

This AdaMet package is the implementation of Cappellari et al. (2013b) of the Adaptive Metropolis algorithm of Haario (2001). In many real-world applications, it was found to be more efficient and robust than the emcee approach, whose warm-up phase scales linearly with the number of walkers (Figure 13).

9.2 The AdaMet package in Python

The user-friendly AdaMet package is on the Python Package Index PyPI.

How to install: Use pip install adamet. Without write access to the global site-packages directory, use pip install --user adamet.

Usage examples: Are in the directory “examples” inside the main package folder inside site-packages.

The User Manual: The detailed user manual is HERE.

Also required for plotting is my plotbin package (automatically installed by pip).


Comments and suggestions are welcome to the address on my Homepage.

Latest changes: 2024-10-15

Go back to Michele Cappellari Homepage

References

Barnabè, M., Dutton, A. A., Marshall, P. J., et al. 2012, “The SWELLS survey - IV. Precision measurements of the stellar and dark matter distributions in a spiral lens galaxy”, MNRAS, 423, 1073, 2012MNRAS.423.1073B
Bruzual, G., & Charlot, S. 2003, “Stellar population synthesis at the resolution of 2003”, MNRAS, 344, 1000, 2003MNRAS.344.1000B
Calzetti, D., Armus, L., Bohlin, R. C., et al. 2000, “The Dust Content and Opacity of Actively Star-forming Galaxies”, ApJ, 533, 682, 2000ApJ...533..682C
Cappellari, M. 2002, “Efficient multi-gaussian expansion of galaxies”, MNRAS, 333, 400, 2002MNRAS.333..400C
Cappellari, M. 2008, “Measuring the inclination and mass-to-light ratio of axisymmetric galaxies via anisotropic jeans models of stellar kinematics”, MNRAS, 390, 71, 2008MNRAS.390...71C
Cappellari, M. 2009, “Voronoi binning: Optimal adaptive tessellations of multi-dimensional data”, ArXiv e-prints, 2009arXiv0912.1303C
Cappellari, M. 2012, “Anisotropic Jeans models of stellar kinematics: second moments including proper motions and radial velocities”, arXiv e-prints, arXiv:1211.7009, 2012arXiv1211.7009C
Cappellari, M. 2015, “General spherical anisotropic Jeans models of stellar kinematics: including proper motions and radial velocities”, arXiv e-prints, arXiv:1504.05533, 2015arXiv150405533C
Cappellari, M. 2016, “Structure and Kinematics of Early-Type Galaxies from Integral Field Spectroscopy”, ARA&A, 54, 597, 2016ARA%26A..54..597C
Cappellari, M. 2017, “Improving the full spectrum fitting method: accurate convolution with Gauss-Hermite functions”, MNRAS, 466, 798, 2017MNRAS.466..798C
Cappellari, M. 2020, “Efficient solution of the anisotropic spherically aligned axisymmetric Jeans equations of stellar hydrodynamics for galactic dynamics”, MNRAS, 494, 4819, 2020MNRAS.494.4819C
Cappellari, M. 2023, “Full spectrum fitting with photometry in PPXF: Stellar population versus dynamical masses, non-parametric star formation history and metallicity for 3200 LEGA-c galaxies at redshift z ≈ 0.8”, MNRAS, 526, 3273, 2023MNRAS.526.3273C
Cappellari, M., & Copin, Y. 2003, “Adaptive spatial binning of integral-field spectroscopic data using voronoi tessellations”, MNRAS, 342, 345, 2003MNRAS.342..345C
Cappellari, M., & Emsellem, E. 2004, “Parametric recovery of line-of-sight velocity distributions from absorption-line spectra of galaxies via penalized likelihood”, PASP, 116, 138, 2004PASP..116..138C
Cappellari, M., Emsellem, E., Bacon, R., et al. 2007, “The SAURON project - x. The orbital anisotropy of elliptical and lenticular galaxies: Revisiting the (v/σ, ϵ) diagram with integral-field stellar kinematics”, MNRAS, 379, 418, 2007MNRAS.379..418C
Cappellari, M., Emsellem, E., Krajnović, D., et al. 2011, “The ATLAS3D project - i. A volume-limited sample of 260 nearby early-type galaxies: Science goals and selection criteria”, MNRAS, 413, 813, 2011MNRAS.413..813C
Cappellari, M., McDermid, R. M., Alatalo, K., et al. 2012, “Systematic variation of the stellar initial mass function in early-type galaxies”, Nature, 484, 485, 2012Natur.484..485C
Cappellari, M., McDermid, R. M., Alatalo, K., et al. 2013a, “The ATLAS3D project - XX. Mass-size and mass-σ distributions of early-type galaxies: bulge fraction drives kinematics, mass-to-light ratio, molecular gas fraction and stellar initial mass function”, MNRAS, 432, 1862, 2013MNRAS.432.1862C
Cappellari, M., McDermid, R. M., Bacon, R., et al. 2010, “Testing Mass Determinations of Supermassive Black Holes via Stellar Kinematics”, in American institute of physics conference series, ed. V. P. Debattista, & C. C. Popescu, Vol. 1240, 211, 2010AIPC.1240..211C
Cappellari, M., Romanowsky, A. J., Brodie, J. P., et al. 2015, “Small Scatter and Nearly Isothermal Mass Profiles to Four Half-light Radii from Two-dimensional Stellar Dynamics of Early-type Galaxies”, ApJL, 804, L21, 2015ApJ...804L..21C
Cappellari, M., Scott, N., Alatalo, K., et al. 2013b, “The ATLAS3D project - XV. Benchmark for early-type galaxies scaling relations from 260 dynamical models: mass-to-light ratio, dark matter, Fundamental Plane and Mass Plane”, MNRAS, 432, 1709, 2013MNRAS.432.1709C
Cappellari, M., Serego Alighieri, S. di, Cimatti, A., et al. 2009, “Dynamical masses of early-type galaxies at z ∼ 2: Are they truly superdense?”, ApJL, 704, L34, 2009ApJ...704L..34C
Cenarro, A. J., Cardiel, N., Gorgas, J., et al. 2001, “Empirical calibration of the near-infrared Ca ii triplet - I. The stellar library and index definition”, MNRAS, 326, 959, 2001MNRAS.326..959C
Conroy, C., Gunn, J. E., & White, M. 2009, “The propagation of uncertainties in stellar population synthesis modeling. I. The relevance of uncertain aspects of stellar evolution and the initial mass function to the derived physical properties of galaxies”, ApJ, 699, 486, 2009ApJ...699..486C
Drehmer, D. A., Storchi-Bergmann, T., Ferrari, F., Cappellari, M., & Riffel, R. A. 2015, “The benchmark black hole in NGC 4258: dynamical models from high-resolution two-dimensional stellar kinematics”, MNRAS, 450, 128, 2015MNRAS.450..128D
Emsellem, E., Cappellari, M., Peletier, R. F., et al. 2004, “The SAURON project - III. Integral-field absorption-line kinematics of 48 elliptical and lenticular galaxies”, MNRAS, 352, 721, 2004MNRAS.352..721E
Emsellem, E., Monnet, G., & Bacon, R. 1994, “The multi-gaussian expansion method: A tool for building realistic photometric and kinematical models of stellar systems i. The formalism”, A&A, 285, 723, 1994A%26A...285..723E
Falcón-Barroso, J., Lyubenova, M., van de Ven, G., et al. 2017, “Stellar kinematics across the hubble sequence in the CALIFA survey: General properties and aperture corrections”, A&A, 597, A48, 2017A&A...597A..48F
Falcón-Barroso, J., Sánchez-Blázquez, P., Vazdekis, A., et al. 2011, “An updated MILES stellar library and stellar population models”, A&A, 532, A95, 2011A%26A...532A..95F
Feldmeier-Krause, A., Zhu, L., Neumayer, N., et al. 2017, “Triaxial orbit-based modelling of the Milky Way Nuclear Star Cluster”, MNRAS, 466, 4040, 2017MNRAS.466.4040F
Graham, M. T., Cappellari, M., Li, H., et al. 2018, “SDSS-IV MaNGA: Stellar angular momentum of about 2300 galaxies: Unveiling the bimodality of massive galaxy properties”, MNRAS, 477, 4711, 2018MNRAS.477.4711G
Gustafsson, B., Edvardsson, B., Eriksson, K., et al. 2008, “A grid of MARCS model atmospheres for late-type stars. I. Methods and general properties”, A&A, 486, 951, 2008A&A...486..951G
Jeans, J. H. 1922, “The motions of stars in a kapteyn universe”, MNRAS, 82, 122, 1922MNRAS..82..122J
Jin, Y., Zhu, L., Long, R. J., et al. 2019, “Evaluating the ability of triaxial Schwarzschild modelling to estimate properties of galaxies from the Illustris simulation”, MNRAS, 486, 4753, 2019MNRAS.486.4753J
Johnston, E. J., Merrifield, M. R., Aragón-Salamanca, A., & Cappellari, M. 2013, “Disentangling the stellar populations in the counter-rotating disc galaxy NGC 4550”, MNRAS, 428, 1296, 2013MNRAS.428.1296J
Krajnović, D., Cappellari, M., de Zeeuw, P. T., & Copin, Y. 2006, “Kinemetry: A generalization of photometry to the higher moments of the line-of-sight velocity distribution”, MNRAS, 366, 787, 2006MNRAS.366..787K
Krajnović, D., Cappellari, M., McDermid, R. M., et al. 2018, “A quartet of black holes and a missing duo: probing the low end of the MBH − σ relation with the adaptive optics assisted integral-field spectroscopy”, MNRAS, 477, 3030, 2018MNRAS.477.3030K
Krajnović, D., Emsellem, E., Cappellari, M., et al. 2011, “The ATLAS3D project - II. Morphologies, kinemetric features and alignment between photometric and kinematic axes of early-type galaxies”, MNRAS, 414, 2923, 2011MNRAS.414.2923K
Leung, G. Y. C., Leaman, R., van de Ven, G., et al. 2018, “The EDGE-CALIFA survey: validating stellar dynamical mass models with CO kinematics”, MNRAS, 477, 254, 2018MNRAS.477..254L
Maraston, C., & Strömbäck, G. 2011, “Stellar population models at high spectral resolution”, MNRAS, 418, 2785, 2011MNRAS.418.2785M
Munari, U., Sordo, R., Castelli, F., & Zwitter, T. 2005, “An extensive library of 2500 10 500 Å synthetic spectra”, A&A, 442, 1127, 2005A&A...442.1127M
Nitschai, M. S., Cappellari, M., & Neumayer, N. 2020, “First Gaia dynamical model of the Milky Way disc with six phase space coordinates: a test for galaxy dynamics”, MNRAS, 494, 6001, 2020MNRAS.494.6001N
Nitschai, M. S., Eilers, A.-C., Neumayer, N., Cappellari, M., & Rix, H.-W. 2021, “Dynamical model of the milky way using APOGEE and gaia data”, ApJ, 916, 112, 2021ApJ...916..112N
Prugniel, P., & Soubiran, C. 2001, “A database of high and medium-resolution stellar spectra”, A&A, 369, 1048, 2001A%26A...369.1048P
Rix, H.-W., Franx, M., Fisher, D., & Illingworth, G. 1992, “NGC 4550 - a laboratory for testing galaxy formation”, ApJL, 400, L5, 1992ApJ...400L...5R
Sánchez-Blázquez, P., Peletier, R. F., Jiménez-Vicente, J., et al. 2006, “Medium-resolution isaac newton telescope library of empirical spectra”, MNRAS, 371, 703, 2006MNRAS.371..703S
Sanders, J. S., Fabian, A. C., Allen, S. W., & Schmidt, R. W. 2004, “Mapping small-scale temperature and abundance structures in the core of the perseus cluster”, MNRAS, 349, 952, 2004MNRAS.349..952S
Shajib, A. J., Mozumdar, P., Chen, G. C. F., et al. 2023, “TDCOSMO. XII. Improved hubble constant measurement from lensing time delays using spatially resolved stellar kinematics of the lens galaxy”, A&A, 673, A9, 2023A&A...673A...9S
Stanway, E. R., & Eldridge, J. J. 2018, “Re-evaluating old stellar populations”, MNRAS, 479, 75, 2018MNRAS.479...75S
Tabor, M., Merrifield, M., Aragón-Salamanca, A., et al. 2017, “Untangling galaxy components: Full spectral bulge-disc decomposition”, MNRAS, 466, 2024, 2017MNRAS.466.2024T
Valdes, F., Gupta, R., Rose, J. A., Singh, H. P., & Bell, D. J. 2004, “The Indo-US Library of Coudé Feed Stellar Spectra”, ApJS, 152, 251, 2004ApJS..152..251V
van de Sande, J., Bland-Hawthorn, J., Fogarty, L. M. R., et al. 2017, “The SAMI galaxy survey: Revisiting galaxy classification through high-order stellar kinematics”, ApJ, 835, 104, 2017ApJ...835..104V
van de Ven, G., Falcón-Barroso, J., McDermid, R. M., et al. 2010, “The Einstein Cross: Constraint on Dark Matter from Stellar Dynamics and Gravitational Lensing”, ApJ, 719, 1481, 2010ApJ...719.1481V
Vazdekis, A., Sánchez-Blázquez, P., Falcón-Barroso, J., et al. 2010, “Evolutionary stellar population synthesis with MILES - i. The base models and a new line index system”, MNRAS, 404, 1639, 2010MNRAS.404.1639V
Verro, K., Trager, S. C., Peletier, R. F., et al. 2022a, “Modelling simple stellar populations in the near-ultraviolet to near-infrared with the x-shooter spectral library (XSL)”, A&A, 661, A50, 2022A&A...661A..50V
Verro, K., Trager, S. C., Peletier, R. F., et al. 2022b, “The x-shooter spectral library (XSL): Data release 3”, A&A, 660, A34, 2022A&A...660A..34V
Watkins, L. L., van de Ven, G., Brok, M. den, & Bosch, R. C. E. van den. 2013, “Discrete dynamical models of ω Centauri”, MNRAS, 436, 2598, 2013MNRAS.436.2598W
Weijmans, A.-M., Cappellari, M., Bacon, R., et al. 2009, “Stellar velocity profiles and line strengths out to four effective radii in the early-type galaxies NGC3379 and 821”, MNRAS, 398, 561, 2009MNRAS.398..561W
Westfall, K. B., Cappellari, M., Bershady, M. A., et al. 2019, “The data analysis pipeline for the SDSS-IV MaNGA IFU galaxy survey: overview”, AJ, 158, 231, 2019AJ....158..231W
Winge, C., Riffel, R. A., & Storchi-Bergmann, T. 2009, “The gemini spectral library of near-IR late-type stellar templates and its application for velocity dispersion measurements”, ApJS, 185, 186, 2009ApJS..185..186W
Woo, J., Walters, D., Archinuk, F., et al. 2024, “Stellar populations with optical spectra: Deep learning versus popular spectrum fitting codes”, MNRAS, 530, 4260, 2024MNRAS.530.4260W
Yan, R., Chen, Y., Lazarz, D., et al. 2019, “SDSS-IV MaStar: A large and comprehensive empirical stellar spectral libraryfirst release”, ApJ, 883, 175, 2019ApJ...883..175Y
Zhu, K., Lu, S., Cappellari, M., et al. 2023, “MaNGA DynPop - i. Quality-assessed stellar dynamical modelling from integral-field spectroscopy of 10K nearby galaxies: A catalogue of masses, mass-to-light ratios, density profiles, and dark matter”, MNRAS, 522, 6326, 2023MNRAS.522.6326Z
Zhu, K., Lu, S., Cappellari, M., et al. 2024, “MaNGA DynPop - III. Stellar dynamics versus stellar population relations in 6000 early-type and spiral galaxies: Fundamental plane, mass-to-light ratios, total density slopes, and dark matter fractions”, MNRAS, 527, 706, 2024MNRAS.527..706Z