API Reference¶
Core Module¶
jaxcapse.jaxcapse
¶
IdentityInterpolation
¶
Return emulator outputs unchanged on their training grid.
MLP
¶
MLP(emulator: FlaxEmulator, in_MinMax: ndarray, out_MinMax: ndarray, postprocessing: Callable, emulator_description: Dict[str, Any], training_ell_grid: ndarray, interpolation: str = 'auto', max_spline_knots: int = 2048, endpoint_tolerance: float = 0.1, InterpolationMethod: Optional[Callable] = None)
CAPSE MLP emulator using jaxace infrastructure.
This class wraps a jaxace FlaxEmulator with CAPSE-specific functionality for CMB power spectrum computation.
Initialize MLP with jaxace emulator and CAPSE-specific components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emulator
|
FlaxEmulator
|
jaxace FlaxEmulator instance |
required |
in_MinMax
|
ndarray
|
Input normalization parameters |
required |
out_MinMax
|
ndarray
|
Output normalization parameters |
required |
postprocessing
|
Callable
|
Postprocessing function (must be JAX-compatible) |
required |
emulator_description
|
Dict[str, Any]
|
Emulator metadata |
required |
training_ell_grid
|
ndarray
|
Multipoles used while training the emulator |
required |
interpolation
|
str
|
Automatic, disabled, or forced cubic interpolation |
'auto'
|
max_spline_knots
|
int
|
Largest source grid automatically interpolated |
2048
|
endpoint_tolerance
|
float
|
Distance used to snap source bounds to integers |
0.1
|
InterpolationMethod
|
Optional[Callable]
|
Optional preconstructed interpolation method |
None
|
get_Cl
¶
get_Cl_batch
¶
Compute CMB power spectrum Cl values for a batch of inputs using vectorization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_batch
|
ndarray
|
Array of cosmological parameters, shape (n_samples, n_params) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of processed Cl values, shape (n_samples, n_cls) |
get_ell_grid
¶
Return the multipole grid corresponding to get_Cl output.
get_training_ell_grid
¶
Return the original emulator training multipoles.
SplinePlan
¶
Interpolate fixed training multipoles onto a dense integer grid.
load_emulator
¶
load_emulator(folder_path: str, interpolation: str = 'auto', max_spline_knots: int = 2048, endpoint_tolerance: float = 0.1) -> MLP
Load a CAPSE emulator using jaxace infrastructure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
str
|
Path to the emulator folder containing: - nn_setup.json: Neural network specification - weights.npy: Trained weights - inminmax.npy: Input normalization parameters - outminmax.npy: Output normalization parameters - l.npy: Multipoles used during training - postprocessing.py: Postprocessing function |
required |
interpolation
|
str
|
|
'auto'
|
max_spline_knots
|
int
|
Maximum source-grid size selected for automatic cubic interpolation. Defaults to 2048. |
2048
|
endpoint_tolerance
|
float
|
Maximum distance used to snap source bounds to an integer. Defaults to 0.1; bounds farther away are moved inward. |
0.1
|
Returns:
| Type | Description |
|---|---|
MLP
|
MLP instance ready for inference |
load_preprocessing
¶
prepare_interpolation_method
¶
prepare_interpolation_method(training_ell_grid, interpolation='auto', max_spline_knots=2048, endpoint_tolerance=0.1)
Choose identity or cubic interpolation for an emulator training grid.