

def FitErrorFunction(self, fitpars):
    '\n        The error function for the fitter. This should never be called directly!\n        '
    if self.return_resolution:
        (model, resolution) = self.GenerateModel(fitpars, return_resolution=True)
    else:
        model = self.GenerateModel(fitpars)
    outfile = open('chisq_summary.dat', 'a')
    weights = np.ones(self.data.size())
    weights /= weights.sum()
    good = np.arange(self.data.x.size, dtype=np.int32)
    if ((len(self.ignore) > 0) and all([(len(region) > 0) for region in self.ignore])):
        for region in self.ignore:
            x0 = min(region)
            x1 = max(region)
            tmp1 = [(self.data.x[i] in self.data.x[good]) for i in range(self.data.x.size)]
            tmp2 = np.logical_or((self.data.x < x0), (self.data.x > x1))
            good = np.where(np.logical_and(tmp1, tmp2))[0]
    logging.info('Fraction of points used in X^2 evaluation: {}'.format((float(good.size) / float(self.data.size()))))
    return_array = ((self.data.y - (self.data.cont * model.y))[good] * weights[good])
    fit_idx = 0
    for i in range(len(self.bounds)):
        if self.fitting[i]:
            outfile.write(('%.12g\t' % self.const_pars[i]))
            self.parvals[i].append(self.const_pars[i])
            fit_idx += 1
    outfile.write(('%g\n' % (np.sum((return_array ** 2)) / float(weights.size))))
    self.chisq_vals.append((np.sum((return_array ** 2)) / float(weights.size)))
    logging.info('X^2 = {}'.format((np.sum((return_array ** 2)) / float(weights.size))))
    outfile.close()
    return return_array

dataset/ETHPy150Open kgullikson88/Telluric-Fitter/src/TelluricFitter.py TelluricFitter.FitErrorFunction/original