Planck’s radiation law

PyAstronomy.pyasl.planck(T, lam=None, nu=None)

Evaluate Planck’s radiation law.

Depending on whether wavelength or frequency is specified as input, the function evaluates:

\[B_{\nu} = \frac{2\pi h \nu^3}{c^2} \frac{1}{e^{\frac{h\nu}{kT}} - 1}\]

or

\[B_{\lambda} = \frac{2\pi h c^2}{\lambda^5} \frac{1}{e^{\frac{h c}{\lambda kT}} - 1} \; .\]

If lambda is given (in meters), the output units are W/(m^2 m). To convert into erg/(cm^2 A s), the output has to be multiplied by a factor of 1e-7.

Parameters
Tfloat

Temperature in Kelvin.

lamfloat or array, optional

Wavelength in meters.

nufloat or array, optional

Frequency in Hz.

Returns
Spectral radiancefloat or array

Depending on whether lam or nu were specified, returns the spectral radiance per area and wavelength or frequency. The unit (SI) will be W/(m^2 m) if lam was given and W/(m^2 Hz) if nu was specified.

Example

from __future__ import print_function
import numpy as np
import matplotlib.pylab as plt
from PyAstronomy.pyasl import planck

# Define wavelength in meters
lam = np.arange(1000.0*1e-10, 20000.*1e-10, 20e-10)

# Get the Planck spectrum in [W/(m**2 m)] for a temperature of 7000 K
s7 = planck(7000., lam=lam)
# Get the Planck spectrum in [W/(m**2 m)] for a temperature of 5000 K
s5 = planck(5000., lam=lam)

# Convert into erg/(cm**2 * A * s)
s5erg = s5 * 1e-7
s7erg = s7 * 1e-7

# Integrate the spectrum and compare with Stefan-Boltzmann law
i5 = np.sum(s5) * (lam[1] - lam[0])
i7 = np.sum(s7) * (lam[1] - lam[0])

print("5000 K integral: %.3e W/m**2 (Stefan-Boltzmann predicts %.3e W/m**2)" % (i5, (5.67e-8*5000.**4)))
print("7000 K integral: %.3e W/m**2 (Stefan-Boltzmann predicts %.3e W/m**2)" % (i7, (5.67e-8*7000.**4)))

plt.xlabel("Wavelength [$\AA$]")
plt.ylabel("Flux [erg/cm$^2$/A/s]")
plt.plot(lam*1e10, s5erg, 'r-')
plt.plot(lam*1e10, s7erg, 'b-')
plt.show()