BlackBody

class astropy.modeling.physical_models.BlackBody(temperature=<Quantity 5000. K>, scale=1.0, **kwargs)[source]

Bases: astropy.modeling.Fittable1DModel

Blackbody model using the Planck function.

Parameters
temperatureQuantity

Blackbody temperature.

scalefloat or Quantity

Scale factor

Notes

Model formula:

\[B_{\nu}(T) = A \frac{2 h \nu^{3} / c^{2}}{exp(h \nu / k T) - 1}\]

Examples

>>> from astropy.modeling import models
>>> from astropy import units as u
>>> bb = models.BlackBody(temperature=5000*u.K)
>>> bb(6000 * u.AA)  
<Quantity 1.53254685e-05 erg / (cm2 Hz s sr)>
import numpy as np
import matplotlib.pyplot as plt

from astropy.modeling.models import BlackBody
from astropy import units as u
from astropy.visualization import quantity_support

bb = BlackBody(temperature=5778*u.K)
wav = np.arange(1000, 110000) * u.AA
flux = bb(wav)

with quantity_support():
    plt.figure()
    plt.semilogx(wav, flux)
    plt.axvline(bb.nu_max.to(u.AA, equivalencies=u.spectral()).value, ls='--')
    plt.show()

(png, svg, pdf)

../_images/astropy-modeling-physical_models-BlackBody-1.png

Attributes Summary

bolometric_flux

Bolometric flux.

input_units

This property is used to indicate what units or sets of units the evaluate method expects, and returns a dictionary mapping inputs to units (or None if any units are accepted).

input_units_equivalencies

lambda_max

Peak wavelength when the curve is expressed as power density.

nu_max

Peak frequency when the curve is expressed as power density.

param_names

scale

temperature

Methods Summary

evaluate(self, x, temperature, scale)

Evaluate the model.

Attributes Documentation

bolometric_flux

Bolometric flux.

input_units

This property is used to indicate what units or sets of units the evaluate method expects, and returns a dictionary mapping inputs to units (or None if any units are accepted).

Model sub-classes can also use function annotations in evaluate to indicate valid input units, in which case this property should not be overridden since it will return the input units based on the annotations.

input_units_equivalencies = {'x': [(Unit("m"), Unit("Hz"), <function spectral.<locals>.<lambda>>), (Unit("m"), Unit("J"), <function spectral.<locals>.<lambda>>), (Unit("Hz"), Unit("J"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>), (Unit("m"), Unit("1 / m"), <function spectral.<locals>.<lambda>>), (Unit("Hz"), Unit("1 / m"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>), (Unit("J"), Unit("1 / m"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>), (Unit("1 / m"), Unit("rad / m"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>), (Unit("m"), Unit("rad / m"), <function spectral.<locals>.<lambda>>), (Unit("Hz"), Unit("rad / m"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>), (Unit("J"), Unit("rad / m"), <function spectral.<locals>.<lambda>>, <function spectral.<locals>.<lambda>>)]}
lambda_max

Peak wavelength when the curve is expressed as power density.

nu_max

Peak frequency when the curve is expressed as power density.

param_names = ('temperature', 'scale')
scale = Parameter('scale', value=1.0, bounds=(0, None))
temperature = Parameter('temperature', value=5000.0, unit=K, bounds=(0, None))

Methods Documentation

evaluate(self, x, temperature, scale)[source]

Evaluate the model.

Parameters
xfloat, ndarray, or Quantity

Frequency at which to compute the blackbody. If no units are given, this defaults to Hz.

temperaturefloat, ndarray, or Quantity

Temperature of the blackbody. If no units are given, this defaults to Kelvin.

scalefloat, ndarray, or Quantity

Desired scale for the blackbody.

Returns
ynumber or ndarray

Blackbody spectrum. The units are determined from the units of scale.

Note

Use numpy.errstate to suppress Numpy warnings, if desired.

Warning

Output values might contain nan and inf.

Raises
ValueError

Invalid temperature.

ZeroDivisionError

Wavelength is zero (when converting to frequency).