Skip to content

Commit

Permalink
weights and mask
Browse files Browse the repository at this point in the history
  • Loading branch information
profxj committed Apr 10, 2016
1 parent fcce365 commit a8b2444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions py/desiutil/funcfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ def iter_fit(xarray, yarray, func, order, weights=None, sigma=None,
w = np.where(mask == 0)
xfit = xarray[w]
yfit = yarray[w]
if weights is not None:
wfit = weights[w]
else:
wfit = None
# Fit
dfit = func_fit(xfit, yfit, func, order, xmin=xmin, xmax=xmax,
dfit = func_fit(xfit, yfit, func, order, xmin=xmin, xmax=xmax, w=wfit,
**kwargs)
yrng = func_val(xarray, dfit)
# Reject
Expand Down Expand Up @@ -208,8 +212,8 @@ def iter_fit(xarray, yarray, func, order, weights=None, sigma=None,
if mskcnt-imskcnt > max_rej:
break
mskcnt = np.sum(mask)
w = np.where(mask == 0)
# Final fit
w = np.where(mask == 0)
xfit = xarray[w]
yfit = yarray[w]
fdict = func_fit(xfit, yfit, func, order, xmin=xmin, xmax=xmax, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/test/test_funcfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_iterfit(self):
y2 = func_val(x2, dfit)
np.testing.assert_allclose(y2[50], 0.99941444872371643)

def test_iterfit(self):
def test_iterfit2(self):
"""Test iter fit with some special cases.
"""
# Generate data
Expand Down

0 comments on commit a8b2444

Please sign in to comment.