synthesizer.conversions¶
A module containing functions for conversions.
This module contains helpful conversions for converting between different observables. This mainly covers conversions between flux, luminosity and magnitude systems.
Example usage:
lum = flux_to_luminosity(flux, cosmo, redshift) fnu = apparent_mag_to_fnu(m) lnu = absolute_mag_to_lnu(M)
Functions
- synthesizer.conversions.absolute_mag_to_lnu(ab_mag)[source]¶
Convert absolute magnitude (M) to luminosity.
The conversion is done using the formula:
L_nu = 10**(-0.4 * (M + 48.6)) * dist_mod
The result will be in units of erg / s / Hz.
- Parameters:
ab_mag (float) – The absolute magnitude to convert.
- Returns:
- unyt_quantity/unyt_array
The luminosity in erg / s / Hz.
- synthesizer.conversions.air_to_vacuum(wavelength)[source]¶
Convert an air wavelength into a vacuum wavelength.
- Arguments
- wavelength (float or unyt_array)
A standard wavelength.
- Returns
- wavelength (unyt_array)
A wavelength in vacuum.
- synthesizer.conversions.angular_to_spatial_at_z(angular, cosmo, redshift)[source]¶
Convert angular distance to spatial distance at a specified redshift.
- Parameters:
angular (unyt_quantity) – The angular distance to convert.
cosmo (astropy.cosmology) – The cosmology object used to calculate angular diameter distance.
redshift (float) – The redshift of the source.
- Returns:
- unyt_quantity
The converted spatial distance in kpc.
- synthesizer.conversions.apparent_mag_to_fnu(app_mag)[source]¶
Convert apparent AB magnitude to flux.
The conversion is done using the formula:
F_nu = 10**9 * 10**(-0.4 * (m - 8.9)) * nJy
The result will be in units of nJy.
- Parameters:
app_mag (float) – The apparent AB magnitude to be converted, can either be a singular value or array.
- Returns:
- unyt_quantity/unyt_array
The flux.
Examples using synthesizer.conversions.apparent_mag_to_fnu
¶
An example showing how to scale a galaxy’s mass by luminosity/flux.
- synthesizer.conversions.attenuation_to_optical_depth(attenuation)[source]¶
Convert attenuation to optical depth.
- Parameters:
attenuation (float) – The attenuation to convert.
- Returns:
- float
The converted optical depth.
- synthesizer.conversions.flam_to_fnu(lam, flam)[source]¶
Convert spectral flux density per wavelength to per frequency.
The conversion is done using the formula:
F_nu = F_lam * lam**2 / c
The result will be in units of nJy.
- Parameters:
lam (unyt_quantity/unyt_array) – The wavelength array the flux is defined at.
flam (unyt_quantity/unyt_array) – The spectral flux in terms of wavelength.
- Returns:
- unyt_quantity/unyt_array
The spectral flux in terms of frequency, in units of nJy.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.flux_to_luminosity(flux, cosmo, redshift)[source]¶
Convert flux to luminosity.
The conversion is done using the formula:
L = F * 4 * pi * D_L**2 / (1 + z)
The result will be in units of erg / s.
- Parameters:
flux (unyt_quantity/unyt_array) – The flux to be converted to luminosity, can either be a singular value or array.
cosmo (astropy.cosmology) – The cosmology object used to calculate luminosity distance.
redshift (float) – The redshift of the rest frame.
- Returns:
- unyt_quantity/unyt_array
The converted luminosity.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.fnu_to_apparent_mag(fnu)[source]¶
Convert flux to apparent AB magnitude.
The conversion is done using the formula:
m = -2.5 * log10(fnu / (10**9 * nJy)) + 8.9
- Parameters:
flux (unyt_quantity/unyt_array) – The flux to be converted, can either be a singular value or array.
- Returns:
- float
The apparent AB magnitude.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.fnu_to_flam(lam, fnu)[source]¶
Convert spectral flux density per frequency to per wavelength.
The conversion is done using the formula:
F_lam = F_nu * c / lam**2
The result will be in units of erg / s / A.
- Parameters:
lam (unyt_quantity/unyt_array) – The wavelength array the flux density is defined at.
fnu (unyt_quantity/unyt_array) – The spectral flux density in terms of frequency.
- Returns:
- unyt_quantity/unyt_array
The spectral flux density in terms of wavelength, in units of erg / s / Hz / cm**2.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.fnu_to_lnu(fnu, cosmo, redshift)[source]¶
Convert spectral flux density to spectral luminosity density.
The conversion is done using the formula:
L_nu = F_nu * 4 * pi * D_L**2 / (1 + z)
The result will be in units of erg / s / Hz.
- Parameters:
fnu (unyt_quantity/unyt_array) – The spectral flux dnesity to be converted to luminosity, can either be a singular value or array.
cosmo (astropy.cosmology) – The cosmology object used to calculate luminosity distance.
redshift (float) – The redshift of the rest frame.
- Returns:
- unyt_quantity/unyt_array
The converted spectral luminosity density.
- Raises:
IncorrectUnits – If units are missing an error is raised.
Examples using synthesizer.conversions.fnu_to_lnu
¶
An example showing how to scale a galaxy’s mass by luminosity/flux.
- synthesizer.conversions.llam_to_lnu(lam, llam)[source]¶
Convert spectral luminosity density per wavelength to per frequency.
The conversion is done using the formula:
L_nu = L_lam * lam**2 / c
The result will be in units of erg / s / Hz.
- Parameters:
lam (unyt_quantity/unyt_array) – The wavelength array the flux is defined at.
llam (unyt_quantity/unyt_array) – The spectral luminoisty density in terms of wavelength.
- Returns:
- unyt_quantity/unyt_array
The spectral luminosity in terms of frequency, in units of nJy.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.lnu_to_absolute_mag(lnu)[source]¶
Convert spectral luminosity density to absolute magnitude (M).
The conversion is done using the formula:
M = -2.5 * log10(L_nu / dist_mod / (erg / s / Hz)) - 48.6
- Parameters:
unyt_quantity/unyt_array – The luminosity to convert with units. Unyt
- Returns:
- float
The absolute magnitude.
- Raises:
IncorrectUnits – If units are missing an error is raised.
Examples using synthesizer.conversions.lnu_to_absolute_mag
¶
Camels luminosity function example
- synthesizer.conversions.lnu_to_fnu(lnu, cosmo, redshift)[source]¶
Convert spectral luminosity density to spectral flux density.
The conversion is done using the formula:
F_nu = L_nu * (1 + z) / 4 / pi / D_L**2
The result will be in units of nJy.
- Parameters:
lnu (unyt_quantity/unyt_array) – The spectral luminosity density to be converted to flux, can either be a singular value or array.
cosmo (astropy.cosmology) – The cosmology object used to calculate luminosity distance.
redshift (float) – The redshift of the rest frame.
- Returns:
- unyt_quantity/unyt_array
The converted spectral flux density.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.lnu_to_llam(lam, lnu)[source]¶
Convert spectral luminoisty density per frequency to per wavelength.
The conversion is done using the formula:
L_lam = L_nu * c / lam**2
The result will be in units of erg / s / A.
- Parameters:
lam (unyt_quantity/unyt_array) – The wavelength array the luminoisty density is defined at.
lnu (unyt_quantity/unyt_array) – The spectral luminoisty density in terms of frequency.
- Returns:
- unyt_quantity/unyt_array
The spectral luminoisty density in terms of wavelength, in units of erg / s / A.
- Raises:
IncorrectUnits – If units are missing an error is raised.
- synthesizer.conversions.optical_depth_to_attenuation(optical_depth)[source]¶
Convert optical depth to attenuation.
- Parameters:
depth (optical) – The optical depth to convert.
- Returns:
- float
The converted attenuation.
- synthesizer.conversions.spatial_to_angular_at_z(spatial, cosmo, redshift)[source]¶
Convert spatial distance to angular distance at a specified redshift.
- Parameters:
spatial (unyt_quantity) – The spatial distance to convert.
cosmo (astropy.cosmology) – The cosmology object used to calculate angular diameter distance.
redshift (float) – The redshift of the source.
- Returns:
- unyt_quantity
The converted angular distance in arcseconds.
- synthesizer.conversions.standard_to_vacuum(wavelength)[source]¶
Convert a standard wavelength into a vacuum wavelength.
Standard wavelengths are defined in vacuum at <2000A and air at >= 2000A.
- Arguments
- wavelength (float or unyt_array)
A standard wavelength.
- Returns
- wavelength (unyt_array)
A wavelength in vacuum.
- synthesizer.conversions.tau_lam_to_tau_v(dust_curve, tau_lam, lam)[source]¶
Convert optical depth in any given band to v-band optical depth.
- Parameters:
dust_curve (AttenuationBase) – The attenutation law to use.
tau_lam (float) – The optical depth to convert.
lam (unyt_quantity) – The wavelength at which tau_lam was calculated.
- Returns:
- float
The converted optical depth.
- synthesizer.conversions.vacuum_to_air(wavelength)[source]¶
Convert a vacuum wavelength into an air wavelength.
- Parameters:
wavelength (float or unyt_array) – A wavelength in air.
- Returns:
- wavelength (unyt_array)
A wavelength in vacuum.
- synthesizer.conversions.vacuum_to_standard(wavelength)[source]¶
Convert a vacuum wavelength into a standard wavelength.
Standard wavelengths are defined in vacuum at <2000A and air at >= 2000A.
- Arguments
- wavelength (float or unyt_array)
A vacuum wavelength.
- Returns
- wavelength (unyt_array)
A standard wavelength.