# hiddenbox

class selfisys.hiddenbox.HiddenBox(k_s: Any, P_ss_path: str, Pbins_bnd: Any, theta2P: Callable, P: int, size: int, L: float, G_sim_path: str, G_ss_path: str, Np0: int, Npm0: int, fsimdir: str, noise_std: float | None = None, radial_selection: str | None = None, selection_params: List[Any] | None = None, observed_density: float | None = None, linear_bias: float | List[float] | None = None, norm_csts: float | List[float] | None = None, survey_mask_path: str | None = None, local_mask_prefix: str | None = None, sim_params: str | None = None, eff_redshifts: List[float] | None = None, TimeSteps: List[int] | None = None, TimeStepDistribution: str | None = None, seedphase: int | None = None, seednoise: int | None = None, fixnoise: bool = False, seednorm: int | None = None, save_frequency: int | None = None, reset: bool = False, verbosity: int = 2, **kwargs)

  Bases: `object`

  This class represents custom forward data model of large-scale spectroscopic galaxy surveys.

  property Npop

    Number of populations.

  property Ntimesteps

    Number of time steps.

  property Psingle

    Number of summary statistics for each population.

  compute_pool(theta, d, pool_fname, N, index=None, force_powerspectrum=False, force_parfiles=False, force_sim=False, remove_sbmy=False, theta_is_p=False, simspath=None, bar=False)

    Compute a pool of realisations of the hidden box compatible with pySELFI.

    Parameters:

      - theta (ndarray) – Power spectrum values at the support wavenumbers.

      - d (int) – Direction in parameter space, from 0 to S.

      - pool_fname (str) – Filename for the pool.

      - N (int) – Number of realisations required at the given direction.

      - index (int, optional) – Index of a single simulation to run. Default is None.

      - force_powerspectrum (bool, optional) – If True, force recomputation of the power spectrum. Default is False.

      - force_parfiles (bool, optional) – If True, overwrite existing parameter files. Default is False.

      - force_sim (bool, optional) – If True, rerun the simulation even if the output density already exists. Default is False.

      - remove_sbmy (bool, optional) – If True, remove Simbelmynë output files from disk. Default is False.

      - theta_is_p (bool, optional) – Set to True when theta is already an unnormalised power spectrum. Default is False.

      - simspath (str, optional) – Path indicating where to store the simulations. Default is None.

      - bar (bool, optional) – If True, display a progress bar. Default is False.

    Returns:

      p – Simulation pool object.

    Return type:

      Pool

  evaluate(theta, d, seedphase, seednoise, i=0, N=0, force_powerspectrum=False, force_parfiles=False, force_sim=False, remove_sbmy=False, theta_is_p=False, simspath=None, check_output=False, RSDs=True, abc=False, cosmo_vect=None)

    Evaluate the hidden box for a given input power spectrum.

    The result is deterministic (the phase is fixed), except as it is modified by nuisance parameters if any.

    This routine is used by pySELFI to compute the gradient of the hidden box with respect to the power spectrum, and by ABC-PMC to evaluate the forward model.

    Parameters:

      - theta (ndarray) – Power spectrum values at the support wavenumbers.

      - d (int) – Direction in parameter space, from 0 to S.

      - seedphase (int or list of int) – Seed to generate the initial white noise in Fourier space.

      - seednoise (int or list of int) – Seed to generate the noise realisation.

      - i (int, optional) – Current evaluation index of the hidden box. Default is 0.

      - N (int, optional) – Total number of evaluations of the hidden box. Default is 0.

      - force_powerspectrum (bool, optional) – If True, force recomputation of the power spectrum at the values of the Fourier grid. Default is False.

      - force_parfiles (bool, optional) – If True, overwrite existing parameter files. Default is False.

      - force_sim (bool, optional) – If True, rerun the simulation even if the output density already exists. Default is False.

      - remove_sbmy (bool, optional) – If True, remove Simbelmynë output files from disk. Default is False.

      - theta_is_p (bool, optional) – Set to True if theta is already an unnormalised power spectrum. Default is False.

      - simspath (str, optional) – Path to the simulations directory. Default is None.

      - check_output (bool, optional) – If True, check the integrity of the output file and recompute if corrupted. Default is False.

      - RSDs (bool, optional) – Whether to compute redshift-space distortions. Default is True.

      - abc (bool or str, optional) – If not False, remove most output files after evaluation. Default is False.

      - cosmo_vect (ndarray, optional) – Cosmological parameters. Required if abc is True.

    Returns:

      Phi – Vector of summary statistics.

    Return type:

      ndarray

  property force_neglect_lightcone

    Whether to force neglecting the lightcone.

  property force_recompute_mocks

    Whether to force recomputation of mocks.

  property gravity_on

    Whether gravity is enabled.

  load_pool(pool_fname, N)

    Load a pool of realisations of the hidden box.

    Parameters:

      - pool_fname (str) – Filename of the pool to load.

      - N (int) – Number of realisations in the pool.

    Returns:

      p – Simulation pool object.

    Return type:

      Pool

  make_data(cosmo, id, seedphase, seednoise, force_powerspectrum=False, force_parfiles=False, force_sim=False, force_cosmo=False, force_phase=False, d=-1, remove_sbmy=True, verbosity=None, return_g=False, RSDs=True, prefix_mocks=None)

    Generate simulated data based on the given cosmological parameters.

    Parameters:

      - cosmo (dict) – Cosmological and infrastructure parameters.

      - id (int or str, optional) – Identifier used as a suffix in the file names. Default is 0.

      - seedphase (int or list of int) – Seed to generate the initial white noise in Fourier space.

      - seednoise (int or list of int) – Seed to generate the noise realisation.

      - force_powerspectrum (bool, optional) – Force recomputing the input spectrum. Default is False.

      - force_parfiles (bool, optional) – Force recomputing the parameter files. Default is False.

      - force_sim (bool, optional) – Force recomputing the simulation. Default is False.

      - force_cosmo (bool, optional) – Force recomputing the cosmological parameters. Default is False.

      - force_phase (bool, optional) – Force recomputing the initial phase. Default is False.

      - d (int, optional) – Direction in the parameter space. Default is -1.

      - remove_sbmy (bool, optional) – Whether to remove most Simbelmynë output files after use for disk space management. Default is True.

      - verbosity (int, optional) – Verbosity level. If None, use self.verbosity. Default is None.

      - return_g (bool, optional) – Whether to return the full field alongside the summary. Default is False.

      - RSDs (bool, optional) – Whether to compute the redshift-space distortions. Default is True.

      - prefix_mocks (str, optional) – Prefix for the mock data. If None, use self.prefix_mocks. Default is None.

    Returns:

      - Phi (ndarray) – Vector of summary statistics.

      - g (ndarray or list of ndarray or None) – Observed field(s) if return_g is True; otherwise None.

  property modified_selfi

    Whether to use the modified selfi.

  property prefix_mocks

    Prefix for the mocks.

  reset_survey()

    Re-initialise the survey mask C(n) and radial selection function R(r).

  property setup_only

    Whether to only set up the hidden box.

  switch_recompute_pool(prefix_mocks=None)

    Toggle recomputation of the pool for future compute_pool calls.

    Parameters:

      prefix_mocks (str, optional) – Prefix for the future simulation files. Default is None.

  switch_setup()

    Toggle the setup-only mode.

  update(**kwargs)

    Updates the given parameter(s) of the hidden box with the given value(s).

    Parameters:

      **kwargs (dict) – dictionary of parameters to update