pyselfi_examples.simbelmyne.model.blackbox_SBMY module

A blackbox to generate synthetic galaxy observations and evaluate their power spectrum, using the Simbelynë code.

class pyselfi_examples.simbelmyne.model.blackbox_SBMY.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 simulation

  • G_ss (FourierGrid) – Fourier grid on which to compute the output summaries of the blackbox

  • P_ss (PowerSpectrum) – fiducial summaries at the expansion point, to normalize the output of the blackbox

  • corner0 (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))

  • Np0 (int) – particle grid size x

  • Npm0 (int) – simulation particle-mesh grid size x

  • fdir (str) – directory for inference outputs

  • fsimdir (str) – directory for simulation outputs

  • fname_inputsurveygeometry (str) – input survey geometry filename

  • b_cut (double) – cut in galactic latitude to generate the mock survey geometry

  • bright_apparent_magnitude_cut (double) – bright cut in absolute magnitude for Schechter completeness

  • faint_apparent_magnitude_cut (double) – faint cut in apparent magnitude for Schechter completeness

  • bright_absolute_magnitude_cut (double) – bright cut in absolute magnitude for Schechter completeness

  • faint_absolute_magnitude_cut (double) – faint cut in absolute magnitude for Schechter completeness

  • Mstar (double) – Schechter completeness parameter

  • alpha (double) – Schechter completeness parameter

  • save_frequency (int) – saves the output on the blackbox on disk each save_frequency evaluations

_aux_blackbox(d, fname_powerspectrum, fname_simparfile, fname_mockparfile, fname_RngStateLPT, fname_whitenoise, fname_outputinitialdensity, fname_outputrealspacedensity, fname_outputdensity, fname_RngStateMock, fname_outputmock, fname_outputss, fname_simlogs, fname_mocklogs, force_parfiles=False, force_sim=False, force_mock=False)[source]

Auxiliary routine for the Simbelynë blackbox: generates a noisy realization from an input power spectrum object, and returns its normalized estimated power spectrum.

Parameters
  • d (int) – index giving the direction in parameter space: -1 for mock data, 0 for the expansion point, or from 1 to S

  • fname_powerspectrum (str) – name of input power spectrum file

  • fname_simparfile (str) – name of output simulation parameter file

  • fname_mockparfile (str) – name of output mock parameter file

  • fname_RngStateLPT (str) – name of output random number generator state file for LPT module

  • fname_whitenoise (str) – name of output white noise file

  • fname_outputinitialdensity (str) – name of output initial density field file

  • fname_outputrealspacedensity (str) – name of output real-space density field file

  • fname_outputdensity (str) – name of output redshift-space density field file

  • fname_RngStateMock (str) – name of output random number generator state file for Mock module

  • fname_outputmock (str) – name of output mock field file

  • fname_outputss (str) – name of output summary statistics file

  • fname_simlogs (str) – name of the output Simbelynë logs

  • fname_mocklogs (str) – name of the output Simbelynë logs

  • force_parfiles (bool, optional, default=False) – overwrite if parameter files already exists?

  • force_sim (bool, optional, default=False) – force recomputation if output density already exists?

  • force_mock (bool, optional, default=False) – force recomputation if output mock summary statistics file already exists?

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

_clean_sbmy_outputs(fname_outputdensity, fname_outputmock, fname_outputss)[source]

Removes Simbelynë output files to save disk space.

Parameters
  • fname_outputdensity (str) – name of output redshift-space density field file

  • fname_outputmock (str) – name of output mock field file

  • fname_outputss (str) – name of output summary statistics file

_compute_Phi(fname_outputss)[source]

Computes summary statistics (Phi) from Simbelynë output files.

Parameters

fname_outputss (str) – name of Simbelynë output summary statistics file

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

_compute_Phi_DM(fname_outputdensity)[source]

Compute summary statistics (Phi) from Simbelynë output files. Alternative routine to _compute_Phi using the dark matter field instead of galaxies, for testing purposes.

Parameters

fname_outputdensity (str) – name of Simbelynë output density field file

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

_get_powerspectrum_from_cosmo(cosmo, fname_powerspectrum, force_powerspectrum=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 file

  • force (bool, optional, default=False) – force recomputation?

_get_powerspectrum_from_theta(theta, fname_powerspectrum, force_powerspectrum=False)[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

  • fname_powerspectrum (str) – name of input/output power spectrum file

  • force_powerspectrum (bool, optional, default=False) – force recomputation?

_run_mock(fname_mockparfile, fname_mocklogs, fname_outputss, force_mock=False)[source]

Runs a simulation with Simbelynë for mock data.

Parameters
  • fname_mockparfile (str) – name of the input parameter file

  • fname_mocklogs (str) – name of the output Simbelynë logs

  • fname_outputss (str) – name of the output summary statistics file to be written

  • force_mock (bool, optional, default=False) – force recomputation if output summary statistics file already exists?

_run_sim(fname_simparfile, fname_simlogs, fname_outputdensity, force_sim=False)[source]

Runs a simulation with Simbelynë.

Parameters
  • fname_simparfile (str) – name of the input parameter file

  • fname_simlogs (str) – name of the output Simbelynë logs

  • fname_outputdensity (str) – name of the output density field to be written

  • force_sim (bool, optional, default=False) – force recomputation if output density already exists?

_save_cosmo(cosmo, fname_cosmo, force_cosmo=False)[source]

Saves cosmological parameters in json format.

Parameters
  • cosmo (dictionary) – cosmological parameters (and some infrastructure parameters) to be saved

  • fname_cosmo (str) – name of the output json file

  • force_cosmo (bool, optional, default=False) – overwrite if the file already exists?

_setup_parfiles(d, fname_simparfile, fname_mockparfile, fname_powerspectrum, fname_RngStateLPT, fname_whitenoise, fname_outputinitialdensity, fname_outputrealspacedensity, fname_outputdensity, fname_RngStateMock, fname_outputmock, fname_outputss, force_parfiles=False)[source]

Sets up Simbelynë parameter file given the necessary inputs (see the Simbelynë documentation for details).

Parameters
  • d (int) – index giving the direction in parameter space: -1 for mock data, 0 for the expansion point, or from 1 to S

  • fname_simparfile (str) – name of output simulation parameter file

  • fname_mockparfile (str) – name of output mock parameter file

  • fname_powerspectrum (str) – name of input power spectrum file

  • fname_RngStateLPT (str) – name of output random number generator state file for LPT module

  • fname_whitenoise (str) – name of output white noise file

  • fname_outputinitialdensity (str) – name of output initial density field file

  • fname_outputrealspacedensity (str) – name of output real-space density field file

  • fname_outputdensity (str) – name of output redshift-space density field file

  • fname_RngStateMock (str) – name of output random number generator state file for Mock module

  • fname_outputmock (str) – name of output mock field file

  • fname_outputss (str) – name of output summary statistics file

  • force_parfiles (bool, optional, default=False) – overwrite if files already exists?

compute_pool(theta, d, pool_fname, N, force_powerspectrum=False, force_parfiles=False, force_sim=False, force_mock=False)[source]

Computes a pool of realizations of the Simbelynë 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 name

  • N (int) – number of realizations required

  • force_powerspectrum (bool, optional, default=False) – force recomputation of the power spectrum?

  • force_parfiles (bool, optional, default=False) – overwrite if parameter files already exists?

  • force_sim (bool, optional, default=False) – force recomputation if output density already exists?

  • force_mock (bool, optional, default=False) – force recomputation if output mock summary statistics file already exists?

Returns

p – simulation pool

Return type

pool

evaluate(theta, d, i=0, N=0, force_powerspectrum=False, force_parfiles=False, force_sim=False, force_mock=False, remove_sbmy=True)[source]

Evaluates the Simbelynë 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

  • d (int) – index giving the direction in parameter space: -1 for mock data, 0 for the expansion point, or from 1 to S

  • i (int, optional, default=0) – current evaluation index of the blackbox

  • N (int, optional, default=0) – total number of evaluations of the blackbox

  • force_powerspectrum (bool, optional, default=False) – force recomputation of the power spectrum?

  • force_parfiles (bool, optional, default=False) – overwrite if parameter files already exists?

  • force_sim (bool, optional, default=False) – force recomputation if output density already exists?

  • force_mock (bool, optional, default=False) – force recomputation if output mock summary statistics file already exists?

  • remove_sbmy (bool, optional, default=True) – remove Simbelynë output files from disk?

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

make_data(cosmo, i=0, force_powerspectrum=False, force_parfiles=False, force_sim=False, force_mock=False, force_cosmo=False)[source]

Evaluates the Simbelynë blackbox to make mock data, from input cosmological parameters.

Parameters
  • cosmo (dictionary) – cosmological parameters (and some infrastructure parameters)

  • i (int, optional, default=0) – current evaluation index of the blackbox

  • force_powerspectrum (bool, optional, default=False) – force recomputation of the power spectrum?

  • force_parfiles (bool, optional, default=False) – overwrite if parameter files already exists?

  • force_sim (bool, optional, default=False) – force recomputation if output density already exists?

  • force_mock (bool, optional, default=False) – force recomputation if output mock summary statistics file already exists?

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

make_survey_geometry(N_CAT, cosmo, force=False)[source]

Produces a mock survey geometry file.

Parameters
  • N_CAT (int) – number of subcatalogs

  • cosmo (dictionary) – cosmological parameters (and some infrastructure parameters)

  • force (bool, optional, default=False) – force recomputation if file already exists?