specutils
specutils copied to clipboard
SciPy Interpolate true_divide warning when making a new spectrum
A seemingly unjustified true_divide warning message pops up when normalizing a spectrum:
import warnings
import astropy
import numpy as np
import astropy.units as u
import specutils
# See Issue https://github.com/astropy/specutils/issues/779
warnings.filterwarnings('ignore', category=astropy.utils.exceptions.AstropyDeprecationWarning)
spec = specutils.Spectrum1D(flux=np.random.normal(2.0, 0.01, size=500)*u.erg/u.s,
spectral_axis=np.linspace(1, 1.5, num=500)*u.micron)
spec.flux / np.median(spec.flux)
:arrow_right: no warning message
whereas making a new Spectrum1D object somehow is attempting to interpolate, which seems unnecessary for division by a scalar:
spec_normalized = spec / np.median(spec.flux) # yes warning message
:arrow_down:
lib/python3.7/site-packages/scipy/interpolate/interpolate.py:2533: RuntimeWarning: invalid value encountered in true_divide
(grid[i + 1] - grid[i]))