API reference
This section documents the functions intended for internal usage by the package.
Index
Effort.AbstractComponentEmulatorsEffort.AbstractPℓEmulatorsEffort.ComponentEmulatorEffort.PℓEmulatorEffort._Legendre_0Effort._Legendre_2Effort._Legendre_4Effort._P_obsEffort._Pk_reconEffort._PkμEffort._k_trueEffort._k_trueEffort._transformed_weightsEffort._μ_trueEffort._μ_trueEffort.apply_APEffort.apply_APEffort.apply_AP_checkEffort.get_componentEffort.interp_PℓsEffort.load_component_emulatorEffort.load_multipole_emulatorEffort.q_par_perpEffort.window_convolution
Neural Networks
Effort.AbstractComponentEmulators — Type
AbstractComponentEmulatorsAbstract type for component-level emulators that represent individual parts of the power spectrum calculation (e.g., P11, Ploop, Pct).
All concrete subtypes must implement the necessary fields to enable neural network evaluation, normalization, and postprocessing.
Effort.ComponentEmulator — Type
ComponentEmulator <: AbstractComponentEmulatorsA complete emulator for a single power spectrum component, combining neural network predictions with normalization and physics-based postprocessing.
Fields
TrainedEmulator::AbstractTrainedEmulators: The trained neural network (Lux or SimpleChains).kgrid::Array: Wavenumber grid on which the component is evaluated (in h/Mpc).InMinMax::Matrix{Float64}: Min-max normalization parameters for inputs (n_params × 2).OutMinMax::Array{Float64}: Min-max normalization parameters for outputs (n_k × 2).Postprocessing::Function: Function to apply physics transformations to raw NN output.
Details
The typical evaluation flow is:
- Normalize input parameters using
InMinMax. - Evaluate neural network to get normalized output.
- Denormalize output using
OutMinMax. - Apply postprocessing (e.g., multiply by AₛD² for P11 and Pct and by (AₛD²)² for Ploop).
Example Postprocessing
# For linear power spectrum component
postprocess_P11 = (params, output, D, emu) -> output .* D^2Effort.get_component — Function
get_component(input_params, D, comp_emu::AbstractComponentEmulators)Evaluate a component emulator to obtain power spectrum component values.
Arguments
input_params: Array of input parameters (e.g., cosmological parameters).D: Growth factor at the redshift of interest.comp_emu::AbstractComponentEmulators: The component emulator to evaluate.
Returns
A matrix of shape (n_k, n_samples) containing the evaluated power spectrum component values on the emulator's k-grid.
Details
This function performs the full evaluation pipeline:
- Copy input parameters to avoid mutation.
- Apply min-max normalization to inputs.
- Run neural network inference.
- Denormalize network output.
- Apply component-specific postprocessing (using
Dand emulator metadata). - Reshape to match k-grid dimensions.
The postprocessing step typically includes physics-based transformations such as scaling by powers of the growth factor.
Effort.AbstractPℓEmulators — Type
AbstractPℓEmulatorsAbstract type for complete power spectrum multipole emulators.
Concrete subtypes must combine multiple component emulators (P11, Ploop, Pct) with bias models to compute full power spectrum multipoles $P_\ell(k)$ for $\ell \in \{0, 2, 4\}$.
Effort.PℓEmulator — Type
PℓEmulator <: AbstractPℓEmulatorsComplete emulator for power spectrum multipoles in the Effective Field Theory of Large Scale Structure (EFTofLSS) framework.
Fields
P11::ComponentEmulator: Emulator for the linear theory power spectrum component.Ploop::ComponentEmulator: Emulator for the one-loop corrections.Pct::ComponentEmulator: Emulator for the counterterm contributions.StochModel::Function: Function to compute stochastic (shot noise) terms.BiasCombination::Function: Function mapping bias parameters to linear combination weights.JacobianBiasCombination::Function: Analytical Jacobian ofBiasCombinationw.r.t. bias parameters.
Details
The power spectrum multipole is computed as:
\[P_\ell(k) = \sum_i c_i(b_1, b_2, ...) P_i(k)\]
where:
- $P_i(k)$ are the component power spectra (P11, Ploop, Pct, stochastic terms)
- $c_i(b_1, b_2, ...)$ are coefficients from the bias expansion
The BiasCombination function encodes the EFT bias model, while JacobianBiasCombination provides analytical derivatives for efficient gradient-based inference.
Example Usage
# Load pre-trained emulator
emu = trained_emulators["PyBirdmnuw0wacdm"]["0"] # monopole
# Evaluate power spectrum
cosmology = [z, ln10As, ns, H0, ωb, ωcdm, mν, w0, wa]
bias = [b1, b2, b3, b4, b5, b6, b7, f, cϵ0, cϵ1, cϵ2]
D = 0.8 # growth factor
P0 = get_Pℓ(cosmology, D, bias, emu)See Also
get_Pℓ: Evaluate the power spectrum.get_Pℓ_jacobian: Evaluate power spectrum and its Jacobian.
Projection
Effort._Pkμ — Function
_Pkμ(k, μ, Int_Mono, Int_Quad, Int_Hexa)Reconstructs the anisotropic power spectrum $P(k, \mu)$ at a given wavenumber k and cosine of the angle to the line-of-sight μ, using its Legendre multipole moments.
Arguments
k: The wavenumber.μ: The cosine of the angle to the line-of-sight.Int_Mono: A function or interpolant that provides the monopole moment $I_0(k)$ at wavenumberk.Int_Quad: A function or interpolant that provides the quadrupole moment $I_2(k)$ at wavenumberk.Int_Hexa: A function or interpolant that provides the hexadecapole moment $I_4(k)$ at wavenumberk.
Returns
The value of the anisotropic power spectrum $P(k, \mu)$ at the given k and μ.
Details
The anisotropic power spectrum is reconstructed as a sum of its multipole moments multiplied by the corresponding Legendre polynomials evaluated at μ. The function uses the 0th, 2nd, and 4th order Legendre polynomials.
Formula
The formula used is:
\[P(k, \mu) = I_0(k) \mathcal{L}_0(\mu) + I_2(k) \mathcal{L}_2(\mu) + I_4(k) \mathcal{L}_4(\mu)\]
where $I_l(k)$ are the multipole moments and $\mathcal{L}_l(\mu)$ are the Legendre polynomials of order $l$.
See Also
_Legendre_0: Calculates the 0th order Legendre polynomial._Legendre_2: Calculates the 2nd order Legendre polynomial._Legendre_4: Calculates the 4th order Legendre polynomial.
Effort._k_true — Method
_k_true(k_o, μ_o, q_perp, F)Calculates the true (physical) wavenumber k from the observed wavenumber k_o and observed cosine of the angle to the line-of-sight μ_o.
This transformation accounts for anisotropic effects, likely redshift-space distortions (RSD) or anisotropic cosmological scaling, parameterized by q_perp and F.
Arguments
k_o: The observed wavenumber (scalar).μ_o: The observed cosine of the angle to the line-of-sight (scalar).q_perp: A parameter related to perpendicular anisotropic scaling.F: A parameter related to parallel anisotropic scaling (often the growth ratefdivided by the anisotropic scaling parameterq_parallel).
Returns
The calculated true wavenumber k (scalar).
Formula
The formula used is:
\[k = \frac{k_o}{q_\perp} \sqrt{1 + \mu_o^2 \left(\frac{1}{F^2} - 1\right)}\]
See Also
_k_true(k_o::Array, μ_o::Array, q_perp, F): Method for arrays of observed values._μ_true: Calculates the true cosine of the angle to the line-of-sight.
Effort._k_true — Method
_k_true(k_o::Array, μ_o::Array, q_perp, F)Calculates the true (physical) wavenumber k for arrays of observed wavenumbers k_o and observed cosines of the angle to the line-of-sight μ_o.
This method applies the transformation from observed to true wavenumber element-wise or for combinations of input arrays, accounting for anisotropic effects parameterized by q_perp and F.
Arguments
k_o: An array of observed wavenumbers.μ_o: An array of observed cosines of the angle to the line-of-sight.q_perp: A parameter related to perpendicular anisotropic scaling.F: A parameter related to parallel anisotropic scaling.
Returns
A vector containing the calculated true wavenumbers k for the given input arrays.
Details
The function calculates k for pairs or combinations of values from the input arrays k_o and μ_o using a formula derived from anisotropic scaling. The calculation involves broadcasting and array operations to handle the array inputs efficiently. The result is flattened into a vector.
Formula
The underlying transformation for each pair of k_o and μ_o is:
\[k = \frac{k_o}{q_\perp} \sqrt{1 + \mu_o^2 \left(\frac{1}{F^2} - 1\right)}\]
See Also
_k_true(k_o, μ_o, q_perp, F): Method for scalar observed values._μ_true: Calculates the true cosine of the angle to the line-of-sight.
Effort._μ_true — Method
_μ_true(μ_o, F)Calculates the true (physical) cosine of the angle to the line-of-sight μ from the observed cosine of the angle to the line-of-sight μ_o.
This transformation accounts for anisotropic effects, likely redshift-space distortions (RSD) or anisotropic cosmological scaling, parameterized by F.
Arguments
μ_o: The observed cosine of the angle to the line-of-sight (scalar).F: A parameter related to parallel anisotropic scaling (often the growth ratefdivided by the anisotropic scaling parameterq_parallel).
Returns
The calculated true cosine of the angle to the line-of-sight μ (scalar).
Formula
The formula used is:
\[\mu = \frac{\mu_o}{F \sqrt{1 + \mu_o^2 \left(\frac{1}{F^2} - 1\right)}}\]
See Also
_μ_true(μ_o::Array, F): Method for an array of observed values._k_true: Calculates the true wavenumber.
Effort._μ_true — Method
_μ_true(μ_o::Array, F)Calculates the true (physical) cosine of the angle to the line-of-sight μ for an array of observed cosines of the angle to the line-of-sight μ_o.
This method applies the transformation from observed to true angle cosine element-wise, accounting for anisotropic effects parameterized by F.
Arguments
μ_o: An array of observed cosines of the angle to the line-of-sight.F: A parameter related to parallel anisotropic scaling.
Returns
An array containing the calculated true cosines of the angle to the line-of-sight μ.
Details
The function calculates μ for each value in the input array μ_o using a formula derived from anisotropic scaling. Broadcasting (@.) is used to apply the calculation element-wise.
Formula
The underlying transformation for each μ_o is:
\[\mu = \frac{\mu_o}{F \sqrt{1 + \mu_o^2 \left(\frac{1}{F^2} - 1\right)}}\]
See Also
_μ_true(μ_o, F): Method for a scalar observed value._k_true: Calculates the true wavenumber.
Effort._P_obs — Function
_P_obs(k_o, μ_o, q_par, q_perp, Int_Mono, Int_Quad, Int_Hexa)Calculates the observed power spectrum $P_{\text{obs}}(k_o, \mu_o)$ at a given observed wavenumber k_o and observed cosine of the angle to the line-of-sight μ_o.
This function transforms the observed coordinates to true (physical) coordinates, calculates the true power spectrum using provided interpolants for the multipole moments, and applies the appropriate scaling factor due to anisotropic effects.
Arguments
k_o: The observed wavenumber.μ_o: The observed cosine of the angle to the line-of-sight.q_par: A parameter related to parallel anisotropic scaling.q_perp: A parameter related to perpendicular anisotropic scaling.Int_Mono: An interpolation function for the monopole moment $I_0(k)$ in true k.Int_Quad: An interpolation function for the quadrupole moment $I_2(k)$ in true k.Int_Hexa: An interpolation function for the hexadecapole moment $I_4(k)$ in true k.
Returns
The value of the observed power spectrum $P_{\text{obs}}(k_o, \mu_o)$.
Details
The observed coordinates $(k_o, \mu_o)$ are transformed to true coordinates $(k_t, \mu_t)$ using the _k_true and _μ_true functions, with $F = q_\parallel / q_\perp$. The true power spectrum $P(k_t, \mu_t)$ is then reconstructed using _Pkμ and the provided multipole interpolants. Finally, the result is scaled by $1 / (q_\parallel q_\perp^2)$.
Formula
The formula used is:
\[P_{\text{obs}}(k_o, \mu_o) = \frac{1}{q_\parallel q_\perp^2} P(k_t, \mu_t)\]
where
\[k_t = \text{_k_true}(k_o, \mu_o, q_\perp, F)\]
\[\mu_t = \text{_μ_true}(\mu_o, F)\]
and
\[F = q_\parallel / q_\perp\]
See Also
_k_true: Transforms observed wavenumber to true wavenumber._μ_true: Transforms observed angle cosine to true angle cosine._Pkμ: Reconstructs the true power spectrum from multipole moments.interp_Pℓs: Creates the multipole interpolants.
Effort.interp_Pℓs — Function
interp_Pℓs(Mono_array, Quad_array, Hexa_array, k_grid)Creates interpolation functions for the monopole, quadrupole, and hexadecapole moments of the power spectrum.
These interpolants can then be used to efficiently evaluate the multipole moments at arbitrary wavenumbers k.
Arguments
Mono_array: An array containing the values of the monopole moment $I_0(k)$.Quad_array: An array containing the values of the quadrupole moment $I_2(k)$.Hexa_array: An array containing the values of the hexadecapole moment $I_4(k)$.k_grid: An array containing the corresponding wavenumberkvalues for the multipole arrays.
Returns
A tuple containing three interpolation functions: (Int_Mono, Int_Quad, Int_Hexa).
Details
The function uses AkimaInterpolation from the Interpolations.jl package to create the interpolants. Extrapolation is set to ExtrapolationType.Extension, which means the interpolant will use the nearest data points to extrapolate outside the provided k_grid range. Note that extrapolation can sometimes introduce errors.
See Also
_Pkμ: Uses the interpolation functions to reconstruct the anisotropic power spectrum.
Effort.q_par_perp — Function
q_par_perp(z, cosmo_mcmc::AbstractCosmology, cosmo_ref::AbstractCosmology)Calculates the parallel (q_par) and perpendicular (q_perp) Alcock-Paczynski (AP) parameters at a given redshift z, comparing a varying cosmology to a reference cosmology.
The AP parameters quantify the distortion of observed clustering due to assuming a different cosmology than the true one when converting redshifts and angles to distances.
Arguments
z: The redshift at which to calculate the AP parameters.cosmo_mcmc: AnAbstractCosmologystruct representing the varying cosmology (e.g., from an MCMC chain).cosmo_ref: AnAbstractCosmologystruct representing the reference cosmology used for measurements.
Returns
A tuple (q_par, q_perp) containing the calculated parallel and perpendicular AP parameters at redshift z.
Details
The parallel AP parameter q_par is the ratio of the Hubble parameter in the reference cosmology to that in the varying cosmology. The perpendicular AP parameter q_perp is the ratio of the conformal angular diameter distance in the varying cosmology to that in the reference cosmology.
Formula
The formulas for the Alcock-Paczynski parameters are:
\[q_\parallel(z) = \frac{E_{\text{ref}}(z)}{E_{\text{mcmc}}(z)}\]
\[q_\perp(z) = \frac{\tilde{d}_{A,\text{mcmc}}(z)}{\tilde{d}_{A,\text{ref}}(z)}\]
where $E(z)$ is the normalized Hubble parameter and $\tilde{d}_A(z)$ is the conformal angular diameter distance.
Effort.apply_AP_check — Method
apply_AP_check(k_input::AbstractVector, k_output::AbstractVector, Mono_array::AbstractVector, Quad_array::AbstractVector, Hexa_array::AbstractVector, q_par, q_perp)Calculates the observed power spectrum multipole moments (monopole, quadrupole, hexadecapole) on a given observed wavenumber grid k_output, from vectors of true multipole moments provided on an input wavenumber grid k_input, using numerical integration.
This is a check version, intended for verifying results from faster methods. It is significantly slower due to the use of numerical integration over the angle μ.
Arguments
k_input: A vector of wavenumber values on which the input true multipole moments (Mono_array,Quad_array,Hexa_array) are defined.k_output: A vector of observed wavenumber values at which to calculate the output observed multipoles.Mono_array: A vector containing the values of the true monopole moment $I_0(k)$ on thek_inputgrid.Quad_array: A vector containing the values of the true quadrupole moment $I_2(k)$ on thek_inputgrid.Hexa_array: A vector containing the values of the true hexadecapole moment $I_4(k)$ on thek_inputgrid.q_par: A parameter related to parallel anisotropic scaling.q_perp: A parameter related to perpendicular anisotropic scaling.method: Interpolation method to use (Akima or Cubic). Default:Cubic.
Returns
A tuple (P0_obs, P2_obs, P4_obs), where each element is a vector containing the calculated observed monopole, quadrupole, and hexadecapole moments respectively, evaluated at the wavenumbers in k_output.
Details
This method first creates interpolation functions for the true multipole moments using interp_Pℓs based on the k_input grid. It then calls the core apply_AP_check(k_grid, int_Mono, int_Quad, int_Hexa, q_par, q_perp) method, passing k_output as the grid at which to calculate the observed multipoles.
This function is a slower check implementation and should not be used in performance-critical code.
Formula
The observed multipole moments are calculated using the formula:
\[P_\ell(k_o) = (2\ell + 1) \int_{0}^1 P_{\text{obs}}(k_o, \mu_o) \mathcal{L}_\ell(\mu_o) d\mu_o\]
for $\ell \in \{0, 2, 4\}$. The observed power spectrum $P_{\text{obs}}(k_o, \mu_o)$ is calculated using _P_obs(k_o, μ_o, q_par, q_perp, int_Mono, int_Quad, int_Hexa).
See Also
apply_AP_check(k_grid, int_Mono, int_Quad, int_Hexa, q_par, q_perp): The core method performing the integration.interp_Pℓs: Creates the interpolation functions for the true multipoles._P_obs: Calculates the observed power spectrum.
Effort.apply_AP — Method
apply_AP(k_input::AbstractVector, k_output::AbstractVector, mono::AbstractVector, quad::AbstractVector, hexa::AbstractVector, q_par, q_perp; n_GL_points=8, method::InterpolationMethod=Cubic())Calculates the observed power spectrum multipole moments (monopole, quadrupole, hexadecapole) on a given observed wavenumber grid k_output, using arrays of true multipole moments provided on an input wavenumber grid k_input, and employing Gauss-Lobatto quadrature.
This is the standard, faster implementation for applying the Alcock-Paczynski (AP) effect to the power spectrum multipoles.
Arguments
k_input: A vector of wavenumber values on which the input true multipole moments (mono,quad,hexa) are defined.k_output: A vector of observed wavenumber values at which to calculate the output observed multipoles.mono: A vector containing the values of the true monopole moment $I_0(k)$ on thek_inputgrid.quad: A vector containing the values of the true quadrupole moment $I_2(k)$ on thek_inputgrid.hexa: A vector containing the values of the true hexadecapole moment $I_4(k)$ on thek_inputgrid.q_par: A parameter related to parallel anisotropic scaling.q_perp: A parameter related to perpendicular anisotropic scaling.
Keyword Arguments
n_GL_points: The number of Gauss-Lobatto points to use for the integration overμ. The actual number of nodes used corresponds to2 * n_GL_points. Defaults to 8.method: Interpolation method to use (Akima or Cubic). Default:Cubic.
Returns
A tuple (P0_obs, P2_obs, P4_obs), where each element is a vector containing the calculated observed monopole, quadrupole, and hexadecapole moments respectively, evaluated at the observed wavenumbers in k_output.
Effort.apply_AP — Method
apply_AP(k_input::AbstractVector, k_output::AbstractVector, mono::AbstractMatrix, quad::AbstractMatrix, hexa::AbstractMatrix, q_par, q_perp; n_GL_points=8, method::InterpolationMethod=Cubic())Batch version of apply_AP for processing multiple columns simultaneously using optimized matrix interpolation.
Arguments
k_input::AbstractVector: Input wavenumber grid.k_output::AbstractVector: Output wavenumber grid.mono::AbstractMatrix: Monopole moments with shape(n_k, n_cols).quad::AbstractMatrix: Quadrupole moments with shape(n_k, n_cols).hexa::AbstractMatrix: Hexadecapole moments with shape(n_k, n_cols).q_par: Parallel AP parameter.q_perp: Perpendicular AP parameter.
Keyword Arguments
n_GL_points::Int: Number of Gauss-Lobatto points. Default: 8.method: Interpolation method to use (Akima or Cubic). Default:Cubic.
Returns
A tuple (mono_AP, quad_AP, hexa_AP) where each is a matrix of shape (n_k_output, n_cols) containing the AP-corrected multipoles for all input columns.
Effort._Pk_recon — Function
_Pk_recon(mono::Matrix, quad::Matrix, hexa::Matrix, l0, l2, l4)Reconstructs the anisotropic power spectrum $P(k, \mu)$ on a grid of wavenumbers k and cosines of the angle to the line-of-sight μ, using matrices of its Legendre multipole moments and vectors of Legendre polynomial values.
This function is designed to efficiently reconstruct the 2D power spectrum for multiple k and μ values simultaneously, assuming the multipole moments are provided as matrices (e.g., N_k x 1) and Legendre polynomials as vectors (e.g., N_μ).
Arguments
mono: A matrix containing the monopole moment $I_0(k)$ values (expected dimensionsN_k x 1).quad: A matrix containing the quadrupole moment $I_2(k)$ values (expected dimensionsN_k x 1).hexa: A matrix containing the hexadecapole moment $I_4(k)$ values (expected dimensionsN_k x 1).l0: A vector containing the 0th order Legendre polynomial $\mathcal{L}_0(\mu)$ values evaluated at the desiredμvalues (expected dimensionsN_μ).l2: A vector containing the 2nd order Legendre polynomial $\mathcal{L}_2(\mu)$ values evaluated at the desiredμvalues (expected dimensionsN_μ).l4: A vector containing the 4th order Legendre polynomial $\mathcal{L}_4(\mu)$ values evaluated at the desiredμvalues (expected dimensionsN_μ).
Returns
A matrix representing the anisotropic power spectrum $P(k, \mu)$ on the N_k x N_μ grid.
Details
The function reconstructs the anisotropic power spectrum using the formula that sums the multipole moments multiplied by the corresponding Legendre polynomials. The matrix and vector operations are broadcast to calculate the result for all combinations of input k (from the rows of the moment matrices) and μ (from the elements of the Legendre polynomial vectors).
Formula
The formula used for each element $(i, j)$ of the output matrix (corresponding to the $i$-th wavenumber and $j$-th angle cosine) is:
\[P(k_i, \mu_j) = I_0(k_i) \mathcal{L}_0(\mu_j) + I_2(k_i) \mathcal{L}_2(\mu_j) + I_4(k_i) \mathcal{L}_4(\mu_j)\]
See Also
_Pkμ: Reconstructs $P(k, \mu)$ for singlekandμ._Legendre_0,_Legendre_2,_Legendre_4: Calculate the Legendre polynomials.
Effort.window_convolution — Function
window_convolution(W::Array{T, 4}, v::Matrix) where {T}Applies a 4-dimensional window function or kernel W to a 2-dimensional input matrix v.
This operation performs a transformation or generalized convolution, summing over the j and l indices of the inputs to produce a 2D result indexed by i and k. This is commonly used in analyses where a 4D kernel relates input data in two dimensions to output data in another two dimensions.
Arguments
W: A 4-dimensional array representing the window function or kernel.v: A 2-dimensional matrix representing the input data.
Returns
A 2-dimensional matrix representing the result of the convolution or transformation.
Details
The function implements the summation using the @tullio macro, which provides an efficient way to express tensor contractions and generalized convolutions. The operation can be thought of as applying a 4D kernel to a 2D input, resulting in a 2D output.
Formula
The operation is defined as:
\[C_{ik} = \sum_{j,l} W_{ijkl} v_{jl}\]
See Also
window_convolution(W::AbstractMatrix, v::AbstractVector): Method for a matrix kernel and vector input.
References
- The methodology for this type of window measurement is discussed in: arXiv:1810.05051
window_convolution(W::AbstractMatrix, v::AbstractVector)Performs matrix-vector multiplication, where the matrix W acts as a linear transformation or window applied to the vector input v.
Arguments
W: An abstract matrix representing the linear transformation or window.v: An abstract vector representing the input data.
Returns
An abstract vector representing the result of the matrix-vector multiplication.
Details
This method is a direct implementation of standard matrix-vector multiplication. It applies the linear transformation defined by matrix W to the vector v.
Formula
The operation is defined as:
\[\mathbf{c} = \mathbf{W} \mathbf{v}\]
or element-wise:
\[c_i = \sum_j W_{ij} v_j\]
See Also
window_convolution(W::Array{T, 4}, v::Matrix) where {T}: Method for a 4D kernel and matrix input.
References
- The methodology for this type of window measurement is discussed in: arXiv:1810.05051
Utils
Effort._transformed_weights — Function
_transformed_weights(quadrature_rule, order, a, b)Transforms the points and weights of a standard quadrature rule from the interval [-1, 1] to a specified interval [a, b].
This is a utility function used to adapt standard quadrature rules (like Gauss-Legendre) for numerical integration over arbitrary intervals [a, b].
Arguments
quadrature_rule: A function that takes anorderand returns a tuple(points, weights)for the standard interval[-1, 1].order: The order of the quadrature rule (number of points).a: The lower bound of the target interval.b: The upper bound of the target interval.
Returns
A tuple (transformed_points, transformed_weights) for the interval [a, b].
Details
The transformation is applied to the standard points $x_i^{\text{std}}$ and weights $w_i^{\text{std}}$ obtained from the quadrature_rule:
- Transformed points: $x_i = \frac{b - a}{2} x_i^{\text{std}} + \frac{b + a}{2}$
- Transformed weights: $w_i = \frac{b - a}{2} w_i^{\text{std}}$
Formula
The transformation formulas are: Points: $x_i = \frac{b - a}{2} x_i^{\text{std}} + \frac{b + a}{2}$ Weights: $w_i = \frac{b - a}{2} w_i^{\text{std}}$
Effort._Legendre_0 — Function
_Legendre_0(x)Calculates the 0th order Legendre polynomial, $\mathcal{L}_0(x)$.
Arguments
x: The input value (typically the cosine of an angle, -1 ≤ x ≤ 1).
Returns
The value of the 0th order Legendre polynomial evaluated at x.
Formula
The formula for the 0th order Legendre polynomial is:
\[\mathcal{L}_0(x) = 1\]
See Also
_Legendre_2: Calculates the 2nd order Legendre polynomial._Legendre_4: Calculates the 4th order Legendre polynomial._Pkμ: A function that uses Legendre polynomials.
Effort._Legendre_2 — Function
_Legendre_2(x)Calculates the 2nd order Legendre polynomial, $\mathcal{L}_2(x)$.
Arguments
x: The input value (typically the cosine of an angle, -1 ≤ x ≤ 1).
Returns
The value of the 2nd order Legendre polynomial evaluated at x.
Formula
The formula for the 2nd order Legendre polynomial is:
\[\mathcal{L}_2(x) = \frac{1}{2} (3x^2 - 1)\]
See Also
_Legendre_0: Calculates the 0th order Legendre polynomial._Legendre_4: Calculates the 4th order Legendre polynomial._Pkμ: A function that uses Legendre polynomials.
Effort._Legendre_4 — Function
_Legendre_4(x)Calculates the 4th order Legendre polynomial, $\mathcal{L}_4(x)$.
Arguments
x: The input value (typically the cosine of an angle, -1 ≤ x ≤ 1).
Returns
The value of the 4th order Legendre polynomial evaluated at x.
Formula
The formula for the 4th order Legendre polynomial is:
\[\mathcal{L}_4(x) = \frac{1}{8} (35x^4 - 30x^2 + 3)\]
See Also
_Legendre_0: Calculates the 0th order Legendre polynomial._Legendre_2: Calculates the 2nd order Legendre polynomial._Pkμ: A function that uses Legendre polynomials.
Effort.load_component_emulator — Function
load_component_emulator(path::String; emu=LuxEmulator, k_file="k.npy", weights_file="weights.npy", inminmax_file="inminmax.npy", outminmax_file="outminmax.npy", nn_setup_file="nn_setup.json", postprocessing_file="postprocessing_file.jl")Load a trained component emulator from disk.
Arguments
path::String: Directory path containing the emulator files.
Keyword Arguments
emu: Emulator type to initialize (LuxEmulatororSimpleChainsEmulator). Default:LuxEmulator.k_file::String: Filename for the wavenumber grid. Default:"k.npy".weights_file::String: Filename for neural network weights. Default:"weights.npy".inminmax_file::String: Filename for input normalization parameters. Default:"inminmax.npy".outminmax_file::String: Filename for output normalization parameters. Default:"outminmax.npy".nn_setup_file::String: Filename for network architecture configuration. Default:"nn_setup.json".postprocessing_file::String: Filename for postprocessing function. Default:"postprocessing_file.jl".
Returns
A ComponentEmulator instance ready for evaluation.
Details
This function loads all necessary files to reconstruct a trained component emulator:
- Neural network architecture from JSON configuration.
- Trained weights from NumPy binary format.
- Normalization parameters for inputs and outputs.
- Wavenumber grid.
- Postprocessing function dynamically loaded from Julia file.
The postprocessing function is evaluated in an isolated scope to prevent namespace pollution.
Example
P11_emu = load_component_emulator("/path/to/emulator/11/")File Structure
The expected directory structure is:
path/
├── k.npy # Wavenumber grid
├── weights.npy # Neural network weights
├── inminmax.npy # Input normalization (n_params × 2)
├── outminmax.npy # Output normalization (n_k × 2)
├── nn_setup.json # Network architecture
└── postprocessing_file.jl # Postprocessing functionEffort.load_multipole_emulator — Function
load_multipole_emulator(path; emu=LuxEmulator, k_file="k.npy", weights_file="weights.npy", inminmax_file="inminmax.npy", outminmax_file="outminmax.npy", nn_setup_file="nn_setup.json", postprocessing_file="postprocessing.jl", stochmodel_file="stochmodel.jl", biascombination_file="biascombination.jl", jacbiascombination_file="jacbiascombination.jl")Load a complete power spectrum multipole emulator from disk.
Arguments
path: Directory path containing the multipole emulator structure.
Keyword Arguments
emu: Emulator type to initialize (LuxEmulatororSimpleChainsEmulator). Default:LuxEmulator.k_file::String: Filename for the wavenumber grid. Default:"k.npy".weights_file::String: Filename for neural network weights. Default:"weights.npy".inminmax_file::String: Filename for input normalization parameters. Default:"inminmax.npy".outminmax_file::String: Filename for output normalization parameters. Default:"outminmax.npy".nn_setup_file::String: Filename for network architecture configuration. Default:"nn_setup.json".postprocessing_file::String: Filename for postprocessing function. Default:"postprocessing.jl".stochmodel_file::String: Filename for stochastic model function. Default:"stochmodel.jl".biascombination_file::String: Filename for bias combination function. Default:"biascombination.jl".jacbiascombination_file::String: Filename for bias Jacobian function. Default:"jacbiascombination.jl".
Returns
A PℓEmulator instance containing all three components (P11, Ploop, Pct) and bias models.
Details
This function loads a complete multipole emulator by:
- Loading three component emulators (P11, Ploop, Pct) from subdirectories.
- Loading the stochastic model function (shot noise terms).
- Loading the bias combination function (maps bias parameters to weights).
- Loading the analytical Jacobian of the bias combination.
All functions are evaluated in isolated scopes to prevent namespace conflicts between different emulator components.
Example
# Load monopole emulator
monopole_emu = load_multipole_emulator("/path/to/artifact/0/")
# Evaluate
cosmology = [z, ln10As, ns, H0, ωb, ωcdm, mν, w0, wa]
bias = [b1, b2, b3, b4, b5, b6, b7, f, cϵ0, cϵ1, cϵ2]
D = 0.8
P0 = get_Pℓ(cosmology, D, bias, monopole_emu)File Structure
The expected directory structure is:
path/
├── 11/ # P11 component
│ ├── k.npy
│ ├── weights.npy
│ ├── inminmax.npy
│ ├── outminmax.npy
│ ├── nn_setup.json
│ └── postprocessing.jl
├── loop/ # Ploop component
│ └── ... (same structure)
├── ct/ # Pct component
│ └── ... (same structure)
├── stochmodel.jl # Stochastic model function
├── biascombination.jl # Bias combination function
└── jacbiascombination.jl # Bias Jacobian functionSee Also
load_component_emulator: Load individual component emulators.get_Pℓ: Evaluate the loaded emulator.