def b(params,value,iter): "Print status everytime a best fit is found." m=iso.computeCMD(params,isos) C=sum(data.flat)/sum(m.flat) x=array(params) bestfit[0] = x*C file("bestfit117","w").write(str(list(bestfit[0]))) print "henry:",value,"tom:",2.0*(value+llhC),"iter:",iter,"norm:",C
def b(params,value,iter): "Print status everytime a best fit is found." m=iso.computeCMD(params,isos) C=sum(data.flat)/sum(m.flat) x=array(params) bestfit[0] = x*C file("bestfit117","w").write(str(list(bestfit[0]))) print "henry:",value,"tom:",2.0*(value+llhC),"iter:",iter,"norm:",C
def f(par): params.setvalues(par) w = utils.calculateweights(t, sfr(t, params)) #isow=iso.getisosweights(w,10.**t,metallicity(t,params),isos) isow = iso.getisosweights_gauss(w, 10.**t, metallicity(t, params), isos, params.sigma) m = iso.computeCMD(isow, isos) m = utils.normalize(m, sum(data.flat)) return utils.loglikelihood(m, data)
def f(par): params.setvalues(par) w=utils.calculateweights(t,sfr(t,params)) isow=iso.getisosweights(w,10.**t,metallicity(t,params),isos) #isow=iso.getisosweights_gauss(w,10.**t,metallicity(t,params),isos, # params.sigma) m=iso.computeCMD(isow,isos) m=utils.normalize(m,ndata) return utils.loglikelihood(m,data)
def f(params): w = utils.calculateweights(t, sfr(t, params)) isow = iso.getisosweights(w, 10.**t, metallicity(t, params), isos) #a3=time.time() m = iso.computeCMD(isow, isos) #a4=time.time() m = utils.normalize(m, ndata) l = utils.loglikelihood(m, data) #print a4-a3 return l
def f(params): w=utils.calculateweights(t,sfr(t,params)) isow=iso.getisosweights(w,10.**t,metallicity(t,params),isos) #a3=time.time() m=iso.computeCMD(isow,isos) #a4=time.time() m=utils.normalize(m,ndata) l= utils.loglikelihood(m,data) #print a4-a3 return l
def f(params): global iter m = iso.computeCMD(params, isos) C = ndata / sum(m.flat) x = numarray.array(params) # out.write(str(list(x*C))+"\n") pickle.dump(x * C, out, protocol=-1) value = utils.loglikelihood(m * C, data) # out.write("henry: %r tom: %r iter: %r norm: %r\n" # %(value,2.0*(value+llhC),iter,C)) pickle.dump((value, 2.0 * (value + llhC), iter, C), out, protocol=-1) #out.flush() iter += 1 return value
def f(params): global iter m=iso.computeCMD(params,isos) C=ndata/sum(m.flat) x=numarray.array(params) # out.write(str(list(x*C))+"\n") pickle.dump(x*C,out,protocol=-1) value=utils.loglikelihood(m*C,data) # out.write("henry: %r tom: %r iter: %r norm: %r\n" # %(value,2.0*(value+llhC),iter,C)) pickle.dump((value,2.0*(value+llhC),iter,C),out,protocol=-1) #out.flush() iter+=1 return value
def f(params): m=utils.normalize(iso.computeCMD(params,isos),ndata) return utils.loglikelihood(m,data)
def f(params): m = utils.normalize(iso.computeCMD(params, isos), ndata) return utils.loglikelihood(m, data)
#! /usr/bin/env python """Writes all the information about the best fit to the file "protocol" """ import sys from chemev import iso, isodir, utils print "reading isochrones" data = iso.readfits(isodir + "/117/halo/datarr.fits") isos = iso.readisos(isodir + "/117/halo") isow = eval(open("bestfit117").readline()) model = iso.computeCMD(isow, isos) model = utils.normalize(model, sum(data.flat)) def plot_residuals(d, m, aspect=0.2): """ todo: the same color range for both data and model. the rediduals are ok """ import pylab pylab.figure() pylab.subplot(221) pylab.imshow(d, origin='lower', interpolation="nearest", aspect=aspect) pylab.title("data") pylab.colorbar() pylab.subplot(222) pylab.imshow(m, origin='lower', interpolation="nearest", aspect=aspect) pylab.title("model") pylab.colorbar() pylab.subplot(223) residuals = d - m
#! /usr/bin/env python """Writes all the information about the best fit to the file "protocol" """ import sys from chemev import iso, isodir, utils print "reading isochrones" data = iso.readfits(isodir+"/117/halo/datarr.fits") isos = iso.readisos(isodir+"/117/halo") isow = eval(open("bestfit117").readline()) model = iso.computeCMD(isow,isos) model = utils.normalize(model,sum(data.flat)) def plot_residuals(d,m,aspect=0.2): """ todo: the same color range for both data and model. the rediduals are ok """ import pylab pylab.figure() pylab.subplot(221) pylab.imshow(d,origin='lower',interpolation="nearest",aspect=aspect) pylab.title("data") pylab.colorbar() pylab.subplot(222) pylab.imshow(m,origin='lower',interpolation="nearest",aspect=aspect) pylab.title("model") pylab.colorbar() pylab.subplot(223) residuals = d-m pylab.imshow(residuals,origin='lower',interpolation="nearest",aspect=aspect)