kspace#
kspace is a Python package for working with scalar and vector fields in
1, 2, or 3 dimensions for use in physical models and simulations. It provides
capabilities for generating, analyzing, and manipulating fields in both real
and Fourier spaces, with a focus on Gaussian random fields (GRFs) and their
power spectra. This approach is well-suited to producing synthetic turbulent
velocity or magnetic fields with a prescribed power spectrum.
Core features:
Generate scalar or vector GRF realizations from an arbitrary power spectrum (
GaussianRandomField), including divergence-free vector fields.Built-in power spectrum models (
PowerLaw,PowerLawBetaModel,DoublePowerLaw), or supply your own callable viaPowerSpectrum.FFT-based analysis (
FourierAnalysis): binned power spectra, divergence and curl of vector fields, windowing to reduce FFT boundary effects, and vector-potential/curl inversion. Works with fields generated bykspaceor any other gridded data, such as from hydrodynamic simulations.