structure-factor-v2
Structure factor $S(k)$ of point sets in the unit cube $[0, 1)^D$, estimated by the scattering intensity, with fast transforms (finufft / cufinufft) and ready-made log-log plots.
The structure factor measures the density fluctuations of a point set in Fourier space (it is the power spectrum, up to normalisation). For a hyperuniform (blue-noise) pattern, $S(k) \to 0$ as $k \to 0$; for an order $\alpha$ hyperuniform pattern $S(k) \sim k^\alpha$.
Installation
pip install structure-factor-v2 # CPU: numpy + finufft
#pip install structure-factor-v2[gpu12] # GPU: [gpu12] or [gpu13], cupy + cufinufft
Quick start
import structure_factor_v2 as sf
import numpy as np
N, D = 10_000, 2
x = sf.jittered_lattice(N, D) # (N, D) points in [0, 1)^D, hyperuniform
sf.plot(x) # scatter plot
sf.plot_structure_factor(x) # log-log S(k), raw values + radial average
Built-in samplers:
sf.plot_structure_factor(np.random.rand(N, D)) # Poisson: S = 1
sf.plot_structure_factor(sf.korobov_lattice(N, D)) # crystal
sf.plot_structure_factor(sf.jittered_lattice(N, D)) # noisy cristal (hyperuniform, but free of bragg peaks)
sf.plot_structure_factor(sf.curled_lattice(N, D)) # curl noise (replace iid jitter with divergence free perturbation)
Two estimators: trust_boundary
trust_boundary |
When |
|---|---|
True (default) |
the points self compensate for any boundary effects (eg they are periodic) |
False |
the points need a procedure to compensate for boundary effect (here tapering, with a kaiser taper) |
"both" |
(plots only) compare the two |
sf.plot_structure_factor(x, trust_boundary="both")
Backends, precision and tolerance
Structure factor computation takes backend, precision and nufft_tolerance, assumming
that the backend's dependency are properly installed :
backend |
method | dimensions |
|---|---|---|
"finufft" |
type-1 non-uniform FFT, CPU | D <= 6 |
"cufinufft" |
same, GPU | D <= 6 |
"keops" |
direct sums, pykeops (GPU if available) | any |
"torch" |
direct sums, torch (cuda if available) | any |
"numpy" |
direct sums, numpy | any |
"cupy" |
direct sums, cupy | any |
References
- Korobov lattices: I. H. Sloan and S. Joe. Lattice Methods for Multiple Integration. Oxford University Press, 1994.
- Curl noise jittering: J. A. Bærentzen, J. R. Frisvad, and J. Martínez. Curl Noise
Jittering. SIGGRAPH Asia 2023 Conference Papers, article 88, 2023.
doi:10.1145/3610548.3618163,
code: jonasmb/curlnoisejittering.
curled_latticestarts from a Korobov lattice instead of their triangular / cubic grids, and uses a random Fourier divergence-free field (exactly periodic, any dimension) instead of the curl of a Perlin noise; independent implementation. - finufft / cufinufft: A. H. Barnett, J. F. Magland, and L. af Klinteberg. A parallel non-uniform fast Fourier transform library based on an "exponential of semicircle" kernel. SIAM J. Sci. Comput. 41(5), C479–C504, 2019. See finufft.
- structure-factor: the original package of the same group, For-a-few-DPPs-more/structure-factor.
Used by blue-sampler.
License
MIT
Metadata
Release files for structure-factor-v2 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| structure_factor_v2-2.1.0.tar.gz | 21.4 kB | Without provenance | Details for structure_factor_v2-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| structure_factor_v2-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for structure_factor_v2-2.1.0-py3-none-any.whl |
Total release size: 46.9 kB
Release files / structure_factor_v2-2.1.0.tar.gz
| Download URL | structure_factor_v2-2.1.0.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d287946c668ad729ba0b3b183631658a6f53860098483f24bd848d2bfe01d582
|
|
BLAKE2b-256 checksum How to use checksums |
d85f18ec18a3244d8250cfd73f1c6293e0acd79ac463714e001f1a75d3aaaf38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / structure_factor_v2-2.1.0-py3-none-any.whl
| Download URL | structure_factor_v2-2.1.0-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d24fccbb39bf4d3c166a0ad76a416220194b6643bf371d23ca0c6059d9771c4
|
|
BLAKE2b-256 checksum How to use checksums |
1456b5af187dbcb76596f4c0b67d1fc14ed3b0fb898d7ac47349a72c5fb27ae2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for structure-factor-v2 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.