Skip to content

Commit

Permalink
Include test for fwhm interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
nmearl committed Sep 19, 2019
1 parent 245d7ff commit ef14dde
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions specutils/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,18 +476,27 @@ def test_fwhm():
expected = stddev * gaussian_sigma_to_fwhm
assert quantity_allclose(result, expected, atol=0.01*u.GHz)


# Highest point at the first point
wavelengths = np.linspace(1, 10, 100) * u.um
flux = (1.0 / wavelengths.value)*u.Jy # highest point first.
flux = (1.0 / wavelengths.value) * u.Jy # highest point first.

spectrum = Spectrum1D(spectral_axis=wavelengths, flux=flux)
result = fwhm(spectrum)
# Note that this makes a little more sense than the previous version;
# since the maximum value occurs at wavelength=1, and the half-value of
# flux (0.5) occurs at exactly wavelength=2, the result should be
# exactly 1 (2 - 1).
assert result == 1.0*u.um
assert result == 1.0 * u.um

# Test the interpolation used in FWHM for wavelength values that are not
# on the grid
wavelengths = np.linspace(1, 10, 31) * u.um
flux = (1.0 / wavelengths.value) * u.Jy # highest point first.

spectrum = Spectrum1D(spectral_axis=wavelengths, flux=flux)
result = fwhm(spectrum)

assert quantity_allclose(result, 1.01 * u.um)

# Highest point at the last point
wavelengths = np.linspace(1, 10, 100) * u.um
Expand Down

0 comments on commit ef14dde

Please sign in to comment.