|
Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
|
Functions | |
| def | build_data_dict (stats_arr, prefix) |
| def | save_hypercube (fname, sample_points) |
| def | load_hypercube (fname) |
| def | generate_latin_hypercube (samples, param_dict, class_root, seed=10) |
| def | generate_ccl_pspec (sample_points, root, class_data_root, zvals, default_params=None, nonlin=False, mode='std') |
| def | generate_class_ini (sample_points, root, nonlinear=False, mnu=False, redshifts=np.arange(0., 3., 0.5)) |
| def | run_class (fname_pattern, class_root, precision=False) |
| def | load_summary_stats (sample_points, ccl_data_root, class_data_root, thresholds=[5e-5, e, e, e, e, e, scale_ranges=[(1e-4, 1e-2), e, e, e, e0, z_vals=['1', cache_name=None) |
| def | ccl_summary_stats (params, fname_template='../stats/lhs_mpk_err_lin_%05d_z%d.dat', thresholds=[5e-5, e, e, e, e, e, scale_ranges=[(1e-4, 1e-2), e, e, e, e0, z_vals=['1', cache_name=None) |
| def param_space.build_data_dict | ( | stats_arr, | |
| prefix | |||
| ) |
Build a data dictionary with columns named according to (k,z) bins, a threshold value, and some prefix. Assumes that stats_arr has shape: (N_samp, N_thres, N_z, N_kbins)
Definition at line 6 of file param_space.py.
References Catch::Generators.range().
| def param_space.ccl_summary_stats | ( | params, | |
fname_template = '../stats/lhs_mpk_err_lin_%05d_z%d.dat', |
|||
thresholds = [5e-5, |
|||
| e, | |||
| e, | |||
| e, | |||
| e, | |||
| e, | |||
scale_ranges = [(1e-4, 1e-2), |
|||
| e, | |||
| e, | |||
| e, | |||
| e0, | |||
z_vals = ['1', |
|||
cache_name = None |
|||
| ) |
Calculate summary stats for the deviation between CCL and reference power spectra as a function of scale and redshift, for a large number of sample points over the cosmological parameter space.
Definition at line 520 of file param_space.py.
References Catch::Generators.range().
Referenced by load_summary_stats().
| def param_space.generate_ccl_pspec | ( | sample_points, | |
| root, | |||
| class_data_root, | |||
| zvals, | |||
default_params = None, |
|||
nonlin = False, |
|||
mode = 'std' |
|||
| ) |
Generate linear and non-linear power spectra using CCL, for a set of
points in cosmological parameter space and redshift.
Parameters
----------
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
root : str
Path of directory in which output files should be stored.
class_data_root : str
Root of filenames in which CLASS power spectra were stored.
zvals : array_like
Array of redshifts at which the power spectra should be evaluated.
default_params : dict, optional
Dictionary of default cosmological parameters, to be used if a
necessary parameter is not included in sample_points.
nonlin : bool, optional
Whether to load non-linear P(k). Default: False.
mode : str, optional
Which mode the CLASS run was performed in. Default: 'std'.
Definition at line 137 of file param_space.py.
References generate_class_ini(), and Catch::Generators.range().
Referenced by generate_latin_hypercube().
| def param_space.generate_class_ini | ( | sample_points, | |
| root, | |||
nonlinear = False, |
|||
mnu = False, |
|||
redshifts = np.arange(0., 3., 0.5) |
|||
| ) |
Generate CLASS .ini files for a set of parameters.
Parameters
----------
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
root : str
Path of directory in which .ini files should be stored.
nonlinear : bool, optional
Whether CLASS should return the linear or nonlinear (halofit) power
spectrum. Default: False.
mnu : bool, optional
Whether to include massive neutrinos.
redshifts : array_like, optional
Array of redshift values at which P(k) should be calculated. Default:
Five bins from 0.0 to 2.5 in increments of 0.5.
Definition at line 230 of file param_space.py.
References Catch::Generators.range().
Referenced by generate_ccl_pspec().
| def param_space.generate_latin_hypercube | ( | samples, | |
| param_dict, | |||
| class_root, | |||
seed = 10 |
|||
| ) |
Generate a Latin hypercube for a given set of parameters.
Parameters
----------
samples : int
Number of samples points to draw from the hypercube.
param_dict : dict
Dictionary containing parameter names (keys) and tuple with min/max.
values (values).
class_root : str
Path to directory containing 'class' executable.
seed : int, optional
Random seed to use when sampling from hypercube.
Returns
-------
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
Definition at line 81 of file param_space.py.
References generate_ccl_pspec(), and Catch::Generators.range().
| def param_space.load_hypercube | ( | fname | ) |
Load a Latin hypercube from disk. Parameter columns will be ordered
alphabetically by name.
Parameters
----------
fname : str
Filename to read sample points from.
Returns
-------
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
Definition at line 50 of file param_space.py.
References Catch::Generators.range().
| def param_space.load_summary_stats | ( | sample_points, | |
| ccl_data_root, | |||
| class_data_root, | |||
thresholds = [5e-5, |
|||
| e, | |||
| e, | |||
| e, | |||
| e, | |||
| e, | |||
scale_ranges = [(1e-4, 1e-2), |
|||
| e, | |||
| e, | |||
| e, | |||
| e0, | |||
z_vals = ['1', |
|||
cache_name = None |
|||
| ) |
Calculate summary stats for the deviation between CCL and reference power
spectra as a function of scale and redshift, for a large number of sample
points over the cosmological parameter space.
Parameters
----------
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
ccl_data_root : str
Root of filenames of CCL power spectrum files
class_data_root : str
Root of filenames of CLASS power spectrum files. If the string '_nl_'
is found in class_data_root, this will assume that nonlinear power
spectra should be loaded.
Definition at line 398 of file param_space.py.
References ccl_summary_stats(), and Catch::Generators.range().
Referenced by run_class().
| def param_space.run_class | ( | fname_pattern, | |
| class_root, | |||
precision = False |
|||
| ) |
Run CLASS on a set of .ini files.
Parameters
----------
fname_pattern : str
Pattern (glob format) for matching the .ini files to be run by CLASS.
class_root : str
Directory in which the 'class' executable is stored.
precision : bool, optional
Whether to run CLASS in high-precision mode (using the pk_ref.pre
precision file).
Definition at line 350 of file param_space.py.
References load_summary_stats().
| def param_space.save_hypercube | ( | fname, | |
| sample_points | |||
| ) |
Save a Latin hypercube to disk as a text file. Parameter columns will be
ordered alphabetically by name.
Parameters
----------
fname : str
Filename for output file.
sample_points : dict
Dictionary containing parameter names (keys) and array of parameter
values for all sample points (values).
Definition at line 26 of file param_space.py.