This commit is contained in:
Guilhem Lavaux 2014-07-03 15:38:38 +02:00
commit d31d1245c2
4 changed files with 100 additions and 37 deletions

View file

@ -7,7 +7,7 @@ import borgadaptor as ba
def gen_posgrid(N, L):
""" Generate an ordered lagrangian grid"""
ix = np.arange(N)*L/N
ix = (np.arange(N)*L/N).astype(np.float32)
x = ix[:,None,None].repeat(N, axis=1).repeat(N, axis=2)
y = ix[None,:,None].repeat(N, axis=0).repeat(N, axis=2)
@ -95,7 +95,9 @@ def run_generation(input_borg, a_borg, a_ic, cosmo, supersample=1, do_lpt2=True,
print("velmul=%lg" % (cosmo['h']*velmul))
density = cgrowth.D(1)/cgrowth.D(a_borg)*np.fft.irfftn(lpt.dhat)*(supersample*N/L)**3
lpt.cube.dhat = lpt.dhat
density = lpt.cube.irfft()
density *= (cgrowth.D(1)/cgrowth.D(a_borg))
return posx,vel,density,N*supersample,L,a_ic,cosmo
@ -117,7 +119,9 @@ def whitify(density, L, cosmo, supergenerate=1, func='HU_WIGGLES'):
Pk = build_Pk()
Pk[0,0,0]=1
density_hat = np.fft.rfftn(density)*(L/N)**3
cube = CubeFT(N, L)
cube.density = density
density_hat = cube.rfft()
density_hat /= np.sqrt(Pk)
Ns = N*supergenerate
@ -152,6 +156,8 @@ def whitify(density, L, cosmo, supergenerate=1, func='HU_WIGGLES'):
print np.where(np.isnan(density_hat_super))[0].size
cube = CubeFT(Ns, L)
cube.dhat = density_hat_super
return np.fft.irfftn(density_hat_super)*Ns**1.5