dsf.delta_sigma_forecast_builder module¶
Forecast-ready Delta Sigma inputs.
This module provides the high-level builder used to prepare Delta Sigma forecast inputs for Fisher or DALI analyses. It connects three pieces of the forecast:
tomographic lens and source samples,
the stacked Delta Sigma data vector,
the covariance matrix matched to the selected lens-source bin pairs.
The builder is intentionally model-agnostic. It assumes that the data vector is
computed with DeltaSigmaCalculator, but it does not assume a fixed physical
parameterization. Users provide a function that maps a parameter vector into the
cosmology and profile parameters used by the Delta Sigma calculation.
This makes the class suitable for simple amplitude-only forecasts, cosmology forecasts, HOD or SHMR parameter forecasts, and later Fisher/DALI comparisons.
- class dsf.delta_sigma_forecast_builder.DeltaSigmaForecastBuilder(*, cosmo, pk2d_func, theta0, r, rp_bin_edges, area_deg2, sigma_e=0.26, pk2d_kwargs=None, theta_mapper=None, parameter_names=None, tomography_kwargs=None, covariance_kwargs=None, trim_edge_points=0, verbose=True)[source]¶
Bases:
objectPrepare Delta Sigma data vectors and covariance inputs for forecasts.
This class is the user-facing forecast layer for Delta Sigma analyses. It builds the tomographic samples, selects valid lens-source bin pairs, constructs the matching covariance, and exposes a model function that can be passed directly to forecast tools.
The current forecast data vector contains only the galaxy-matter Delta Sigma signal, so this builder currently supports only the matching
gmcovariance block. The covariance layer also contains helpers forggand joint covariance blocks, which are intended for future forecast builders once the correspondingggor joint data vectors are added.- Parameters:
cosmo (ccl.Cosmology)
pk2d_func (Callable[..., dict[str, ccl.Pk2D]])
theta0 (Sequence[float])
r (ArrayLike)
rp_bin_edges (ArrayLike)
area_deg2 (float)
sigma_e (ScalarOrPerBin)
pk2d_kwargs (Mapping[str, Any] | None)
theta_mapper (ThetaMapper | None)
parameter_names (Sequence[str] | None)
tomography_kwargs (Mapping[str, Any] | None)
covariance_kwargs (Mapping[str, Any] | None)
trim_edge_points (int)
verbose (bool)
- context()[source]¶
Return the shared forecast context.
- Returns:
Dictionary containing the tomography products, covariance builder, calculator, radius grids, and fiducial cosmology.
- Return type:
dict[str, Any]
Notes
The returned dictionary is a shallow copy of the cached context so that model calls can safely use it without directly exposing the cached context object.
- dali()[source]¶
Compute the DALI tensors using DerivKit defaults.
- Return type:
dict[str, NDArray[float64]]
- forecast(covariance=None)[source]¶
Return cached forecast products, preparing them if needed.
- Parameters:
covariance (NDArray[float64] | None)
- Return type:
dict[str, Any]
- forecast_inputs()[source]¶
Return the model function, fiducial parameters, and covariance.
- Returns:
Tuple containing the model callable, fiducial parameter vector, and covariance matrix.
- Return type:
tuple[Callable[[NDArray[float64] | list[float] | tuple[float, …]], NDArray[float64]], NDArray[float64], NDArray[float64]]
Notes
This is the minimal interface needed by many Fisher-style forecast tools. It uses cached forecast products when available, so repeated calls do not rebuild tomography or covariance.
- forecastkit()[source]¶
Return a DerivKit ForecastKit initialized with the forecast inputs.
- Return type:
ForecastKit
- model(theta, *, context=None)[source]¶
Return the stacked Delta Sigma data vector for one parameter vector.
- Parameters:
theta (NDArray[float64] | list[float] | tuple[float, ...]) – Parameter vector at which the Delta Sigma model is evaluated.
context (Mapping[str, Any] | None) – Optional forecast context. If omitted, the cached forecast context is used.
- Returns:
One-dimensional stacked data vector containing the Delta Sigma blocks for all selected lens-source bin pairs.
- Return type:
NDArray[float64]
Notes
The optional
theta_mappercontrols howthetachanges the physical model. For example, it can update the cosmology, HOD parameters, SHMR parameters, or any keyword arguments accepted by the suppliedpk2d_func.
- prepare(covariance=None)[source]¶
Build and cache all forecast products.
- Parameters:
covariance (NDArray[float64] | None) – Optional precomputed covariance matrix. If provided, the builder reuses this matrix instead of recomputing the covariance block. Tomography, context, and the fiducial data vector are still rebuilt so the model function remains matched to the selected lens-source bin pairs.
- Returns:
Dictionary containing the model callable, fiducial parameters, covariance matrix, fiducial data vector, selected bin pairs, tomography products, covariance builder, Delta Sigma calculator, and shared forecast context.
- Return type:
dict[str, Any]
Notes
Calling this method explicitly recomputes the forecast products and refreshes the cached result. Use
forecast()when you want the cached products if they already exist.