Flux-photon conversion

PyAstronomy.pyasl.flux2photons(wave, flux)

Convert flux (erg/s) to photons/s.

Parameters
wavefloat, array

The wavelength in Angstrom.

fluxfloat, array

The associated flux array in erg/s.

Returns
photonsarray

Number of photons/s for the given input flux

PyAstronomy.pyasl.photons2flux(wave, photons)

Convert photons/s to flux (erg/s).

Parameters
wavefloat, array

The wavelength in Angstrom.

photonsfloat, array

The associated photons array in photons/s.

Returns
fluxarray

Flux in erg/s for the given photon flux

Example

from __future__ import print_function, division
from PyAstronomy import pyasl

# Wavelength in Angstrom
wvl = 4000.
# Flux in erg/s
flux = 1.5e-14

# Convert into photons
photons = pyasl.flux2photons(wvl, flux)

# How many photons is this?
print("%g erg/s at %g A correspond to %g photons/s" \
        % (flux, wvl, photons))

# Converting back
flux2 = pyasl.photons2flux(wvl, photons)

print("%g photons/s at %g A correspond to %g erg/s" \
        % (photons, wvl, flux2))