def expy(d): colors = ['b','g','r','c','m','y','k','b--','g--','r--','c--','m--','y--'] multi = 2.**N.arange(2,3.1,1.) #multi = [77.] for i in range(len(multi)): dinflate = N.exp((d)*multi[i])-1. k,p = power.pk(dinflate) var = N.var((d)*multi[i]) lognocor = ((N.exp(var)-1)*N.exp(var)/var) lognovar = (N.exp(var)-1)*N.exp(var) print 1+2*var,'lognocor:',lognocor #varlog = N.var(N.log(dinflate+1.).flatten()) k,plog = power.pk(N.log(dinflate+1)) print p[0]/plog[0], p[-1]/plog[-1] #M.subplot(121) M.loglog(k,p/plog/lognocor,colors[i]) #M.subplot(122) #M.loglog(k,plog,colors[i]) #M.loglog([k[0],k[-1]],[lognovar,lognovar],colors[i]) #M.loglog(k,1./plog**mul,colors[i]) #preal = M.load('mill/s63/pm.pnl.dat') #plogreal = M.load('mill/s63/plogm.pnl.dat') #M.loglog(preal[:,0],preal[:,1]/plogreal[:,1],'b') #M.xlabel(r'$k\ [\rm{Mpc}/h]$',fontsize=20) #M.ylabel(r'$P_\delta(k)/P_{\log (1+\delta)}(k)$',fontsize=20) M.show()
def logskew(d,floors = [],col='',divvypk=[]): maxd = max(d.flatten()) if len(floors) == 0: floors = 1./maxd * 2.**N.arange(-5,5.01,1.) print floors for fl in floors: dcopy = 1.*d wltf = N.where(dcopy < fl) dcopy[wltf] = 0.*dcopy[wltf] + fl logrho = N.log(dcopy) var = N.var(decreaseres(logrho,f=16).flatten()) #skew = SS.skew(logrho.flatten()) #print fl,'log:',var,'lin:',N.var(dcopy.flatten()) print fl,'log:',var#,SS.skew(dcopy.flatten()) k,pk = power.pk(logrho) if (len(divvypk) > 0): M.loglog(k,pk/divvypk/var,col) if (len(divvypk) == 0): return pk,pk/var else: return
def gaussy(d): colors = ['b','g','r','c','m','y','b--','g--','r--','c--','m--','y--'] multi = 2.**N.arange(0,4.1,1) M.clf() for i in range(len(multi)): dinflate = (d-1.)*multi[i] k,p = power.pk(dinflate) w0 = N.where(dinflate <=-0.9999) dinflate[w0] = dinflate[w0]*0. -0.9999 k,plog = power.pk(N.log(dinflate+1.)) print p[0]/plog[0], p[-1]/plog[-1] M.loglog(k,p/plog,colors[i]) M.show()
cdNu2 = CIC.getDemNu(mapNu2) cdNu2 = N.double(cdNu2) den2 = N.sum(cdNu2)/2000.**3 npix = N.size(cdNu2.flat) cdNu2 = cdNu2/((N.sum(cdNu2))/npix) #turn into a density field print N.var(cdNu1) print N.var(cdNu2) print N.var(N.log(cdNu1)) print N.var(N.log(cdNu2)) """ Calculate Power spectrum """ print 'Power spectrum min mass' Pow.pk(cdNu1, boxsize=2000., filename='PkNu17z0.txt') out = N.loadtxt(open('./Output/PkNu17z0.txt')) kmin = out[:,0] Pkmin = out[:,1] print 'Log power spectrum min mass' Pow.pk(N.log(cdNu1), boxsize=2000., filename='PklogNu17z0.txt') out = N.loadtxt(open('./Output/PklogNu17z0.txt')) klogmin = out[:,0] Pklogmin = out[:,1] print 'Power spectrum max mass' Pow.pk(cdNu2, boxsize=2000., filename='PkNu30z0.txt') out = N.loadtxt(open('./Output/PkNu30z0.txt')) kmax = out[:,0] Pkmax = out[:,1] print 'Log power spectrum max mass'