pyselfi_examples.grf.model.blackbox_GRF module¶
A blackbox to generate Gaussian random fields and evaluate their power spectrum, using the Simbelmynë code.
- class pyselfi_examples.grf.model.blackbox_GRF.blackbox(P, **kwargs)[source]¶
Bases:
object
This class represents a SELFI blackbox.
- Variables
P (int) – number of output summary statistics. This is the only mandatory argument
theta2P (func) – function to go from input parameters theta to cosmological power spectrum
k_s (array, double, dimension=S) – vector of support wavenumbers
G_sim (
FourierGrid
) – Fourier grid of the simulationP_ss (
PowerSpectrum
) – fiducial summaries at the expansion point, to normalize the output of the blackboxcorner0 (double) – x-position of the corner of the box with respect to the observer (which is at (0,0,0))
corner1 (double) – y-position of the corner of the box with respect to the observer (which is at (0,0,0))
corner2 (double) – z-position of the corner of the box with respect to the observer (which is at (0,0,0))
a_min (double) – minimale scale factor
noise_std (double) – standard deviation for the Gaussian noise
seedphases (int) – (first) random seed to be used for the phase realizations
fixphases (bool) – fix the phase realization? if True the seed used will always be seedphases
seednoise (int) – (first) random seed to be used for the noise realizations
fixnoise (bool) – fix the noise realization? if True the seed used will always be seednoise
save_frequency (int) – saves the output on the blackbox on disk each save_frequency evaluations
Note
corner0, corner1, corner2, and a_min have no influence on the blackbox output
- _aux_blackbox(P, seedphases=None, seednoise=None)[source]¶
Auxiliary routine for the GRF blackbox: generates a noisy realization from an input power spectrum object, and returns its normalized estimated power spectrum.
- Parameters
P (
PowerSpectrum
) – input power spectrum objectseedphases (int, optional, default=None) – value of the seed to generate the phases of the Gaussian random field
seednoise (int, optional, default=None) – value of the seed to generate the noise realization, uses current state if set to None
- Returns
Phi – vector of summary statistics
- Return type
array, double, dimension=P
- _get_powerspectrum_from_cosmo(cosmo, fname_powerspectrum, force=False)[source]¶
Loads or computes the power spectrum from input cosmological parameters.
- Parameters
cosmo (dictionary) – cosmological parameters (and some infrastructure parameters)
fname_powerspectrum (
str
) – name of input/output power spectrum fileforce (bool, optional, default=False) – force recomputation?
- Returns
P – power spectrum object
- Return type
PowerSpectrum
- _get_powerspectrum_from_theta(theta)[source]¶
Returns a power spectrum from its value at support wavenumbers, by performing a Spline interpolation.
- Parameters
theta (array, double, dimension=S) – vector of power spectrum values at the support wavenumbers
- Returns
P – power spectrum object
- Return type
PowerSpectrum
- compute_pool(theta, d, pool_fname, N)[source]¶
Computes a pool of realizations of the GRF blackbox. A method compute_pool with this prototype is the only mandatory method.
- Parameters
theta (array, double, dimension=S) – vector of power spectrum values at the support wavenumbers
d (int) – direction in parameter space, from 0 to S
pool_fname (
str
) – pool file nameN (int) – number of realizations required
- Returns
p – simulation pool
- Return type
pool
- evaluate(theta, seedphases=None, seednoise=None, i=0, N=0)[source]¶
Evaluates the GRF blackbox from an input vector of power spectrum coefficients at the support wavenumbers.
- Parameters
theta (array, double, dimension=S) – vector of power spectrum values at the support wavenumbers
seedphases (int, optional, default=None) – value of the seed to generate the phases of the Gaussian random field
seednoise (int, optional, default=None) – value of the seed to generate the noise realization, uses current state if set to None
i (int, optional, default=0) – current evaluation index of the blackbox
N (int, optional, default=0) – total number of evaluations of the blackbox
- Returns
Phi – vector of summary statistics
- Return type
array, double, dimension=P
- make_data(cosmo, fname_powerspectrum, seedphases=None, seednoise=None, force=False)[source]¶
Evaluates the GRF blackbox to make mock data, from input cosmological parameters.
- Parameters
cosmo (dictionary) – cosmological parameters (and some infrastructure parameters)
fname_powerspectrum (
str
) – name of input/output power spectrum fileseedphases (int, optional, default=None) – value of the seed to generate the phases of the Gaussian random field
seednoise (int, optional, default=None) – value of the seed to generate the noise realization, uses current state if set to None
force (bool, optional, default=False) – force recomputation?
- Returns
Phi – vector of summary statistics
- Return type
array, double, dimension=P