API Reference
pah_spec is a package for generating PAH emission spectra for arbitrary input radiation fields using the single photon approximation, as described in Richie & Hensley (2026).
The primary functionality of pah_spec lies in the PahSpec class, which uses a pre-existing set of basis spectra to
execute the PahSpec.generate_spectrum() method. This method takes a radiation field and dust grain size distributions as
(optional) inputs and returns an emission spectrum for neutral and ionized PAHs.
In addition to generating emission spectra, pah_spec contains useful functions for the PAH energy and absorption
cross-sections (calc_pah_energy() and PahSpec.calc_c_abs(), respectively) using the PAH model from Draine & Li (2001)
and Draine et al. (2021).
- class pah_spec.PahSpec(*, basis_dir=None, internal_data_dir=None, c_abs_func=None, pah_energy_func=None)
Bases:
objectClass for generating PAH emission spectra with the single photon approximation
- Parameters:
basis_dir (path-like, optional) – Specifies the path to the directory containing “basis_ion.h5” and “basis_neu.h5” which store the desired basis spectra for the ionized and neutral PAHs, respectively. When None (the default), basis spectra are read from the appropriate data cache directory.
internal_data_dir (path-like, optional) – Specifies the path to the directory holding internal data files. When None (the default), these files are read from the appropriate data cache directory. This is mostly provided for testing purposes (and should NOT be considered part of the public API)
c_abs_func (callable, optional) – Function to calculate absorption cross-sections. Must have the same signature as PahSpec.calc_c_abs(wavelength_arr, radius_arr). Defaults to PahSpec.calc_c_abs.
pah_energy_func (callable, optional) – Function to calculate PAH vibrational energy as a function of temperature. Must have the same signature as calc_pah_energy(grain_radius, temp_arr). Defaults to calc_pah_energy.
- calc_c_abs(wavelength_arr, radius_arr)
Calculate the absorption cross-section, C_abs, for input grain sizes and wavelengths based on method from Draine et al. (2021).
- Parameters:
wavelength_arr (astropy.units.Quantity (array_like)) – Array of wavelengths to calculate C_abs for
radius_arr (astropy.units.Quantity (float or array_like)) – Array of dust grain radii to calculate C_abs for
- Returns:
c_abs_ion_out (astropy.units.Quantity (array_like)) – Array with C_abs values for ionized grains (in u.cm ** 2)
c_abs_neu_out (astropy.units.Quantity (array_like)) – Array with C_abs values for neutral grains (in u.cm ** 2)
- generate_basis_spectra(grain_sizes, emission_wavelengths, output_directory='./', ion=False, lambda_min=<Quantity 0.0912 um>, lambda_max=<Quantity 10. um>, pah_mode_energy_func=None)
Generates basis spectra file for input grain sizes for an ionized or neutral PAHs.
If basis spectra file already exists in output_directory, appends to exisitng file.
- Parameters:
grain_sizes (astropy.units.Quantity (float or array_like)) – Array of dust grain radii to calculate basis spectra for
emission_wavelengths (astropy.units.Quantity (array_like)) – Array of emission wavelengths to define basis spectra over
output_directory (str, optional) – Directory to output basis spectra to, default is ./
ion (Bool, optional) – PAH ionization to run basis spectra for, default is False
lambda_min (astropy.units.Quantity, optional) – Lowest lambda_abs wavelength, recommended default is 912 A
lambda_max (astropy.units.Quantity, optional) – Highest lambda_abs wavelength, recommended default is 10 um
pah_mode_energy_func (callable, optional) – Function to calculate PAH vibrational mode energies as a function of grain size. Must accept the grain radius as an argument and return an ordered list of PAH vibrational mode energies (in ascending order) in ergs. Defaults to calc_pah_mode_energies.
- Return type:
None
- generate_spectra_per_grain(wavelength_arr, u_lambda_arr)
Scale the basis spectra for ionized and neutral PAHs to an input radiation field
- Parameters:
wavelength_arr (astropy.units.Quantity (array_like), optional) – Wavelength array for the radiation field u_lambda (in u.um)
u_lambda_arr (astropy.units.Quantity (array_like), optional) – Array of length len(wavelength_arr) with the radiation field (in u.erg / u.cm ** 4)
- Returns:
spectra_neu_a (astropy.units.Quantity (array-like)) – Array of spectra for neutral PAHs in response to radiation field, with dimensions (len(grain_sizes), len(emission_wavelengths)) in u.erg / (u.cm * u.s)
spectra_ion_a (astropy.units.Quantity (array-like)) – Array of spectra for ionized PAHs in response to radiation field, with dimensions (len(grain_sizes), len(emission_wavelengths)) in u.erg / (u.cm * u.s)
- generate_spectrum(wavelength_arr=None, u_lambda_arr=None, size_dist_neu=None, size_dist_ion=None)
Scale the basis spectra for ionized and neutral PAHs to an input radiation field and integrate over the size distribution.
- Parameters:
wavelength_arr (astropy.units.Quantity (array_like), optional) – Wavelength array for the radiation field u_lambda (in u.um)
u_lambda_arr (astropy.units.Quantity (array_like), optional) – Array of length len(wavelength_arr) with the radiation field (in u.erg / u.cm ** 4)
size_dist_neu (array_like, optional) – PAH0 size distribution and ionization function for each grain size in self.grain_sizes
size_dist_ion (array_like, optional) – PAH+ size distribution and ionization function for each grain size in self.grain_sizes
- Returns:
spectrum_neu (astropy.units.Quantity (array_like)) – PAH0 size- and ionization-integrated spectrum for grains heated by the input u_lambda (in u.erg / (u.cm * u.s))
spectrum_ion (astropy.units.Quantity (array_like)) – PAH+ size- and ionization-integrated spectrum for grains heated by the input u_lambda (in u.erg / (u.cm * u.s))
- pah_spec.calc_pah_energy(grain_radius, temp_arr)
Calculate PAH vibrational energy as a function of temperature.
- Parameters:
grain_radius (astropy.units.Quantity (float)) – The PAH effective radius
temp_arr (astropy.units.Quantity (array-like)) – Array of temperature to calculate energies for
- Returns:
energy_arr – Resulting PAH energy array (in u.erg)
- Return type:
astropy.units.Quantity (array-like)
- pah_spec.calc_pah_mode_energies(grain_radius)
Calculate vibrational mode energies for a PAH
- Parameters:
grain_radius (astropy.units.Quantity (float)) – PAH radius in u.AA
- Returns:
emode_arr – Array of PAH vibrational energies in u.erg, sorted in order of increasing energy
- Return type:
astropy.units.Quantity (array-like)
- pah_spec.retrieve_internal_data(*, path: PathLike | None = None, kind: DataKind = DataKind.INTERNAL_DATA, progressbar: Any = None)
Ensure that all internal data has been downloaded.
If the data has already been downloaded and has the appropriate checksum it won’t be redownloaded.
- Parameters:
path (
os.PathLike, optional) – When specified, all files are downloaded to this directory. When None, the default, files are downloaded to the cache directory.progressbar (bool or arbitrary progressbar, optional) – Forwarded onto
pooch.retrieve(). WhenNone(the default), the value is inferred based on whether the tqdm package is installed
- pah_spec.retrieve_sample_basis(*, path: PathLike | None = None, kind: DataKind = DataKind.SAMPLE_BASIS, progressbar: Any = None)
Ensure that all sample basis spectra has been downloaded.
If the data has already been downloaded and has the appropriate checksum it won’t be redownloaded.
- Parameters:
path (
os.PathLike, optional) – When specified, all files are downloaded to this directory. When None, the default, files are downloaded to the cache directory.progressbar (bool or arbitrary progressbar, optional) – Forwarded onto
pooch.retrieve(). WhenNone(the default), the value is inferred based on whether the tqdm package is installed