pPXF

Module for running pPXF analyses

frb.galaxies.ppxf.run(spec_file, R, zgal, results_file=None, spec_fit='tmp.fits', chk=True, flux_scale=1.0, atmos=[], gaps=[], wvmnx=(0.0, 1000000000.0))[source]

Wrapper for running and handling outputs

Outputs are written to disk

Parameters:
  • spec_file (str or XSpectrum1D)

  • R (float)

  • zgal (float)

  • results_file (str, optional)

  • spec_fit

  • chk

  • flux_scale

  • atmos (list of tuple) – List of (wvmin,wvmax) regions to mask during the analysis This is a list of lists, e.g. [[7150., 7300.]]

  • gaps (list) – Regions to ignore due to detector gaps or any other bad regions This is a list of lists, e.g. [[6675., 6725.]]

  • wvmnx

frb.galaxies.ppxf.fit_spectrum(spec, zgal, specresolution, tie_balmer=False, miles_dir=None, rebin=True, limit_doublets=False, degree_add=None, degree_mult=5, **kwargs)[source]

This is a wrapper for pPXF to fit stellar population models as well as emission lines to galaxy spectra. Although pPXF allows otherwise, the emission lines are kinematically fixed to one another as are the stellar models, and the stars and gas independently vary with one another.

Please see the pPXF documentation for more details on the vast array of parameters and options afforded by the software.

The pPXF software may be downloaded at http://www-astro.physics.ox.ac.uk/~mxc/software/

Parameters:
  • spec (XSpectrum1D) – Spectrum to be fitted

  • zgal (float) – Redshift of galaxy

  • specresolution (float) – Spectral resolution (R) of the data

  • tie_balmer (bool, optional) – Assume intrinsic Balmer decrement. See documentation in ppxf_util.py, as this has implications for the derived reddening.

  • limit_doublets (bool, optional) – Limit the ratios of [OII] and [SII] lines to ranges allowed by atomic physics. See documentation in ppxf_util.py, as this has implications for getting the true flux values from those reported.

  • degree_add (int, optional) – Degree of the additive Legendre polynomial used to modify the template continuum in the fit.

  • degree_mult (int,optional)

  • miles_dir (str, optional) – Location of MILES models

Returns:

  • ppfit (ppxf) – Object returned by pPXF; attributes are data pertaining to the fit

  • miles (miles) – Contains information about the stellar templates used in the fit. See the documentation in miles_util.py for full details

  • weights (1d numpy vector) – Weights of the stellar template components. Equivalent to the first N elements of ppfit.weights where N is the number of stellar templates used in the fit.

frb.galaxies.ppxf.total_mass(miles, weights, quiet=False)[source]

Computes the total mass of living stars and stellar remnants in models fitted, given the weights produced and output by pPXF.

A Salpeter IMF is assumed (slope=1.3) initially.
  • TODO: Employ Chabrier models

The returned mass excludes the gas lost during stellar evolution.

This procedure uses the mass predictions from Vazdekis+12 and Ricciardelli+12 http://adsabs.harvard.edu/abs/2012MNRAS.424..157V http://adsabs.harvard.edu/abs/2012MNRAS.424..172R they were downloaded in December 2016 below and are included in pPXF with permission http://www.iac.es/proyecto/miles/pages/photometric-predictions/based-on-miuscat-seds.php

Parameters:
  • miles (miles) – Miles object output from fit_spectrum()

  • weights (1d numpy array) – Weights vector corresponding to stellar templates. Output from fit_spectrum()

  • quiet (bool, optional) – If True, do not print stellar mass result

Returns:

mass_no_gas – Total stellar mass of templates fitted. NOTE: this value will generally need to be scaled if there is any mismatch in units between data and models. The MILES model spectra are generally given in units of L_sun/M_sun/Angstrom

Return type:

float

frb.galaxies.ppxf.dump_bestfit(ppfit, outfile=None, z=0.0)[source]

Create the bestfit in the observer frame and with vacuum wavelengths

Parameters:
  • ppfit

  • outfile

Returns:

bestfit

Return type:

XSpectrum1D

frb.galaxies.ppxf.dump_ppxf_results(ppfit, miles, z, outfile)[source]

Write the stnadard results and the gas_component measurements to a simple ASCII file

Parameters:
  • ppfit (ppxf)

  • outfile (str)

class frb.galaxies.ppxf.ppxfFit(ppfit, miles, weights)[source]

Bases: object

__init__(ppfit, miles, weights)[source]

Stripped down class of pPXf fit attributes to improve load times and data management.

Parameters:
  • ppfit (ppxf) – pPXF object output from fit_spectrum()

  • miles (miles) – Miles object output from fit_spectrum()

  • weights (array) – Weights on stellar pop models in fit; output from fit_spectrum()

Returns:

mass_no_gas – Total stellar mass of templates fitted. NOTE: this value will generally need to be scaled if there is any mismatch in units between data and models. The MILES model spectra are generally given in units of L_sun/M_sun/Angstrom

Return type:

float

Overview

This module provides functionality for running pPXF (Penalized Pixel-Fitting) analyses on galaxy spectra. pPXF is used to extract stellar kinematics and stellar population information from absorption-line spectra.

Functions

frb.galaxies.ppxf.run(spec_file, R, zgal, results_file=None, spec_fit='tmp.fits', chk=True, flux_scale=1.0, atmos=[], gaps=[], wvmnx=(0.0, 1000000000.0))[source]

Wrapper for running and handling outputs

Outputs are written to disk

Parameters:
  • spec_file (str or XSpectrum1D)

  • R (float)

  • zgal (float)

  • results_file (str, optional)

  • spec_fit

  • chk

  • flux_scale

  • atmos (list of tuple) – List of (wvmin,wvmax) regions to mask during the analysis This is a list of lists, e.g. [[7150., 7300.]]

  • gaps (list) – Regions to ignore due to detector gaps or any other bad regions This is a list of lists, e.g. [[6675., 6725.]]

  • wvmnx

Main wrapper function for running and handling pPXF outputs.

This function processes galaxy spectra through the pPXF pipeline, handling input/output and providing a simplified interface to the underlying pPXF code.

Parameters

The run function accepts the following key parameters:

  • spec_file (str or XSpectrum1D): Input spectrum file or object

  • R (float): Spectral resolution

  • zgal (float): Galaxy redshift

  • results_file (str, optional): Output results filename

  • spec_fit (str, optional): Fitted spectrum output filename

  • chk (bool, optional): Enable checking/validation

  • flux_scale (float, optional): Flux scaling factor

  • atmos (list, optional): Atmospheric absorption regions to mask

  • gaps (list, optional): Detector gaps or bad regions to ignore

  • wvmnx (tuple, optional): Wavelength range limits

Masking Options

The module provides flexible masking capabilities:

Atmospheric Lines

Regions affected by atmospheric absorption can be masked during analysis:

atmos = [[7150., 7300.], [7594., 7621.]]  # O2 bands
Detector Gaps

Bad regions or detector gaps can be excluded:

gaps = [[6675., 6725.]]  # CCD gap

Usage Examples

Basic pPXF analysis:

from frb.galaxies import ppxf

# Run pPXF on a spectrum file
ppxf.run('galaxy_spectrum.fits',
         R=3000.,  # Resolution
         zgal=0.1,  # Redshift
         results_file='ppxf_results.fits')

With masking:

# Define regions to mask
atmos_lines = [[7594., 7621.], [6864., 6884.]]  # Telluric features
detector_gaps = [[6675., 6725.]]  # Bad detector region

ppxf.run('spectrum.fits',
         R=2500.,
         zgal=0.25,
         atmos=atmos_lines,
         gaps=detector_gaps,
         wvmnx=(4000., 9000.))  # Wavelength limits

Output Processing:

# Run with custom output files
ppxf.run('galaxy.fits',
         R=3500.,
         zgal=0.15,
         results_file='kinematic_results.fits',
         spec_fit='best_fit_spectrum.fits',
         flux_scale=1e-17,  # Scale factor for flux units
         chk=True)  # Enable validation checks

Dependencies

This module requires:

  • ppxf package (Cappellari 2017, 2023)

  • linetools for spectrum handling

  • astropy for units and constants

  • matplotlib for plotting capabilities

  • numpy for numerical computations

Note

The module uses MILES stellar library templates by default for stellar population fitting.