def doFit(self, data): dist1 = 0 dist2 = 0 self.x_off1 = 0.0 self.y_off1 = 0.0 self.x_off2 = 0.0 self.y_off2 = 0.0 if self.fit_hl is None: self.fit_hl = saLPF.LockPeakFinder(offset=5.0, sigma=self.sigma, threshold=10) self.fit_hr = saLPF.LockPeakFinder(offset=5.0, sigma=self.sigma, threshold=10) total_good = 0 [x1, y1, status] = self.fit_hl.findFitPeak(data[:, :self.half_x]) if status: total_good += 1 self.x_off1 = x1 - self.half_y self.y_off1 = y1 - self.half_x dist1 = abs(self.y_off1) [x2, y2, status] = self.fit_hr.findFitPeak(data[:, -self.half_x:]) if status: total_good += 1 self.x_off2 = x2 - self.half_y self.y_off2 = y2 dist2 = abs(self.y_off2) return [total_good, dist1, dist2]
def __init__(self, parameters=None, **kwds): kwds["parameters"] = parameters super().__init__(**kwds) self.cnt = 0 self.max_backlog = 20 self.min_good = parameters.get("min_good") self.offset = parameters.get("offset") self.reps = parameters.get("reps") self.sum_scale = parameters.get("sum_scale") self.sum_zero = parameters.get("sum_zero") self.good = numpy.zeros(self.reps, dtype=numpy.bool) self.mag = numpy.zeros(self.reps) self.x_off = numpy.zeros(self.reps) self.y_off = numpy.zeros(self.reps) self.lpf = slpf.LockPeakFinder(offset=0, sigma=parameters.get("sigma"), threshold=parameters.get("threshold")) assert (self.reps >= self.min_good), "'reps' must be >= 'min_good'."