Skip to content

Commit

Permalink
Attempt to fix the conversion between Fnu and Flam while also convert…
Browse files Browse the repository at this point in the history
…ing from surface brightness to flux
  • Loading branch information
astrofrog authored and gibsongreen committed May 31, 2024
1 parent 901658c commit e89989d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def to_unit(self, data, cid, values, original_units, target_units):
else:
spectral_values = spec.spectral_axis

# By default include spectral density equivalency
eqv = u.spectral_density(spectral_values)

# Ensure a spectrum passed through Spectral Extraction plugin
if '_pixel_scale_factor' in spec.meta and len(values) != 2:

Expand Down
13 changes: 13 additions & 0 deletions jdaviz/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,16 @@ def test_to_unit(cubeviz_helper):
([1, 2] * original_units)
.to_value(target_units,
equivalencies=u.spectral_density(cube.spectral_axis[0])))

# Change from Fnu to Flam/sr (with values shape matching spectral axis)

values = np.ones(3001)
original_units = u.MJy
target_units = u.erg / u.cm**2 / u.s / u.AA / u.sr

new_values = uc.to_unit(cubeviz_helper, data, cid, values, original_units, target_units)

assert np.allclose(new_values,
(values * original_units)
.to_value(target_units,
equivalencies=u.spectral_density(cube.spectral_axis)))

0 comments on commit e89989d

Please sign in to comment.