Fixed whitification. Numpy was not viewing the arrays but copying them
This commit is contained in:
parent
0aeb0d80c3
commit
ca379c91ee
2 changed files with 23 additions and 9 deletions
|
@ -136,8 +136,12 @@ def whitify(density, L, cosmo, supergenerate=1, func='HU_WIGGLES'):
|
|||
if supergenerate > 1:
|
||||
|
||||
cond=np.isnan(density_hat_super)
|
||||
x = np.random.randn(np.count_nonzero(cond),2)/np.sqrt(2.0)
|
||||
density_hat_super[cond] = x[:,0] + 1j * x[:,1]
|
||||
print np.where(np.isnan(density_hat_super))[0].size
|
||||
Nz = np.count_nonzero(cond)
|
||||
density_hat_super.real[cond] = np.random.randn(Nz)
|
||||
density_hat_super.imag[cond] = np.random.randn(Nz)
|
||||
density_hat_super[cond] /= np.sqrt(2.0)
|
||||
print np.where(np.isnan(density_hat_super))[0].size
|
||||
|
||||
# Now we have to fix the Nyquist plane
|
||||
hNs = Ns/2
|
||||
|
@ -145,6 +149,8 @@ def whitify(density, L, cosmo, supergenerate=1, func='HU_WIGGLES'):
|
|||
Nplane = nyquist.size
|
||||
nyquist.flat[:Nplane/2] = np.sqrt(2.0)*nyquist.flat[Nplane:Nplane/2:-1].conj()
|
||||
|
||||
print np.where(np.isnan(density_hat_super))[0].size
|
||||
|
||||
return np.fft.irfftn(density_hat_super)*Ns**1.5
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue