Michele Cappellari Python and IDL Programs

The following software is freely available. However, if you use it for published research, you are requested to cite the paper where the method is described, highlighted in red. You are not allowed to re-distribute any of these programs (modified or not) without explicit permission from the author.

NOTE: If you are just starting to program and are wondering which version you should use, I strongly recommend the Python version of my programs.

  1. The MGE_FIT_SECTORS package: to fit Multi-Gaussian Expansion (MGE) models to galaxy images, to be used as a parametrization for galaxy photometry
  2. The JAM modelling package: to construct Jeans Anisotropic Models for the stellar kinematics of axisymmetric galaxies
  3. VORONOI_2D_BINNING: to perform adaptive spatial binning of Integral-Field Spectroscopy, X-ray or imaging data, to reach a chosen constant signal-to-noise ratio per bin
  4. Penalized Pixel-Fitting (pPXF): to extract the galaxy stellar or gas kinematics or stellar population from absorption-line spectra
  5. FIT_KINEMATIC_PA: to measure the global galaxy kinematical axis from integral field observations
  6. LTS_LINEFIT and LTS_PLANEFIT: to robustly fit a plane or a line to data with intrinsic scatter
  7. CAP_LOESS_1D and CAP_LOESS_2D: to uncover mean trends from noisy one-dimensional or two-dimensional data using the LOESS approach.


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

1. The MGE_FIT_SECTORS package

A set of Python or IDL routines to perform Multi-Gaussian Expansion (MGE) fits to galaxy images

This software obtains an accurate Multi-Gaussian Expansion (MGE) parameterizations (Emsellem et al. 1994) for a galaxy surface brightness, with the efficient and robust fitting method of Cappellari (2002, MNRAS, 333, 400).

See Cappellari et al. (2006) for a large scale application of this software to the study of the M/L ratio and the Fundamental Plane of early-type galaxies and Cappellari et al. (2012, Nature) for an application to the study of the stellar IMF. The MGE parameterizations is useful in the construction of realistic dynamical models of galaxies (see JAM modelling below), for PSF deconvolution of images, for the correction and estimation of dust absorption effects, or for galaxy photometry.

Download the mge_fit_sectors source code in Python

The source code of the mge_fit_sectors package in Python, including a test galaxy image, can be downloaded here in ZIP format (4.9 MB). This version was last updated on the 14 April 2016. It is functionally identical to the IDL one, but it is typically about 5× faster due to the use of Scipy's built-in NNSL procedure and Numpy's broadcasting. It is orders of magnitude faster when using the option linear=True, which is now always recommended with Python.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of mge_fit_sectors requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely mge_fit_sectors only requires the scientific core packages Numpy, Scipy and Matplotlib (the mge_fit_sectors package was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5), and Pyfits to read FITS images.

Also included in the mge_fit_sectors distribution is the mpfit implementation by Markwardt (2009) of the MINPACK (Moré, Garbow & Hillstrom, 1980) Levenberg-Marquardt nonlinear least-squares optimization algorithm. The mpfit routine was translated into Python by Mark River and updated here for Numpy by Sergey Koposov. I modified the latter version to support both Python 2.6/2.7 and Python 3. Note that mge_fit_sectors uses the mpfit implementation instead of the scipy.optimize.leastsq one, because of the ability of mpfit to set limits on parameters or keep them fixed.

Download the MGE_FIT_SECTORS source code in IDL

The source code of the IDL package MGE_FIT_SECTORS, with examples and instructions, can be downloaded here in ZIP format (326 KB). This version was last updated on the 24 April 2015 and the changes are documented in the program file. Optionally the FITS files of the five galaxy images that are required to run the examples routine can be downloaded here in ZIP format (19 MB).

Also required is the following IDL routine, which must be downloaded separately:

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

NOTE: I would appreciate if you drop me an e-mail (address at the bottom) when you download the above procedures. I would also like to know if you got the IDL or Python version.


JAM logo

2. The JAM modelling method

Jeans Anisotropic Models of stellar kinematics or proper motions of axisymmetric or spherical galaxies

JAM 20 galaxies
Figure 1: Examples of JAM data-model comparisons. The bi-symmetrized state-of-the-art SAURON stellar kinematics of 20 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. In many cases χν2 ≈ 1 and the models describe the original un-symmetrized data within the errors. This shows that most of the information on the dynamics of these galaxies is contained in the photometry alone! (Cappellari 2008)

JAM NGC4258
Figure 4: The benchmark black hole (BH) in NGC4258. A detailed modelling using JAM accurately recovers the "correct" BH mass inferred from maser observations (Drehmer et al. 2015). This is one of the most reliable BH mass estimates, after the Milky Way. For other comparisons see Cappellari et al. (2010).
JAM KDC
Figure 3: JAM models examples of kinematically decoupled components. (a) Three-parameters JAM description of the SAURON stellar kinematics of the early-type galaxy NGC4550, which contains two counter-rotating stellar disks (Cappellari et al. 2007). To reproduce the observed velocity field, the flattest (q' < 0.25) Gaussians of the MGE model were assigned opposite rotation (κ < 0). (b) Same as in [a] but with the model orbits all rotating in the same direction. (c) Best fitting JAM model of NGC5308, with constant anisotropy (βz = 0.28 and κ = 1.02) (Cappellari 2008). (d) Same as in [c], but with a non-rotating bulge (κ = 0). (e) Same as in [c] but with an isotropic bulge (βz = 0) and an anisotropic disk (βz = 0.28). The best model has an oblate velocity ellipsoid, with the same strong anisotropy and the same rotation for both the bulge and the disk!
JAM tensor
Figure 2: 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 2012)

The software in this section implements in Python and in IDL 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, for both axisymmetric (Cappellari 2012) and spherical geometry (Cappellari 2015). The technique was introduced in Cappellari (2008, MNRAS, 390, 71) and we call it the Jeans Anisotropic Modelling (JAM) method. It relies on the Multi-Gaussian Expansion parameterization (Emsellem et al. 1994; Cappellari 2002) for the galaxy surface brightness.

With the addition of a single extra parameter βz=1-(σzR)2, the simple and user-friendly JAM method already provides a dramatic improvement over the less general but widely used two-integrals f(E,Lz) Jeans (1922) models. However JAM also allows for tangential ansiotropy γ=1-(σφR)2 and/or for spatially varying anisotropy. The JAM models provide good descriptions of state-of-the-art integral-field stellar kinematics of real galaxies (Figure 1). 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.

The JAM routines are designed for axisymmetric or spherical geometry, (i) they can provide the proper motion dispersion tensor (Cappellari 2012; Cappellari 2015; Figure 2), (ii) allow for the inclusion of dark matter, (iii) variable stellar M/L, (iv) spatially varying anisotropy and (v) multiple kinematic components (Figure 3) and (vi) supermassive black holes (BH; Figure 4). 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 MGE_FIT_SECTORS package above.

Download the jam source code in Python

The source code of the jam modelling package in Python can be downloaded here in ZIP format (47 KB). This version was last updated on the 11 March 2016 and the changes are documented in the program files. The Python version of the mean velocity calculation is about 30× faster than the IDL version, due to a redesign of the double integration approach, made possible by Numpy's broadcasting.

Also required for plotting are the generic routines plot_velfield, symmetrize_velfield and sauron_colormap in this ZIP file.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of jam requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely jam only requires the scientific core packages Numpy, Scipy and Matplotlib (jam was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5).

Download the JAM source code in IDL

The source code of the JAM modelling package in IDL, with documentation and examples, can be downloaded here in ZIP format (45 KB). This version was last updated on 7 April 2015 and the changes are documented in the program files.

Also required are the generic plotting routines SAURON_COLORMAP and PLOT_VELFIELD which can be found in this ZIP file.

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

Download the JAM source code in the C language

Laura Watkins has translated the JAM procedures into the C language. Her code is available here.

NOTE: I would appreciate if you drop me an e-mail (address at the bottom) when you download the above procedures. I would also like to know if you got the IDL or Python version.


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

3. The Voronoi binning method

A Python or IDL program to bin two-dimensional data to a constant signal-to-noise ratio per bin

The Voronoi Binning method of Cappellari & Copin (2003, MNRAS, 342, 345) 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.

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).

Download the Voronoi Binning source code in Python

The source code of the Python program voronoi_2d_binning, with examples and instructions, can be downloaded here in ZIP format (70 KB). It was last updated on the 12 April 2016 and the changes are documented in the program files. This version is functionally identical to the IDL one from which it was translated. It was tested to produce identical results for every spaxel.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of voronoi_2d_binning requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely voronoi_2d_binning only requires the scientific core packages Numpy, Scipy and Matplotlib (voronoi_2d_binning was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5).

This optional ZIP file contains the routines display_bins, display_bins_generators, display_pixels, plot_velfield and the sauron_colormap which can be used to visualize Voronoi 2D-binned or unbinned data, either using interpolation, or by showing the actual bins like in the figures above.

Download the Voronoi Binning source code in IDL

The source code of the IDL program VORONOI_2D_BINNING, with examples and instructions, can be downloaded here in ZIP format (75 KB). This version was last updated on 12 April 2016 and the changes are documented in the program file. Some minor adaptations of the routine may be required to optimally use the method with different types of data. Please ask for suggestions if needed.

This optional ZIP file contains the routines display_bins, display_bins_generators, DISPLAY_PIXELS, PLOT_VELFIELD and SAURON_COLORMAP which can be used to visualize Voronoi 2D-binned or unbinned data, either using interpolation, or by showing the actual bins like in the figures above.

NOTE: I would appreciate if you drop me an e-mail (address at the bottom) when you download the above procedures. I would also like to know if you got the IDL or Python version.


4. Penalized Pixel-Fitting (pPXF)

A Python or IDL program to extract the stellar or gas kinematics or stellar population from absorption-line spectra of galaxies

ppxf_fit_NGC3379ppxf_fit_NGC4150ppxf_fit_NGC4278ppxf_fit_NGC4459
Figure 1: pPXF fit (red) to SAURON spectra (white) of NGC 3379, NGC 4150, NGC 4278 and NGC 4459 in the wavelength region 480-538nm. The fit residuals are plotted in green and the non-fitted gas emission lines in blue.

This software implements the Penalized Pixel-Fitting method (pPXF) originally described in Cappellari & Emsellem (2004, PASP, 116, 138) to extract the stellar kinematics or stellar population from absorption-line spectra of galaxies, using a maximum penalized likelihood approach. The method is very general and robust. For this reason it was applied to a variety of situations. Over the years this lead to the addition of a number of features, based on our own needs and user's feedback. The following key features are implemented in the current pPXF program:

See Emsellem et al. (2004) and Cappellari et al. (2011) for two large-scale applications of the pPXF method to the measurement of the stellar kinematics of galaxies. Falcon-Barroso et al. (2004) present an example of using the optimal template generated by pPXF to extract the gas kinematics from galaxy spectra and to measure emission-corrected line-strength indexes. McDermid et al. (2006; their Fig. 3) use pPXF for spectral flux calibration, and extract the kinematics of a large galaxy sample. Cappellari et al. (2009) use pPXF to measure velocity dispersion of a sample of 9 passive early-type galaxies at redshift z~2.

Minimizing template mismatch 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 (e.g. the four panels of Figure 1 show pPXF fits to SAURON spectra using the full MILES stellar library). An extensive account of the available stellar libraries is maintained by David Montes. An incomplete list of libraries that have been successfully used with pPXF for the kinematics extraction is given below:

pPXF for Population
Figure 4: Population and gas with pPXF. The top panels show the pPXF fit to the SDSS DR8 spectrum of the early-type galaxy NGC3522, using as templates a subset of 26(Ages)×6([M/H])=156 MILES model spectra by Vazdekis et al. (2010), and 12 gas emission lines. The bottom panels show the corresponding pPXF solution for the distribution of the mass fraction in different age and metallicity intervals. The Left Panel has no regularization. This is the minimum χ2 solution which all non-regularized full-spectrum fitting programs must return, if they properly converge. However the solution is rather arbitrary due to the fact that this general inverse problem is ill-posed. For this reason the solution consists of a few model spectra with quite different characteristics. Regularization is a standard approach to solve ill-posed problems. The Right Panel shows the pPXF regularized solution. This is the smoothest solution consistent with the noise in the data. It has a quite extended distribution dominated in mass by an old stellar population and nearly solar mean metallicity. (This figure was made with the script ppxf_population_gas_example_sdss.py in the pPXF Python distribution)
star formation history with pPXF
Figure 3: Star-formation history with pPXF. The plot shows the star-formation history of ATLAS3D galaxies, in bins of different galaxy stellar mass. This was recovered with pPXF using regularization (taken from McDermid et al. 2015).
pPXF with multiple components
Figure 2: Fitting gas and multiple kinematic components with pPXF. The plot shows the pPXF fit to the spectrum of the galaxy NGC4550, which is known to contain two counter-rotating stellar disks (e.g. Figure 3 in JAM section). The fit uses two kinematic components of different age for the stars and one for the gas emission lines (taken from Johnston et al. 2013).

Using pPXF for stellar population and gas emission

When one uses as input templates a set of synthetic galaxy spectra, arranged in a grid of population parameters (e.g. age and metallicity), pPXF is the most efficient and reliable public implementation of the so called "Full-Spectrum Fitting" method to study stellar populations. This technique has replaced the traditional use of line-strength indices, due to the availability of high-quality model spectra (e.g. Bruzual & Charlot 2003; Vazdekis et al. 2010; Maraston & Stromback 2011; Conroy & van Dokkum 2012).

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 filling important absorption features (see Figures 2 and 4).

A number of similar, but less optimized and less general implementations of the Full Spectrum Fitting method exist (e.g. STARLIGHT by Cid Fernandes et al. 2005; STECKMAP by Ocvirk, et al. 2006; VESPA by Tojeiro et al. 2007). A major limitation of most available codes is that they ignore the fact that the recovery of the star formation history and chemical composition distribution from the galaxy spectra is an ill-posed problem. A standard technique to solve ill-posed problems is regularization, which is invoked in pPXF via the keyword REGUL (see Press et al. 1992, Sec.18.5). Regularization is essential to make sense of the derived star formation histories and to explore model degeneracies (see Figure 3 and 4).

See Cappellari et al. (2012, Nature) for a pPXF study of the M/L and IMF of stellar populations, and figure 20 of Onodera et al. (2012) for an application of pPXF to the study of the star formation history of passive galaxies at redshift z~2.

Download the ppxf source code in Python

The source code of the Python program ppxf, with examples and instructions, can be downloaded here in ZIP format (3.0 MB). It was last updated on the 24 May 2016 and the changes are documented in the program files. This version is functionally identical to the IDL one from which it was translated, but it includes some extra optional keywords. It was tested to produce identical results. The Python version is faster than the IDL one (10× faster in the example of Figure 4) when using a large number (>100) of templates, thanks to Scipy's built-in nnls (a similar pPXF performance in IDL requires calling the compiled version of BVLS: see below).

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of ppxf requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely ppxf only requires the scientific core packages Numpy, Scipy and Matplotlib (ppxf was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5), and Pyfits to read any FITS data.

Also included in the ppxf distribution is the mpfit implementation by Markwardt (2009) of the MINPACK (Moré, Garbow & Hillstrom, 1980) Levenberg-Marquardt nonlinear least-squares optimization algorithm. The mpfit routine was translated into Python by Mark River and updated here for Numpy by Sergey Koposov. I modified the latter version to support both Python 2.6/2.7 and Python 3. Note that ppxf uses the mpfit implementation instead of the scipy.optimize.leastsq one, because of the ability of mpfit to set limits on parameters or keep them fixed.

I recommend running the provided ppxf examples and checking the output against the provided ppxf_python_reference_output.txt file, to detect possible Python installation issues.

Download the pPXF source code in IDL

The source code of the IDL program PPXF, with examples and instructions, can be downloaded here in ZIP format (2.6 MB). This version was last updated on the 25 January 2016 and the changes are documented in the program file. See the important note in the README file for a proper usage of pPXF!

The following two IDL routines are also required to run pPXF. They must be downloaded separately:

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

NOTE: I would appreciate if you drop me an e-mail (address at the bottom) when you download the above procedures. I would also like to know if you got the IDL or Python version.

Extracting gas kinematics with GANDALF in IDL

If you are interested in both the stellar and gas kinematics, you may also use pPXF in combination with GANDALF. Please acknowledge both the pPXF (Cappellari & Emsellem 2004) and the GANDALF (Sarzi et al. 2006) papers if you use the two programs together. See Oh et al. (2011) for a large-scale application of the pPXF and GANDALF combination.


Kin PA
Best fitting symmetrized kinematics of NGC 2974

5. Fit kinematic PA

A Python or IDL program to fit the global kinematic position-angle of galaxies

This software implements the method presented in Appendix C of Krajnovic et al. (2006, MNRAS, 366, 787) to measure the global kinematic position-angle (PA) from integral field observations of a galaxy stellar or gas kinematics.

See Cappellari et al. (2007) and Krajnovic et al. (2011) for two large scale application of this software to the study of the stellar kinematical misalignment of early-type galaxies. See Davor's Krajnovic page for the related Kinemetry package.

Download the fit_kinematic_pa source code in Python

The source code of the Python program fit_kinematic_pa can be downloaded here in ZIP format. It was last updated on the 9 Sep 2015. This version is functionally identical to the IDL one from which it was translated.

Also required are the generic plotting routines plot_velfield, symmetrize_velfield and sauron_colormap in this ZIP file.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of fit_kinematic_pa requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely fit_kinematic_pa only requires the scientific core packages Numpy, Scipy and Matplotlib (fit_kinematic_pa was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5).

Download the FIT_KINEMATIC_PA source code in IDL

The source code of the IDL program FIT_KINEMATIC_PA, with examples and instructions, can be downloaded here in ZIP format (9 KB). This version was last updated on 12 October 2013 and the changes are documented in the program file.

Also required are the generic plotting routines SAURON_COLORMAP and PLOT_VELFIELD which can be found in this ZIP file.

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

NOTE: I would appreciate if you drop me an e-mail (address at the bottom) when you download FIT_KINEMATIC_PA. I would also like to know if you got the IDL or Python version.


lts_linefit
Figure 1: Fitting of the (M/L)-σ relation in the Virgo cluster using LTS_LINEFIT (taken from Cappellari et al. 2013a). 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.

6. LTS_LINEFIT and LTS_PLANEFIT

Two versatile and robust Python and IDL programs to fit lines and planes to data with errors in all variables, possible outliers and intrinsic scatter

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

The code combines the Least Trimmed Squares (LTS) robust technique, proposed by Rousseeuw (1984) and speeded up in Rousseeuw & 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 a large number of catastrophic outliers (like in Figure 1), where the much simpler σ-clipping approach can converge to the wrong solution.

Download the lts_linefit and lts_planefit source code in Python

The source code of the Python programs lts_linefit and lts_planefit can be downloaded here in ZIP format. It was last updated on the 1 October 2015. This version is functionally identical to the IDL one from which it was translated. It was tested to produce identical results. It is typically a couple of times faster than the IDL version.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Running this version of lts_linefit requires no installation or compilation of any Python package that is not certainly already included in a standard scientific Python installation. Namely lts_linefit only requires the scientific core packages Numpy, Scipy and Matplotlib (lts_linefit was tested with both Python 2.7 and 3.5, using NumPy 1.11, SciPy 0.17 and Matplotlib 1.5).

Download the LTS_LINEFIT and LTS_PLANEFIT source code in IDL

The source code of the IDL programs LTS_LINEFIT and LTS_PLANEFIT can be downloaded here in ZIP format (9 KB). This version was last updated on 26 October 2015 and the changes are documented in the program file.

The following two IDL routine are also required to run the two programs. They must be downloaded separately:

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

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


LOESS
Application of the CAP_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.

7. CAP_LOESS_1D and CAP_LOESS_2D

Two Python or IDL programs to recover mean trends from noisy data in one or two dimension

This software provides an improved implementation of the one-dimensional (Clevelend 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. 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. (2013b, MNRAS, 432, 1862).

Download the loess_1d and loess_2d source code in Python

The source code of the Python program loess_2d can be downloaded here in ZIP format. It was last updated on the 18 April 2016. This version is functionally identical to the IDL one from which it was translated. It was tested to produce identical results.

Also required to run the 2D example are the generic plotting routines plot_velfield and sauron_colormap in this ZIP file.

How to install: To be able to import the module from any directory, one can add the directory with the Python code to a "path configuration file" (.pth) placed in the .../site-packages/ directory (see here for details).

Download the CAP_LOESS_1D and CAP_LOESS_2D source in IDL

The source code of the IDL programs CAP_LOESS_1D and CAP_LOESS_2D can be downloaded here in ZIP format (6 KB). This version was last updated on 31 October 2013 and the changes are documented in the program file.

And if you just started using IDL and still do not have the IDL Astronomy User's Library installed, or if you have an old version, you should immediately get it from here.

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


Comments and suggestions are welcome to the address e-mail

Latest changes: 24/MAY/2016

Go back to Michele Cappellari Homepage

Valid HTML 4.0 Transitional