powerbox.powerbox.LogNormalPowerBox¶
-
class
powerbox.powerbox.
LogNormalPowerBox
(*args, **kwargs)[source]¶ A subclass of
PowerBox
which calculates Log-Normal density fields with given power spectra.See the documentation of
PowerBox
for a detailed explanation of the arguments, as this class has exactly the same arguments.This class calculates an (over-)density field of arbitrary dimension given an input isotropic power spectrum. In this case, the field has a log-normal distribution of over-densities, always yielding a physically valid field.
Examples
To create a log-normal over-density field:
>>> from powerbox import LogNormalPowerBox >>> lnpb = LogNormalPowerBox(100,lambda k : k**-7./5.,dim=2, boxlength=1.0) >>> overdensities = lnpb.delta_x >>> grid = lnpb.x >>> radii = lnpb.r
To plot the overdensities:
>>> import matplotlib.pyplot as plt >>> plt.imshow(pb.delta_x)
Compare the fields from a Gaussian and Lognormal realisation with the same power:
>>> lnpb = LogNormalPowerBox(300,lambda k : k**-7./5.,dim=2, boxlength=1.0) >>> pb = PowerBox(300,lambda k : k**-7./5.,dim=2, boxlength=1.0) >>> fig,ax = plt.subplots(2,1,sharex=True,sharey=True,figsize=(12,5)) >>> ax[0].imshow(lnpb.delta_x,aspect="equal",vmin=-1,vmax=lnpb.delta_x.max()) >>> ax[1].imshow(pb.delta_x,aspect="equal",vmin=-1,vmax = lnpb.delta_x.max())
To create and plot a discrete version of the field:
>>> positions = lnpb.create_discrete_sample(nbar=1000.0, # Number density in terms of boxlength units >>> randomise_in_cell=True) >>> plt.scatter(positions[:,0],positions[:,1],s=2,alpha=0.5,lw=0)
Methods
__init__
(*args, **kwargs)x.__init__(…) initializes x; see help(type(x)) for signature correlation_array
()The correlation function from the input power, on the grid create_discrete_sample
(nbar[, …])Assuming that the real-space signal represents an over-density with respect to some mean, create a sample of tracers of the underlying density distribution. delta_k
()A realisation of the delta_k, i.e. delta_x
()The real-space over-density field, from the input power spectrum gauss_hermitian
()A random array which has Gaussian magnitudes and Hermitian symmetry gaussian_correlation_array
()The correlation function required for a Gaussian field to produce the input power on a lognormal field gaussian_power_array
()The power spectrum required for a Gaussian field to produce the input power on a lognormal field k
()The entire grid of wavenumber magitudes power_array
()The Power Spectrum (volume normalised) at self.k Attributes
kvec
The vector of wavenumbers along a side r
The radial position of every point in the grid x
The co-ordinates of the grid along a side