# 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 ({class}`~kspace.GaussianRandomField`), including divergence-free vector fields. - Built-in power spectrum models ({class}`~kspace.PowerLaw`, {class}`~kspace.PowerLawBetaModel`, {class}`~kspace.DoublePowerLaw`), or supply your own callable via {class}`~kspace.PowerSpectrum`. - FFT-based analysis ({class}`~kspace.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 by `kspace` or any other gridded data, such as from hydrodynamic simulations. ```{toctree} :maxdepth: 2 :hidden: installation quickstart conventions tutorials/index api/index ```