Tools for generating and analyzing Gaussian random fields (GRFs) and their power spectra on regular grids, in 1, 2, or 3 dimensions. Built for astrophysical/cosmological applications where fields are specified by a power spectrum in Fourier space and realized on a real-space grid.
Features:
- Generate scalar or vector Gaussian random field realizations from an
arbitrary power spectrum (
GaussianRandomField), including divergence-free vector fields. - Built-in power spectrum models (
PowerLaw,PowerLawBetaModel), or supply your own callable. - FFT-based analysis (
FourierAnalysis): binned power spectra, divergence and curl of vector fields, windowing to reduce FFT boundary effects.
Install
pip install kspace
For development, clone the repo and use uv:
uv sync
To also install the heavier dependencies used by the example notebooks
(matplotlib, pandas, yt, h5py, pooch):
uv sync --group docs
Quick example
import numpy as np
from kspace import GaussianRandomField, FourierAnalysis, PowerLawBetaModel
# A power-law power spectrum with large- and small-scale cutoffs
power_spec = PowerLawBetaModel(l_min=10.0, l_max=200.0, alpha=-11.0 / 3.0)
power_spec.renormalize(f_rms=10.0)
le = np.array([0.0, 0.0, 0.0])
re = np.array([750.0, 750.0, 750.0])
ddims = [256, 256, 256]
grf = GaussianRandomField(le, re, ddims, power_spec, seed=10)
field = grf.generate_scalar_field_realization()
fa = FourierAnalysis(re - le, ddims)
kbins, pk = fa.make_binned_powerspec(field, nbins=60)
See docs/examples/ for more complete, runnable notebooks (GRF generation,
vector field decomposition, power spectrum estimation, and analysis of
simulation data).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kspace-0.1.0.tar.gz.
File metadata
- Download URL: kspace-0.1.0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8c9e93e8c33216463708759a5d474b38f9e260f0188c0d6eb32c0a0274a7fbf
|
|
| MD5 |
958b9507ca19240c08bc6d9b8110bd21
|
|
| BLAKE2b-256 |
71c8d2d6be49eb47bb89a746868ed317e83360873a8a58304fcd951ef8976d3d
|
Provenance
The following attestation bundles were made for kspace-0.1.0.tar.gz:
Publisher:
publish.yml on jzuhone/kspace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kspace-0.1.0.tar.gz -
Subject digest:
a8c9e93e8c33216463708759a5d474b38f9e260f0188c0d6eb32c0a0274a7fbf - Sigstore transparency entry: 2424719032
- Sigstore integration time:
-
Permalink:
jzuhone/kspace@9c07f0b943dec1e64fffdfa488c683ef04a89cc7 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/jzuhone
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9c07f0b943dec1e64fffdfa488c683ef04a89cc7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kspace-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kspace-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdc29773f5ba1b3e047c6b8850b4bae19577b022d4563cb3c3c25bc71790a9a
|
|
| MD5 |
39f1ddf93fef44c5b05e70d217f60101
|
|
| BLAKE2b-256 |
bcbabc136dc390e6f7c59974c6e23134aa9fb4721c49a016ce8e7384347996f0
|
Provenance
The following attestation bundles were made for kspace-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jzuhone/kspace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kspace-0.1.0-py3-none-any.whl -
Subject digest:
6cdc29773f5ba1b3e047c6b8850b4bae19577b022d4563cb3c3c25bc71790a9a - Sigstore transparency entry: 2424719046
- Sigstore integration time:
-
Permalink:
jzuhone/kspace@9c07f0b943dec1e64fffdfa488c683ef04a89cc7 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/jzuhone
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9c07f0b943dec1e64fffdfa488c683ef04a89cc7 -
Trigger Event:
release
-
Statement type: