irfpy.util.planck

Collection of Planck’s black body radiation formulae.

Code author: Yoshifumi Futaana

Todo

Move freq2wavlen, wavlen2freq, energy2wavelen, wavelen2energy to irfpy.util.physics module.

irfpy.util.planck.freq2wavlen(freq)[source]

Frequency (Hz) to wavelength (m) conversion.

Parameters

freq (Scalar or np.array.) – Frequency

Returns

Wavelength in m

The following command confirms that 1 MHz ~ 300 m.

>>> print('%.3f' % freq2wavlen(1e6))   # 1MHz
299.792

Unitful version is also defined.

>>> freq = u.Hz * np.array([1e6, 1e7, 1e8])  # 1MHz, 10 and 100MHz
>>> wavlen = freq2wavlen_u(freq)
>>> print('%.5f %.5f %.5f' % tuple(wavlen.rescale(u.km)))
0.29979 0.02998 0.00300
irfpy.util.planck.freq2wavlen_u(*args)

Unitful version of freq2wavlen()

irfpy.util.planck.wavlen2freq(wavlen)[source]

Wavelength (m) to frequency (Hz) conversion.

Parameters

wavlen (Sacalar or np.array.) – Wavelength in m.

Returns

Frequency in Hz.

>>> print('%.3e' % wavlen2freq(1e-9))   # 1 nm
2.998e+17

It confirms 1 nm ~ 300 000 000 GHz = 3e17 Hz.

Unitful version wavlen2freq_u() is also defined.

>>> wavlen = np.array([5, 10, 30])
>>> wavlen = u.km * wavlen  # 5km, 10km, 30 km
>>> freq = wavlen2freq_u(wavlen)
>>> print('%.1f %.1f %.1f' % tuple(freq.rescale(u.Hz)))
59958.5 29979.2 9993.1
irfpy.util.planck.wavlen2freq_u(*args)

Unitful version of wavlen2freq()

irfpy.util.planck.energy2wavlen(energy)[source]

Convert the energy (J) to wavelength (m)

>>> print('%.2e m' % (energy2wavlen(3.973e-19)))
5.00e-07 m
>>> print('3 [eV] = %.2f [nm]' % energy2wavlen_u(3 * u.eV).rescale(u.nm))
3 [eV] = 413.28 [nm]
irfpy.util.planck.energy2wavlen_u(*args)

Unitful version of energy2wavlen().

irfpy.util.planck.wavlen2energy(wavlen)[source]

Convert the wavelength (m) to energy (J)

\[E = h\nu = \frac{hc}{\lambda}\]
>>> print('%.3e J' % wavlen2energy(500e-9))   # 500 nm
3.973e-19 J
>>> print('%.3f eV' % (wavlen2energy(500e-9) / k.qe))
2.480 eV

Unitful version also defined.

>>> wavlen = 500 * u.nm
>>> energy = wavlen2energy_u(wavlen)
>>> print('500 nm = %.3e J' % energy.rescale(u.J))
500 nm = 3.973e-19 J
>>> print('500 nm = %.3f eV' % energy.rescale(u.eV))
500 nm = 2.480 eV
irfpy.util.planck.wavlen2energy_u(*args)

Unitful version of wavlen2energy

class irfpy.util.planck.BlackBodyMksa(temperature)[source]

Bases: object

Black body class with interfaces to MKSA unit system.

A black body is instanced.

Parameters

temperature – Temperature in K.

lh = -33.17874397056745
lc = 8.476820702927927
spectral_radiance_per_frequency(frequency)[source]

Return the spectral radiance in frequency domain

Parameters

frequency (Scalar or np.array) – Frequency in Hz (/s).

Returns

The spectral radiance, in the unit of \(W/m^2 sr Hz\)

The spectral radiance is calcualted as

\[B_\nu(T) = \frac{2h\nu^3}{c^2}\frac{1}{\exp{\frac{h\nu}{k_BT} - 1}}\]
>>> sun = BlackBodyMksa(6000)    # Sun is 6000 K black body.
>>> print('%.3e' % sun.spectral_radiance_per_frequency(1.5e14))   # 2000 nm
2.145e-08
Bnu(*args, **kwds)[source]

Return spectral_radiance_per_frequency()

An alias to spectral_radiance_per_frequency().

>>> sun = BlackBodyMksa(6000)
>>> print('%.3e' % sun.Bnu(1.5e14)) 
2.145e-08
spectral_radiance_per_wavelength(wavelength)[source]

Return the spectral radiance in wavelength domain

Parameters

wavelength – Wavelength in m.

Returns

The spectral radiance, in the unit of \(W/m^2 sr m\)

\[B_\lambda(T) = \frac{2hc^2}{\lambda^5}{\frac{1}{\exp{\frac{hc}{\lambda k_BT}}-1}}\]
>>> sun = BlackBodyMksa(6000)
>>> print('%.3e' % sun.spectral_radiance_per_wavelength(500e-9))
3.176e+13
Blambda(*args, **kwds)[source]

An alias to spectral_radiance_per_wavelength().

class irfpy.util.planck.BlackBody_u(temperature)[source]

Bases: irfpy.util.planck.BlackBodyMksa

Unitful version of BlackBodyMksa.

>>> earth = BlackBody_u(300 * u.K)
>>> b = earth.Bnu(500 * u.kHz)
>>> print('{0:.3e} {1}'.format(float(b.n), b.u))
2.304e-26 W/(m**2*sr*Hz)
>>> b = earth.Blambda(500 * u.nm)
>>> print('{0:.3e} {1}'.format(float(b.n), b.u))
8.399e-27 W/(m**3*sr)
>>> sun = BlackBody_u(0.5 * u.eVT)   # ~5800K
>>> b = sun.Bnu(500 * u.kHz)
>>> print('{0:.3e} {1}'.format(float(b.n), b.u))
4.457e-25 W/(m**2*sr*Hz)
>>> sun = BlackBody_u(5800 * u.K)   # ~5800K
>>> b = sun.Bnu(500 * u.kHz)
>>> print('{0:.3e} {1}'.format(float(b.n), b.u))
4.455e-25 W/(m**2*sr*Hz)

A black body is instanced.

Parameters

temperature – Temperature in K.

spectral_radiance_per_frequency()

Return the spectral radiance in frequency domain

Parameters

frequency (Scalar or np.array) – Frequency in Hz (/s).

Returns

The spectral radiance, in the unit of \(W/m^2 sr Hz\)

The spectral radiance is calcualted as

\[B_\nu(T) = \frac{2h\nu^3}{c^2}\frac{1}{\exp{\frac{h\nu}{k_BT} - 1}}\]
>>> sun = BlackBodyMksa(6000)    # Sun is 6000 K black body.
>>> print('%.3e' % sun.spectral_radiance_per_frequency(1.5e14))   # 2000 nm
2.145e-08
spectral_radiance_per_wavelength()

Return the spectral radiance in wavelength domain

Parameters

wavelength – Wavelength in m.

Returns

The spectral radiance, in the unit of \(W/m^2 sr m\)

\[B_\lambda(T) = \frac{2hc^2}{\lambda^5}{\frac{1}{\exp{\frac{hc}{\lambda k_BT}}-1}}\]
>>> sun = BlackBodyMksa(6000)
>>> print('%.3e' % sun.spectral_radiance_per_wavelength(500e-9))
3.176e+13
irfpy.util.planck.SunProxy(temperature=5778.0)[source]

The Sun proxied by a black body.

The default temperature is 5778K, which is consdered as a average surface temperatuer of the Sun.

Parameters

temperature – Temperature in K.

>>> sun = SunProxy()
>>> print('%.3e' % sun.Blambda(500e-9))   # At 200 nm
2.638e+13
>>> lamrng = np.array([200, 500, 1000, 2000]) * 1e-9    # 200-2000 nm
>>> b = sun.Blambda(lamrng) / 1e9   # in W/m2 sr nm
>>> print('%.2e %.2e %.2e %.2e' % (b[0], b[1], b[2], b[3]))
1.46e+03 2.64e+04 1.08e+04 1.50e+03