scatter is a small Python package for converting between a radial
distribution function g(r) and a static structure factor S(k).
The API is intentionally linear:
- provide two arrays,
- optionally preprocess the signal,
- run the transform.
No hidden state is kept between steps.
git clone https://github.com/vojtechkostal/scatter
cd ./scatter
python -m pip install -e .import numpy as np
import scatter
r, g = np.loadtxt("data/Ar-gr.dat", unpack=True)
# Preprocessing returns the centered signal h(r) = g(r) - 1.
r, h = scatter.preprocess(
r,
g,
smooth=1e-4,
pad=10_000,
taper_start=9.0,
taper_width=1.0,
)
k, s = scatter.structure_factor(
r,
h,
density=1e-3,
k_max=10.0,
points=1000,
centered=True,
)import numpy as np
import scatter
k, s_minus_1 = np.loadtxt("data/KCl-Sk.dat", usecols=(0, 1), unpack=True)
k, delta_s = scatter.preprocess(
k,
s_minus_1,
reference=None,
smooth=1.5e-4,
pad=1000,
taper_start=9.0,
taper_width=1.0,
)
r, g = scatter.radial_distribution(
k,
delta_s,
density=1.0,
r_max=10.0,
points=1000,
centered=True,
)If your input is already clean, call the transforms directly:
k, s = scatter.structure_factor(r, g, density=1.0)
r, g = scatter.radial_distribution(k, s, density=1.0)Use centered=True only when the values are already g(r) - 1 or
S(k) - 1.
Choose density in units consistent with your r and k grids.
scatter uses direct sine integrals with explicit normalization:
where