Skip to content

Commit

Permalink
fix for get_spectrum when vacuum=False for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Oct 26, 2023
1 parent 347e606 commit 291e6e3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions expecto/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,17 @@ def get_spectrum(

wavelengths = get_phoenix_wavelengths(cache=cache, vacuum=vacuum)

return Spectrum1D(fluxes, spectral_axis=wavelengths, meta=header)
# only return wavelengths > 0:
positive_wavelengths = wavelengths > 0

# specutils requires that we sort the wavelengths:
sort_wavelengths = np.argsort(wavelengths[positive_wavelengths])

return Spectrum1D(
flux=fluxes[positive_wavelengths][sort_wavelengths],
spectral_axis=wavelengths[positive_wavelengths][sort_wavelengths],
meta=header
)


def get_phoenix_wavelengths(cache=True, vacuum=True):
Expand All @@ -197,7 +207,8 @@ def get_phoenix_wavelengths(cache=True, vacuum=True):
# Husser 2013, Eqns. 8-10:
sigma_2 = (10**4 / wavelengths_vacuum)**2
f = (
1.0 + 0.05792105/(238.0185 - sigma_2) + 0.00167917 / (57.362 - sigma_2)
1.0 + 0.05792105/(238.0185 - sigma_2) +
0.00167917 / (57.362 - sigma_2)
)
wavelengths_air = wavelengths_vacuum / f

Expand Down

0 comments on commit 291e6e3

Please sign in to comment.