question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlackBody bolometric flux is wrong if scale has units of dimensionless_unscaled

See original GitHub issue

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'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:34 (34 by maintainers)

github_iconTop GitHub Comments

1reaction
pllimcommented, Oct 26, 2021

Would we ruffle too many feathers

Can’t be worse than the episode when we deprecated clobber in io.fits… 😅

1reaction
pllimcommented, Oct 26, 2021

synphot keeps its own BlackBody1D class (perhaps renamed to BlackBodyFlux1D to mirror ConstFlux1D)

synphot never used the new blackbody stuff here, so I think it can be safely left out of the changes here. If you feel strongly about its model names, feel free to open issue at https://github.com/spacetelescope/synphot_refactor/issues but I don’t think it will affect anything at astropy or vice versa. 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for astropy.modeling.physical_models
If no units are given, this defaults to Hz (or AA if `scale` was initialized ... k_B * temp) boltzm1 = np.expm1(log_boltz) #...
Read more >
Astronomy Lecture Number 2
An ideal body that absorbs all wavelengths of electromagnetic radiation is called a blackbody. Such an ideal body has a spectrum that shows...
Read more >
Theoretical quantities: blackbody radiation
So, if we could measure the flux from a star, and we knew its distance, and we assume it emits radiation isotropically, we...
Read more >
phy217 - instruments - photometers - magnitudes and fluxes
The former is a logarithmic brightness scale, whereas the latter is a linear ... This collected quantity is known as the flux, F,...
Read more >
Solution Set 1 by Roger O'Brient and Eugene Chiang
Then divide the luminosity by dA to calculate the total flux (in units of energy/time/area) emitted by the patch. You should recover the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found