Skip to main content

Create arbitrary boxes with isotropic power spectra

Project description

https://coveralls.io/repos/github/steven-murray/powerbox/badge.svg?branch=master https://img.shields.io/pypi/v/powerbox.svg https://travis-ci.org/steven-murray/powerbox.svg?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

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


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.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

powerbox-0.2.1-py2-none-any.whl (8.5 kB view details)

Uploaded Python 2

File details

Details for the file powerbox-0.2.1.tar.gz.

File metadata

  • Download URL: powerbox-0.2.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for powerbox-0.2.1.tar.gz
Algorithm Hash digest
SHA256 219e8ec537e518d363083d9d98d516d812fe33da00fac502e704fc9da16b0634
MD5 d81af6fa5ee3146559eac7c11cb61c05
BLAKE2b-256 a33195741336baeb6a5957f391eb87bf43b176097f0ce0e289b42e186081e9c2

See more details on using hashes here.

File details

Details for the file powerbox-0.2.1-py2-none-any.whl.

File metadata

File hashes

Hashes for powerbox-0.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 9fd896c2e3694bcd273f9d07c28b0bf84b490421c10a0699a60583c67d22891a
MD5 980b09abd24d16ed1c25de914a1d4c79
BLAKE2b-256 49200b2e70535ce0f9799aad4fd425cefe14c459d22bc9fce23d0446b8d77dcd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page