Numerics¶
Pure numerical routines — no cosmology knowledge; they operate on callables and arrays. See Architecture.
Interpolation¶
liulu.numerics.interpolation.loglog_interp ¶
Power-law interpolation: linear in (log x, log y). Near-exact for the steeply-falling, ~power-law xi(r) of the streaming weight, where ordinary log-linear interpolation overestimates the convex curve between bins and biases the model monopole high.
Robust to non-positive y: points with y <= 0 are excluded from the log-log
fit, and queries beyond the positive support fall back to the configured
fill (fill_value follows the same scalar / (below, above) / "edge"
convention as :func:log_linear_interp). If fewer than two positive points
exist it delegates to :func:log_linear_interp.
Source code in liulu/numerics/interpolation.py
liulu.numerics.interpolation.log_linear_interp ¶
Log-linear interpolation: linear in log(x), linear in y.
Handles negative y values (e.g. pairwise velocities) by interpolating y directly (not log(y)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Abscissae (must be positive, ascending). |
required |
y
|
ndarray
|
Ordinates. |
required |
fill_value
|
float or tuple
|
Out-of-range policy; see the module docstring. Defaults to |
0.0
|
name
|
str
|
Label used in the out-of-range warning. |
'table'
|
warn
|
bool
|
Whether to warn on out-of-range queries. |
True
|
Returns:
| Type | Description |
|---|---|
callable
|
Interpolator f(x_new) -> y_new. |
Source code in liulu/numerics/interpolation.py
liulu.numerics.interpolation.log_spline_interp ¶
Cubic spline interpolation in log(x) space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Abscissae (must be positive, ascending). |
required |
y
|
ndarray
|
Ordinates. |
required |
fill_value
|
float or tuple
|
Out-of-range policy; see the module docstring. Defaults to |
0.0
|
name
|
str
|
Label used in the out-of-range warning. |
'table'
|
warn
|
bool
|
Whether to warn on out-of-range queries. |
True
|
Returns:
| Type | Description |
|---|---|
callable
|
Interpolator f(x_new) -> y_new. |
Source code in liulu/numerics/interpolation.py
Hankel transforms¶
liulu.numerics.hankel.pk_to_xi ¶
Transform P(k) to xi(r) via direct quadrature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
ndarray
|
Wavenumbers, h/Mpc. |
required |
pk
|
ndarray
|
Power spectrum, (Mpc/h)^3. |
required |
r
|
array_like
|
Separations at which to evaluate xi, Mpc/h. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Correlation function xi(r). |
Source code in liulu/numerics/hankel.py
liulu.numerics.hankel.xi_to_pk ¶
Transform xi(r) to P(k) via direct quadrature (inverse Hankel).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
ndarray
|
Separations, Mpc/h. |
required |
xi
|
ndarray
|
Correlation function. |
required |
k
|
array_like
|
Wavenumbers at which to evaluate P(k), h/Mpc. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Power spectrum P(k), (Mpc/h)^3. |