Skip to content

BlackBody bolometric flux is wrong if scale has units of dimensionless_unscaled #11547

@lpsinger

Description

@lpsinger

The astropy.modeling.models.BlackBody class has the wrong bolometric flux if scale argument is passed as a Quantity with dimensionless_unscaled units, but the correct bolometric flux if scale is simply a float.

Description

Expected behavior

Expected output from sample code:

4.823870774433646e-16 erg / (cm2 s)
4.823870774433646e-16 erg / (cm2 s)

Actual behavior

Actual output from sample code:

4.5930032795393893e+33 erg / (cm2 s)
4.823870774433646e-16 erg / (cm2 s)

Steps to Reproduce

Sample code:

from astropy.modeling.models import BlackBody
from astropy import units as u
import numpy as np

T = 3000 * u.K
r = 1e14 * u.cm
DL = 100 * u.Mpc
scale = np.pi * (r / DL)**2

print(BlackBody(temperature=T, scale=scale).bolometric_flux)
print(BlackBody(temperature=T, scale=scale.to_value(u.dimensionless_unscaled)).bolometric_flux)

System Details

>>> import numpy; print("Numpy", numpy.__version__)
Numpy 1.20.2
>>> import astropy; print("astropy", astropy.__version__)
astropy 4.3.dev758+g1ed1d945a
>>> import scipy; print("Scipy", scipy.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> import matplotlib; print("Matplotlib", matplotlib.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions