31 def clean(srcMatch, wcs, order=3, nsigma=3):
32 """Remove bad points from srcMatch 35 srcMatch : list of det::SourceMatch 36 order: Order of polynomial to use in robust fitting 37 nsigma: Sources more than this far away from the robust best fit 38 polynomial are removed 41 list of det::SourceMatch of the good data points 48 x, y = wcs.skyToPixel(srcMatch[i].first.getCoord())
54 x = np.array([s.second.getX()
for s
in srcMatch])
56 sigma = np.zeros_like(dx) + 0.1
62 clean.append(srcMatch[i])
67 """Return a list of indices in the range [0, len(x)] 68 of points that lie less than nsigma away from the robust 75 for niter
in range(maxiter):
78 rs = np.ones((len(rx)))
80 lsf = LeastSqFitter1dPoly(
list(rx),
list(ry),
list(rs), order)
81 fit = [lsf.valueAt(value)
for value
in rx]
82 f = [lsf.valueAt(value)
for value
in x]
87 return newidx
if newidx
else idx
88 deviance = np.fabs((y - f) / sigma)
89 newidx = np.flatnonzero(deviance < nsigma)
92 import matplotlib.pyplot
as plt
94 plt.plot(rx, ry,
'b-')
95 plt.plot(rx, ry,
'bs')
96 plt.plot(rx, fit,
'ms')
97 plt.plot(rx, fit,
'm-')
102 if len(newidx) == len(idx):
112 """Create order+1 values of the ordinate based on the median of groups of elements of x""" 113 rSize = len(idx)/
float(order+1)
114 rx = np.zeros((order+1))
116 for i
in range(order+1):
117 rng =
list(range(
int(rSize*i),
int(rSize*(i+1))))
118 rx[i] = np.mean(x[idx[rng]])
123 """Create order+1 values of the ordinate based on the median of groups of elements of y""" 124 rSize = len(idx)/
float(order+1)
125 ry = np.zeros((order+1))
127 for i
in range(order+1):
128 rng =
list(range(
int(rSize*i),
int(rSize*(i+1))))
129 ry[i] = np.median(y[idx[rng]])
def indicesOfGoodPoints(x, y, s, order=1, nsigma=3, maxiter=100)
def chooseRy(y, idx, order)
def chooseRx(x, idx, order)
def clean(srcMatch, wcs, order=3, nsigma=3)
daf::base::PropertyList * list