Skip to content

Commit

Permalink
Merge pull request #22 from NolanKoblischke/fix-continuum-fit-nan-issue
Browse files Browse the repository at this point in the history
Handle NaNs in polynomial fitting of continuum
  • Loading branch information
henrysky committed Oct 25, 2023
2 parents 97e799c + 8aed649 commit f825a5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@ dmypy.json
# Ignore all local history of files
.history
.ionide

# Mac
.DS_Store

7 changes: 4 additions & 3 deletions astroNN/apogee/chips.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ def continuum(spectra, spectra_err, cont_mask, deg=2):
for counter, (spectrum, spectrum_err, flux_ivar) in enumerate(
zip(spectra, spectra_err, flux_ivars)
):
no_nan_mask = ~np.isnan(spectrum[cont_mask])
fit = np.polynomial.chebyshev.Chebyshev.fit(
x=np.arange(spectrum.shape[0])[cont_mask],
y=spectrum[cont_mask],
w=flux_ivar[cont_mask],
x=np.arange(spectrum.shape[0])[cont_mask][no_nan_mask],
y=spectrum[cont_mask][no_nan_mask],
w=flux_ivar[cont_mask][no_nan_mask],
deg=deg,
)
spectra[counter] = spectrum / fit(pix_element)
Expand Down

0 comments on commit f825a5c

Please sign in to comment.