Skip to content

Commit

Permalink
Update pspline.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hippke committed Oct 3, 2020
1 parent b66f3a6 commit 94fa1df
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wotan/pspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def pspline(time, flux, edge_cutoff, max_splines, return_nsplines, verbose):
for i in range(constants.PSPLINES_MAXITER):
mask_outliers = np.ma.where(
np.abs(1-detrended_flux) < constants.PSPLINES_STDEV_CUT*np.std(detrended_flux))
newtime, newflux = cleaned_array(newtime[mask_outliers], newflux[mask_outliers])
if len(mask_outliers[0]) != 0: # Do not cut if zero points remain
newtime, newflux = cleaned_array(newtime[mask_outliers], newflux[mask_outliers])
gam = LinearGAM(s(0, n_splines=max_splines))
search_gam = gam.gridsearch(newtime[:, np.newaxis], newflux, progress=False)
trend = search_gam.predict(newtime)
Expand All @@ -34,7 +35,9 @@ def pspline(time, flux, edge_cutoff, max_splines, return_nsplines, verbose):

# Final iteration, applied to unclipped time series (interpolated over clipped values)
mask_outliers = np.ma.where(np.abs(1-detrended_flux) < constants.PSPLINES_STDEV_CUT*stdev)
newtime, newflux = cleaned_array(newtime[mask_outliers], newflux[mask_outliers])
if len(mask_outliers[0]) != 0: # Do not cut if zero points remain
newtime, newflux = cleaned_array(newtime[mask_outliers], newflux[mask_outliers])
print(newflux)
gam = LinearGAM(s(0, n_splines=max_splines))
search_gam = gam.gridsearch(newtime[:, np.newaxis], newflux, progress=False)
trend = search_gam.predict(time)
Expand Down

0 comments on commit 94fa1df

Please sign in to comment.