In [1]:
# this cell is hidden via the metadata
from nbodykit import style
import matplotlib.pyplot as plt
plt.style.use(style.notebook)
In [2]:
from nbodykit.lab import UniformCatalog
cat = UniformCatalog(nbar=100, BoxSize=1.0, seed=42)
mesh = cat.to_mesh(Nmesh=16)
print("mesh = ", mesh)
In [3]:
from nbodykit.lab import LinearMesh, cosmology
from matplotlib import pyplot as plt
cosmo = cosmology.Planck15
Plin = cosmology.LinearPower(cosmo, redshift=0, transfer='EisensteinHu')
# initialize the mesh
mesh = LinearMesh(Plin, Nmesh=128, BoxSize=1380, seed=42)
# preview the density field
plt.imshow(mesh.preview(axes=[0,1]))
Out[3]:
In [4]:
from nbodykit.lab import FieldMesh
from pmesh.pm import RealField, ComplexField, ParticleMesh
# a 8^3 mesh
pm = ParticleMesh(Nmesh=[8,8,8])
# initialize a RealField
rfield = RealField(pm)
# set entire mesh to unity
rfield[...] = 1.0
# initialize from the RealField
real_mesh = FieldMesh(rfield)
# can also initialize from a ComplexField
cfield = rfield.r2c()
complex_mesh = FieldMesh(cfield)
In [5]:
from nbodykit.lab import ArrayMesh
import numpy
# generate random data on a 128^3 mesh
data = numpy.random.random(size=(128,128,128))
# inititalize the mesh
mesh = ArrayMesh(data, BoxSize=1.0)
# preview the density mesh
plt.imshow(mesh.preview(axes=[0,1]))
Out[5]: