CachedHaloCatalog¶
- class halotools.sim_manager.CachedHaloCatalog(*args, **kwargs)[source]¶
Bases:
object
Container class for the halo catalogs and particle data that are stored in the Halotools cache log.
CachedHaloCatalog
is used to retrieve halo catalogs from shorthand keyword inputs such assimname
,halo_finder
andredshift
.The halos are stored in the
halo_table
attribute in the form of an AstropyTable
. If available, anotherTable
storing a random downsampling of dark matter particles is stored in theptcl_table
attribute. See the Examples section below for details on how to access and manipulate this data.For a list of available snapshots provided by Halotools, see Simulations and Halo Catalogs Provided by Halotools. For information about the subhalo vs. host halo nomenclature conventions used throughout Halotools, see Rockstar halo and subhalo nomenclature conventions. For a thorough discussion of the meaning of each column in the Rockstar halo catalogs, see the appendix of Rodriguez Puebla et al 2016.
- Parameters:
- simnamestring, optional
Nickname of the simulation used as a shorthand way to keep track of the halo catalogs in your cache. The simnames of the Halotools-provided catalogs are ‘bolshoi’, ‘bolplanck’, ‘consuelo’ and ‘multidark’.
Default is set by the
default_simname
variable in thesim_defaults
module.- halo_finderstring, optional
Nickname of the halo-finder used to generate the hlist file from particle data.
Default is set by the
default_halo_finder
variable in thesim_defaults
module.- redshiftfloat, optional
Redshift of the halo catalog.
Default is set by the
default_redshift
variable in thesim_defaults
module.- version_namestring, optional
Nickname of the version of the halo catalog.
Default is set by the
default_version_name
variable in thesim_defaults
module.- ptcl_version_namestring, optional
Nicknake of the version of the particle catalog associated with the halos.
This argument is typically only used if you have cached your own particles via the
UserSuppliedPtclCatalog
class. Default is set by thedefault_version_name
variable in thesim_defaults
module.- fnamestring, optional
Absolute path to the location on disk storing the hdf5 file of halo data. If passing
fname
, do not pass the metadata keyssimname
,halo_finder
,version_name
orredshift
.- update_cached_fnamebool, optional
If the hdf5 file storing the halos has been relocated to a new disk location after storing the data in cache, the
update_cached_fname
input can be used together with thefname
input to update the cache log with the new disk location.See Instructions for relocating simulation data for further instructions.
- dz_tolfloat, optional
Tolerance within to search for a catalog with a matching redshift. Halo catalogs in cache with a redshift that differs by greater than
dz_tol
will be ignored. Default is 0.05.
Examples
If you followed the instructions in the Downloading the default halo catalog section of the Getting started with Halotools guide, then you can load the default halo catalog into memory by calling the
CachedHaloCatalog
with no arguments:>>> halocat = CachedHaloCatalog()
The halos are stored in the
halo_table
attribute in the form of an AstropyTable
.>>> halos = halocat.halo_table
As with any Astropy
Table
, the properties of the halos can be accessed in the same manner as a Numpy structured array or python dictionary:>>> array_of_masses = halocat.halo_table['halo_mvir'] >>> x_positions = halocat.halo_table['halo_x']
Note that all keys of a cached halo catalog begin with the substring
halo_
. This is a bookkeeping device used to help the internals of Halotools differentiate between halo properties and the properties of mock galaxies populated into the halos with ambiguously similar names.The
simname
,halo_finder
,version_name
andredshift
keyword arguments fully specify the halo catalog that will be loaded. Omitting any of them will select the corresponding default value set in thesim_defaults
module.>>> halocat = CachedHaloCatalog(redshift = 1, simname = 'multidark')
If you forget which catalogs you have stored in cache, you have two options for how to remind yourself. First, you can use the
HaloTableCache
class:>>> from halotools.sim_manager import HaloTableCache >>> cache = HaloTableCache() >>> for entry in cache.log: print(entry)
Alternatively, you can simply use a text editor to open the cache log, which is stored as ASCII data in the following location on your machine:
$HOME/.astropy/cache/halotools/halo_table_cache_log.txt
Attributes Summary
Astropy
Table
object storing a catalog of dark matter halos.Astropy
Table
object storing a collection of ~1e6 randomly selected dark matter particles.Attributes Documentation
- acceptable_kwargs = ('ptcl_version_name', 'fname', 'simname', 'halo_finder', 'redshift', 'version_name', 'dz_tol', 'update_cached_fname', 'preload_halo_table')¶
- halo_table¶
Astropy
Table
object storing a catalog of dark matter halos.You can access the array storing, say, halo virial mass using the following syntax:
>>> halocat = CachedHaloCatalog() >>> mass_array = halocat.halo_table['halo_mvir']
To see what halo properties are available in the catalog:
>>> print(halocat.halo_table.keys())