def test(challenge,lim=None): meta,desi,times_f,resid_f,error_f = load(challenge,limit=int(lim)) alphaab = alphamat(meta) print 'Working with {0} pulsars.'.format(len(meta)) with timing('GW covariance matrix [recurring]'): cgw = Cgw_100ns(alphaab,times_f,-2.0/3.0,fL=1.0/500,approx_ksum=True) cgw2 = cgw.copy() with timing('Cgw interpolation'): cgw3 = 0.2 * cgw + 0.8 * cgw2 with timing('PN covariance matrix'): cpn = Cpn(error_f) with timing('Design matrix'): gmat = Gdesi2(desi,meta) # note this takes meta, not len(meta) with timing('Reduced data'): resid_f = N.dot(gmat.T,resid_f) with timing('Reduced Cpn'): cpn = blockmul(cpn,gmat,meta,blas=True) with timing('Reduced Cgw [recurring]'): cgw = blockmul(cgw,gmat,meta,blas=True) cgw2 = cgw.copy() with timing('Reduced-Cgw interpolation'): cgw3 = 0.2 * cgw + 0.8 * cgw2 with timing('Likelihood [recurring]'): logl = logL(resid_f,cgw,cpn)
def lnprob(x): """logL stub function for emcee. It needs to use global variables because otherwise multiprocessing.map will need to transmit big arrays to the slave processes.""" global resid_f,cgw,cpn return logL(resid_f,cgw,cpn,A=x[0],n=1,cgwunit='100ns')