This page details the methods and classes provided by the tabcorr module.
Top-Level Interface¶
- class tabcorr.TabCorr¶
Class to tabulate halo and predict galaxy correlation functions.
- predict(model, separate_gal_type=False, n_gauss_prim=10, check_consistency=True, **occ_kwargs)¶
Predict the number density and correlation function for a model.
- Parameters:
- modelHodModelFactory or numpy.ndarray
Instance of
halotools.empirical_models.HodModelFactorydescribing the model for which predictions are made or a numpy array containing the mean occupation in each halo bin. The latter option is mainly used internally.- separate_gal_typebool, optional
If True, the return values are dictionaries divided by each galaxy types contribution to the output result. Default is False.
- n_gauss_primint, optional
The number of points used in the Gaussian quadrature to calculate the mean occupation averaged over the primary halo property in each halo bin. Default is 10.
- check_consistency: bool, optional
Whether to enforce consistency in the redshift, primary halo property and secondary halo property between the model and the TabCorr instance. Default is True.
- **occ_kwargsdict, optional
Keyword arguments passed to the
mean_occupationfunctions of the model.
- Returns:
- ngalfloat or dict
Galaxy number density. If separate_gal_type is True, this is a dictionary splitting contributions by galaxy type.
- xinumpy.ndarray
Correlation function values. If separate_gal_type is True, this is a dictionary splitting contributions by galaxy type.
- classmethod read(fname)¶
Read tabulated correlation functions from the disk.
- Parameters:
- fnamestring or h5py.Group
Name of the file or h5py group containing the TabCorr object.
- Returns:
- TabCorr object.
- classmethod tabulate(halocat, tpcf, *tpcf_args, mode='auto', Num_ptcl_requirement=300, prim_haloprop_key='halo_mvir', prim_haloprop_bins=30, sec_haloprop_key='halo_nfw_conc', sec_haloprop_percentile_bins=None, sats_per_prim_haloprop=3e-12, downsample=1.0, verbose=False, redshift_space_distortions=True, cens_prof_model=None, sats_prof_model=None, project_xyz=False, cosmology_obs=None, num_threads=1, **tpcf_kwargs)¶
Tabulate correlation functions for halos.
- Parameters:
- halocathalotools.sim_manager.CachedHaloCatalog or halotools.sim_manager.UserSuppliedHaloCatalog
Halo catalog used to tabulate correlation functions.
- tpcffunction
The halotools correlation function for which values are tabulated. Can also be a custom function as long as it follows the halotools syntax.
- *tpcf_argstuple, optional
Positional arguments passed to the tpcf function.
- modestring, optional
Whether an auto- (‘auto’) or a cross-correlation (‘cross’) function is tabulated.
- Num_ptcl_requirementint, optional
Requirement on the number of dark matter particles in the halo catalog. The column defined by the prim_haloprop_key string will have a cut placed on it: all halos with halocat.halo_table[prim_haloprop_key] < Num_ptcl_requirement*halocat.particle_mass will be thrown out. Default value is set in halotools.sim_defaults.Num_ptcl_requirement.
- prim_haloprop_keystring, optional
Name of the primary halo property governing the occupation statistics of galaxies. Default value is specified in the halotools.empirical_models.model_defaults.
- prim_haloprop_binsint or list, optional
Integer determining how many (logarithmic) bins in primary halo property will be used. If a list or numpy array is provided, these will be used as bins directly. Default is 30.
- sec_haloprop_keystring, optional
String giving the column name of the secondary halo property governing the assembly bias. Default value is specified in the halotools.empirical_models.model_defaults module.
- sec_haloprop_percentile_binsint, float or None, optional
If an integer, determines how many evenly spaced bins in the secondary halo property percentiles are going to be used. If a float between 0 and 1, it determines the split. If None is provided, no binning is applied. Default is None.
- sats_per_prim_halopropfloat, optional
Determines how many satellites sample each halo. For each halo, the number is drawn from a Poisson distribution with an expectation value of sats_per_prim_haloprop times the primary halo property. Default is 3e12.
- downsamplefloat or function, optional
Fraction between 0 and 1 used to downsample the total sample used to tabulate correlation functions. Values below unity can be used to reduce the computation time. It should not result in biases but the resulting correlation functions will be less accurate. If float, the same value is applied to all halos. If function, it should return the fraction is a function of the primary halo property. Default is 1.0.
- verbosebool, optional
Whether the progress should be displayed. Default is False.
- redshift_space_distortionsbool, optional
Whether redshift space distortions should be applied to halos/galaxies. Default is True.
- cens_prof_modelobject, optional
Instance of halotools.empirical_models.MonteCarloGalProf that determines the phase space coordinates of centrals. If None, halotools.empirical_models.TrivialPhaseSpace will be used. Default is None.
- sats_prof_modelobject, optional
Instance of halotools.empirical_models.MonteCarloGalProf that determines the phase space coordinates of satellites. If None, halotools.empirical_models.NFWPhaseSpace will be used. Default is None.
- project_xyzbool, optional
If True, the coordinates will be projected along all three spatial axes. If False, only the projection onto the z-axis is used. Default is False.
- cosmology_obsobject, optional
Instance of an astropy astropy.cosmology. This can be used to correct coordinates in the simulation for the Alcock-Paczynski (AP) effect, i.e. a mismatch between the cosmology of the model (simulation) and the cosmology used to interpret observations. Note that the cosmology of the simulation is part of the halocat object. If None, no correction for the AP effect is applied. Also, a correction for the AP effect is only applied for auto-correlation functions. Default is None.
- num_threadsint, optional
How many threads to use for the tabulation. Default is 1.
- **tpcf_kwargsdict, optional
Keyword arguments passed to the tpcf function.
- Returns:
- halotabtabcorr.TabCorr
TabCorr object.
- Raises:
- ValueError
If invalid halo bins are given.
- RuntimeError
If TabCorr encounters an internal error.
- write(fname, overwrite=False, max_args_size=1000000, matrix_dtype=<class 'numpy.float32'>)¶
Write the tabulated correlation functions to the disk.
- Parameters:
- fnamestring or h5py.Group
Name of the file or h5py group the data is written to.
- overwritebool, optional
If True, any existing file will be overwritten. Default is False.
- max_args_sizeint, optional
By default, TabCorr writes all arguments passed to the correlation function when calling tabulate to file. However, arguments that are numpy arrays with more entries than max_args_size will be omitted. Default is 1000000.
- matrix_dtypetype
The dtype used to write the correlation matrix to disk. Can be used to save space at the expense of precision.
- class tabcorr.Interpolator(tabcorr_list, param_dict_table)¶
Initialize an interpolation of multiple TabCorr instances.
- Parameters:
- tabcorr_listlist or numpy.ndarray
TabCorr instances used to interpolate.
- param_dict_tableastropy.table.Table
Table containing the keywords and values corresponding to each instance in the TabCorr list. Must have the same length and ordering as tabcorr_list.
- Raises:
- ValueError
If param_dict_table does not describe a grid.
- predict(model, separate_gal_type=False, n_gauss_prim=10, extrapolate=False, check_consistency=True, **occ_kwargs)¶
Interpolate the predictions from multiple TabCorr instances.
The values of parameters to interpolate should be in the parameter dictionary of the model.
- Parameters:
- modelHodModelFactory
Instance of
halotools.empirical_models.HodModelFactorydescribing the model for which predictions are made.- separate_gal_typebool, optional
If True, the return values are dictionaries divided by each galaxy types contribution to the output result. Default is False.
- n_gauss_primint, optional
The number of points used in the Gaussian quadrature to calculate the mean occupation averaged over the primary halo property in each halo bin. Default is 10.
- extrapolatebool, optional
Whether to allow extrapolation beyond points sampled by the input TabCorr instances. Default is False.
- check_consistencybool, optional
Whether to enforce consistency in the redshift, primary halo property and secondary halo property between the model and the TabCorr instance. Default is True.
- **occ_kwargsdict, optional
Keyword arguments passed to the
mean_occupationfunctions of the model.
- Returns:
- ngalfloat
Galaxy number density.
- xinumpy.ndarray
Correlation function values.
- Raises:
- ValueError
If extrapolate is set to True and values are outside the interpolation range.
- classmethod read(fname)¶
Read a TabCorr interpolator from the disk.
- Parameters:
- fnamestring
Name of the file containing the interpolator object.
- Returns:
- Interpolator object.
- write(fname, overwrite=False, max_args_size=1000000, matrix_dtype=<class 'numpy.float32'>)¶
Write the TabCorr interpolator to the disk.
- Parameters:
- fnamestring or h5py.Group
Name of the file the data is written to.
- overwritebool, optional
If True, any existing file will be overwritten. Default is False.
- max_args_sizeint, optional
By default, TabCorr writes all arguments passed to the correlation function when calling tabulate to file. However, arguments that are numpy arrays with more entries than max_args_size will be omitted. Default is 1000000.
- matrix_dtypetype
The dtype used to write the correlation matrix to disk. Can be used to save space at the expense of precision.
tabcorr.database¶
Module providing database capabilities.
- class tabcorr.database.TabCorrFlatw0waCDM(H0: ~astropy.cosmology._src.parameter.core.Parameter, Om0: ~astropy.cosmology._src.parameter.core.Parameter, Tcmb0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. K>, derived=False, unit=Unit("K"), equivalencies=[], fvalidate='scalar', doc='Temperature of the CMB at z=0.'), Neff: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=3.04, derived=False, unit=None, equivalencies=[], fvalidate='non-negative', doc='Number of effective neutrino species.'), m_nu: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. eV>, derived=False, unit=Unit("eV"), equivalencies=[(Unit("kg"), Unit("J"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m2"), Unit("J / m2"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m3"), Unit("J / m3"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / s"), Unit("J / s"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>)], fvalidate=<function FLRW.m_nu>, doc='Mass of neutrino species.'), Ob0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=0.0, derived=False, unit=None, equivalencies=[], fvalidate=<function FLRW.Ob0>, doc='Omega baryon; baryonic matter density/critical density at z=0.'), w0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=-1.0, derived=False, unit=None, equivalencies=[], fvalidate='float', doc='Dark energy equation of state at z=0.'), wa: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=0.0, derived=False, unit=None, equivalencies=[], fvalidate='float', doc='Negative derivative of dark energy equation of state w.r.t. a.'), *, name: ~astropy.cosmology._src.core._NameField = None, meta: ~astropy.utils.metadata.core.MetaData = None)¶
- class tabcorr.database.TabCorrFlatwCDM(H0: ~astropy.cosmology._src.parameter.core.Parameter, Om0: ~astropy.cosmology._src.parameter.core.Parameter, Tcmb0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. K>, derived=False, unit=Unit("K"), equivalencies=[], fvalidate='scalar', doc='Temperature of the CMB at z=0.'), Neff: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=3.04, derived=False, unit=None, equivalencies=[], fvalidate='non-negative', doc='Number of effective neutrino species.'), m_nu: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. eV>, derived=False, unit=Unit("eV"), equivalencies=[(Unit("kg"), Unit("J"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m2"), Unit("J / m2"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m3"), Unit("J / m3"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / s"), Unit("J / s"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>)], fvalidate=<function FLRW.m_nu>, doc='Mass of neutrino species.'), Ob0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=0.0, derived=False, unit=None, equivalencies=[], fvalidate=<function FLRW.Ob0>, doc='Omega baryon; baryonic matter density/critical density at z=0.'), w0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=-1.0, derived=False, unit=None, equivalencies=[], fvalidate='float', doc='Dark energy equation of state.'), *, name: ~astropy.cosmology._src.core._NameField = None, meta: ~astropy.utils.metadata.core.MetaData = None)¶
- tabcorr.database.configuration(config_str)¶
Describe the tabulation configuration used.
- Parameters:
- config_strstr
String describing the configuration. You can specify a mixture of different configuations by separating them with a _. In this case, the first configurations in the list always take precedence in case multiple configurations apply to a parameter.
- Returns:
- config_dictdict
Dictionary descibing the configuration, i.e. radial binning, number of satellites per halo etc.
- Raises:
- ValueError
If an unkown configuration was requested.
- tabcorr.database.cosmology(suite, i_cosmo=0)¶
Return the cosmology of a given simulation.
- Parameters:
- suitestr
The simulation suite.
- i_cosmoint, optional
Number corresponding to the cosmology. Default is 0.
- Returns:
- cosmoastropy.cosmology.Cosmology
The cosmology associated with the simulation. This is a regular astropy cosmology object with sigma8 added as an extra attribute.
- Raises:
- ValueError
If the an unkown simulation or cosmology number is requested.
- tabcorr.database.directory(suite, redshift, i_cosmo=0, i_phase=0, config=None)¶
Return the directory where all data for a simulation snapshot is stored.
- Parameters:
- suitestr
The simulation suite.
- redshiftfloat
The redshift of the simulation output.
- i_cosmoint, optional
If applicable, number corresponding to the cosmology. Default is 0.
- i_phaseint, optional
If applicable, number corresponding to the simulation phase. Default is 0.
- configstr, optional
Simulation configuration. Only applicable to AbacusSummit. If None, will default to ‘base’ for AbacusSummit. Default is None.
- Returns:
- pathpathlib.Path
The directory where all data for a simulation snapshot is stored.
- Raises:
- RuntimeError
If the TABCORR_DATABASE environment variable is not set.
- tabcorr.database.read(suite, redshift, tpcf, i_cosmo=0, i_phase=0, sim_config=None, tab_config='default')¶
Read the TabCorr tabulation for a given simulation, redshift etc.
- Parameters:
- suitestr
The simulation suite.
- redshiftfloat
The redshift of the simulation output.
- tpcfstr
String describing the two-point correlation function.
- i_cosmoint, optional
If applicable, number corresponding to the cosmology. Default is 0.
- i_phaseint, optional
If applicable, number corresponding to the simulation phase. Default is 0.
- sim_configstr, optional
Simulation configuration. Only applicable to AbacusSummit. If None, will default to ‘base’ for AbacusSummit. Default is None.
- tab_configconfig_strstr, optional
String describing the configuration of the tabulation, i.e. binning, cosmology etc.
- Returns:
- halotabtabcorr.TabCorr or tabcorr.Interpolator
The tabcorr tabulation.
- tabcorr.database.simulation_name(suite, i_cosmo=0, i_phase=0, config=None)¶
Return the name of a given simulation.
- Parameters:
- suitestr
The simulation suite.
- i_cosmoint, optional
If applicable, number corresponding to the cosmology. Default is 0.
- i_phaseint, optional
If applicable, number corresponding to the simulation phase. Default is 0.
- configstr, optional
Simulation configuration. Only applicable to AbacusSummit. If None, will default to ‘base’ for AbacusSummit. Default is None.
- Returns:
- namestr
The name of the simulation.
- Raises:
- ValueError
If the an unkown simulation, simulation number or phase number is requested.
- tabcorr.database.tabcorr(suite, redshift, tpcf, i_cosmo=0, i_phase=0, sim_config=None, tab_config='default')¶
Read the TabCorr tabulation for a given simulation, redshift etc.
- Parameters:
- suitestr
The simulation suite.
- redshiftfloat
The redshift of the simulation output.
- tpcfstr
String describing the two-point correlation function.
- i_cosmoint, optional
If applicable, number corresponding to the cosmology. Default is 0.
- i_phaseint, optional
If applicable, number corresponding to the simulation phase. Default is 0.
- sim_configstr, optional
Simulation configuration. Only applicable to AbacusSummit. If None, will default to ‘base’ for AbacusSummit. Default is None.
- tab_configconfig_strstr, optional
String describing the configuration of the tabulation, i.e. binning, cosmology etc.
- Returns:
- halotabtabcorr.TabCorr or tabcorr.Interpolator
The tabcorr tabulation.