Create arbitrary boxes with isotropic power spectra
Project description
Make arbitrarily structured, arbitrary-dimension boxes.
powerbox is a pure-python code for creating density grids (or boxes) that have an arbitrary two-point distribution (i.e. power spectrum). Primary motivations for creating the code were the simple creation of lognormal mock galaxy distributions, but the methodology can be used for other applications.
Features
Works in any number of dimensions.
Really simple.
Arbitrary isotropic power-spectra.
Create Gaussian or Log-Normal fields
Create discrete samples following the field, assuming it describes an over-density.
Installation
Clone/Download then python setup.py install. Or just pip install powerbox.
Basic Usage
There are two useful classes: the basic PowerBox and one for log-normal fields: LogNormalPowerBox. You can import them like
from powerbox import PowerBox, LogNormalPowerBox
Once imported, to see all the options, just use help:
help(PowerBox)
For a basic 2D Gaussian field with a power-law power-spectrum, one can use the following:
pb = PowerBox(N=512, # Number of grid-points in the box
dim=2, # 2D box
pk = lambda k: 0.1*k**-2., # The power-spectrum
boxlength = 1.0) # Size of the box (sets the units of k in pk)
import matplotlib.pyplot as plt
plt.imshow(pb.delta_x)
Other attributes of the box can be accessed also – check them out with tab completion in an interpreter! The LogNormalPowerBox class is called in exactly the same way, but the resulting field has a log-normal pdf with the same power spectrum.
TODO
At this point, log-normal transforms are done by back-and-forward FFTs on the grid, which could be slow for higher dimensions. Soon I will implement a more efficient way of doing this using numerical Hankel transforms.
Some more tests might be nice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file powerbox-0.2.2.tar.gz
.
File metadata
- Download URL: powerbox-0.2.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66d5af495b9951bd43fbb7166d7578fe4a0dce493d14dd7ed4bdcebb082e14d8 |
|
MD5 | cea5321469a82c0e8b887636b89318b3 |
|
BLAKE2b-256 | 875c2691a5cc16cc12a6b69d5475d2c8b3647cb6c26b4b25f835f29d4e94d3d3 |
File details
Details for the file powerbox-0.2.2-py2-none-any.whl
.
File metadata
- Download URL: powerbox-0.2.2-py2-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 945eed01338eda87b5244e0d1371be60f332de5c9ba60e1e5648dc60358531b1 |
|
MD5 | 0c220ae49398e423e3b6c0c879537cfe |
|
BLAKE2b-256 | dcb51f6945c0c5bcb8c1f67e8dfafb936b97d05c1e95759bf16769fe6d3140bb |