def print_fit(self,par,outfile): """print the energy and amplitude results from a fit""" fit = self.results name = self.name p = fit.p self.chi2_cal() self.chi2_aug_part() self.Q = conf_int(self.chi2/2, par.ncon, self.dof/2) dE = exp(p['log('+name+':dE)']) E = [sum(dE[:i+1]) for i in range(self.nexp)] a = exp(p['log('+name+':a)']) if self.name != 'pimom0': dEo = exp(p['log('+name+':dEo)']) Eo = [sum(dEo[:i+1]) for i in range(self.nexp)] ao = exp(p['log('+name+':ao)']) ofile = open(outfile,'a') if self.dof > 0: chi2dof = self.chi2/self.dof else: chi2dof = 99.9 if chi2dof > 99: chi2dof = 99.9 form = "{:s} & {:2d} - {:2d} & {:d}+{:d} & {:4.1f} & {:3d} & {:4.2f} " ena = "& {:<11s} & {:<11s} " ofile.write( form.format( self.name,self.tmin,self.tmax,self.nexp,self.noxp,chi2dof,self.dof,self.Q ) ) for i in range(self.nexp): ofile.write( ena.format(E[i].fmt(ndecimal=4),a[i].fmt(ndecimal=4),Eo[i].fmt(ndecimal=4),ao[i].fmt(ndecimal=4)) ) ofile.write(" \\\\ \n")
def print_fit(self,par,outfile): """print the energy and amplitude results from a fit""" fit = self.results name = self.name p = fit.p self.chi2_cal() #self.chi2_aug_part() self.Q = conf_int(self.chi2/2, par.ncon, self.dof/2) nexp = self.child.nexp name = self.child.name CdE = exp(p['log('+name+':dE)']) CE = [sum(CdE[:i+1]) for i in range(nexp)] a = exp(p['log('+name+':a)']) if self.name != 'pimom0': CdEo = exp(p['log('+name+':dEo)']) CEo = [sum(CdEo[:i+1]) for i in range(nexp)] ao = exp(p['log('+name+':ao)']) name = self.parent.name PdE = exp(p['log('+name+':dE)']) PE = [sum(PdE[:i+1]) for i in range(nexp)] b = exp(p['log('+name+':a)']) if self.name != 'pimom0': PdEo = exp(p['log('+name+':dEo)']) PEo = [sum(PdEo[:i+1]) for i in range(nexp)] bo = exp(p['log('+name+':ao)']) # calculating f_0 # DOESN"T WORK FOR D TO K YET!!!!!!!!! if self.child.name == 'pimom0': mpi = CE[0] else: mpi = gvar(par.pi0,par.pi0_err) if self.child.name == 'pimom0' or self.child.name == 'pimom2': m_q = par.m_l else: m_q = par.m_s Epi = CE[0] mD = PE[0] v = p['Vnn'][0][0] self.f_0 = v*sqrt(Epi*mD)*(par.m_c-m_q)/(mD**2-mpi**2) self.qsq = mpi**2+mD**2-2*mD*Epi ofile = open(outfile,'a') if self.dof != 0: chi2dof = self.chi2/self.dof else: chi2dof = 99.9 if chi2dof > 99: chi2dof = 99.9 pars = "{:s} & {:2d}-{:2d} & {:2d}-{:2d} & {:d}+{:d} & {:4.1f} & {:3d} & {:4.2f} & " energies = "{:s} & {:<11s} & {:<11s} & " form = "{:<12s} & {:<12s} \\\\ \n" ofile.write( pars.format( self.name,self.tmin,self.child.tmax,self.tmax,self.parent.tmax, nexp,nexp,chi2dof,self.dof,self.Q ) +energies.format( self.child.name,CE[0].fmt(ndecimal=4),a[0].fmt(ndecimal=4) ) +energies.format( self.parent.name,PE[0].fmt(ndecimal=4),b[0].fmt(ndecimal=4) ) +form.format( self.f_0.fmt(ndecimal=4), self.qsq.fmt(ndecimal=4) ) )