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
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
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
Extrapolation¶
liulu.numerics.extrapolation.extend_table ¶
Extend (r, y) onto [r_lo, r_hi].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
array_like
|
Tabulated abscissae (positive, ascending) and ordinates. |
required |
y
|
array_like
|
Tabulated abscissae (positive, ascending) and ordinates. |
required |
r_lo
|
float
|
Target lower/upper bounds. Padding is added only where it widens |
required |
r_hi
|
float
|
Target lower/upper bounds. Padding is added only where it widens |
required |
low
|
edge
|
Fill below |
"edge"
|
high
|
(edge, zero, power, rise)
|
Tail above
|
"edge"
|
n_pad
|
int
|
Number of padding points added per side. |
24
|
Returns:
| Type | Description |
|---|---|
(ndarray, ndarray)
|
Extended |
Source code in liulu/numerics/extrapolation.py
Binning¶
liulu.numerics.binning.pair_weighted_centres ¶
Effective (count-weighted) abscissa of each bin of a pair-count estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
(array_like, shape(n_bins + 1))
|
Bin edges (positive, ascending). |
required |
f
|
callable
|
The binned function itself, |
required |
n_sub
|
int
|
Gauss-Legendre nodes per bin. |
64
|
Returns:
| Type | Description |
|---|---|
(ndarray, shape(n_bins))
|
|
Source code in liulu/numerics/binning.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. |