Skip to content

Commit

Permalink
Fix NaN value for flux and aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
haticekaratay committed Jul 23, 2024
1 parent fcede25 commit 4cf5462
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ def _uncertainty(result):
return

final_unit = flux_unit
temp_result = raw_result.to(final_unit, equivalencies= u.spectral_density(freq_spec.spectral_axis))
temp_result = np.mean(raw_result.to(final_unit, equivalencies= u.spectral_density(freq_spec.spectral_axis)))
if getattr(raw_result, 'uncertainty', None) is not None:
temp_result.uncertainty = raw_result.uncertainty.to(final_unit, equivalencies= u.spectral_density(freq_spec.spectral_axis))
temp_result.uncertainty = np.mean(raw_result.uncertainty.to(final_unit, equivalencies= u.spectral_density(freq_spec.spectral_axis)))
# If the flux unit is instead equivalent to power density
# (Jy, but defined in wavelength), enforce integration in wavelength space
elif (flux_unit.is_equivalent(u.Unit('W/(m2 m)')) or
Expand All @@ -350,9 +350,9 @@ def _uncertainty(result):
return

final_unit = flux_unit
temp_result = raw_result.to(final_unit, equivalencies= u.spectral_density(wave_spec.spectral_axis))
temp_result = np.mean(raw_result.to(final_unit, equivalencies= u.spectral_density(wave_spec.spectral_axis)))
if getattr(raw_result, 'uncertainty', None) is not None:
temp_result.uncertainty = raw_result.uncertainty.to(final_unit, equivalencies= u.spectral_density(wave_spec.spectral_axis))
temp_result.uncertainty = np.mean(raw_result.uncertainty.to(final_unit, equivalencies= u.spectral_density(wave_spec.spectral_axis)))

# Otherwise, just rely on the default specutils line_flux result
else:
Expand Down

0 comments on commit 4cf5462

Please sign in to comment.