-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Thanks for the repo :) It's very clear and easy to use.
I am having issues generating a density field with nbodykit's power spectrum and powerbox, maybe you can help me. This is what I'm doing,
import matplotlib.pyplot as plt
import numpy as np
from astropy.cosmology import Planck18
from nbodykit.cosmology.power.halofit import HalofitPower
import powerbox as pbox
from powerbox import get_power
redshift = 0.
pk = HalofitPower(Planck18,redshift=redshift)
boxsize = 512.
pb = pbox.PowerBox(
N=256,
dim=2,
pk = pk,
boxlength = boxsize,
ensure_physical=True
)
delta_x = pb.delta_x()
samples = pb.create_discrete_sample(
delta_x=delta_x,
nbar=0.1,
min_at_zero=True
)
p_k_field, bins_field = get_power(delta_x, pb.boxlength)
p_k_samples, bins_samples = get_power(samples, pb.boxlength,N=pb.N)
plt.plot(bins_field,pk(bins_field), label='Input')
plt.plot(bins_field, p_k_field,label="Output Field Power")
plt.plot(bins_samples, p_k_samples,label="Output Sample Power")
plt.legend()
plt.xscale('log')
plt.yscale('log')And this what I find for the output power spectra:

As you can see, the amplitude of each of one them is different. Any idea of why they don't match up?
Also, I have noticed that when running the code in 3D it becomes quite slow. Do you have any suggestions to speed it up?
Thank you in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels