Create arbitrary boxes with isotropic power spectra
Project description
========
powerbox
========
.. image:: https://coveralls.io/repos/github/steven-murray/powerbox/badge.svg?branch=master
:target: https://coveralls.io/github/steven-murray/powerbox?branch=master
**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
.. code:: python
from powerbox import PowerBox, LogNormalPowerBox
Once imported, to see all the options, just use `help`:
.. code:: python
help(PowerBox)
For a basic 2D Gaussian field with a power-law power-spectrum, one can use the following:
.. code:: python
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.
powerbox
========
.. image:: https://coveralls.io/repos/github/steven-murray/powerbox/badge.svg?branch=master
:target: https://coveralls.io/github/steven-murray/powerbox?branch=master
**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
.. code:: python
from powerbox import PowerBox, LogNormalPowerBox
Once imported, to see all the options, just use `help`:
.. code:: python
help(PowerBox)
For a basic 2D Gaussian field with a power-law power-spectrum, one can use the following:
.. code:: python
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
powerbox-0.2.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file powerbox-0.2.0.tar.gz
.
File metadata
- Download URL: powerbox-0.2.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9bac64ac97c39ff146e3ec7673338a3d7724f5080272e34e4eed34ed2c15a8 |
|
MD5 | 4f0efd27929cd4ed88c1e06be0463591 |
|
BLAKE2b-256 | b2776ac6a0022700c8cd41577b42648a456c09df5295a5ad1c24703829725b18 |
File details
Details for the file powerbox-0.2.0-py2-none-any.whl
.
File metadata
- Download URL: powerbox-0.2.0-py2-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0f3469f40e38c6069ccc9f531cf963c15a8bf37b13b7a97041e9517d51a496b |
|
MD5 | 532671f1c411b04a438969a44c427488 |
|
BLAKE2b-256 | e524d95d5e6a0df2aac2e79e6a0f217a86683a6efdd34907da1d1a5748c37e4e |