Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hippke committed Jun 9, 2019
1 parent 102a22e commit 3675a1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wotan/cofiam.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def detrend_cosine(t, y, window_length, robust):
degree = (int((max(t) - min(t)) / window_length))
if not robust:
matrix = matrix_gen(t, degree)
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=None)[0])
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=-1)[0])

# robust version: sigma-clip flux from trend and iterate until convergence
else:
Expand All @@ -36,7 +36,7 @@ def detrend_cosine(t, y, window_length, robust):
# Solution from https://stackoverflow.com/questions/27128688/how-to-use-least-squares-with-weight-matrix
Aw = matrix * weights[:,np.newaxis] # if real weights: sqrt
Bw = y * weights # if real weights: sqrt
trend = np.matmul(matrix, np.linalg.lstsq(Aw, Bw, rcond=None)[0])
trend = np.matmul(matrix, np.linalg.lstsq(Aw, Bw, rcond=-1)[0])
detrended_flux = y / trend
mask_outliers = np.ma.where(
1-detrended_flux > constants.PSPLINES_STDEV_CUT*np.std(detrended_flux))
Expand All @@ -57,7 +57,7 @@ def detrend_cofiam(t, y, window_length):
dw_mask = np.array([True] * len(t))
for k_m in range(1, degree + 1):
matrix = matrix_gen(t, degree)
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=None)[0])
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=-1)[0])

# Durbin-Watson autocorrelation statistics
dw_y = y[dw_mask] / trend[dw_mask] - 1
Expand All @@ -68,5 +68,5 @@ def detrend_cofiam(t, y, window_length):
return trend
dw_previous = dw
matrix = matrix_gen(t, degree)
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=None)[0])
trend = np.matmul(matrix, np.linalg.lstsq(matrix, y, rcond=-1)[0])
return trend

0 comments on commit 3675a1a

Please sign in to comment.