nbodykit.source.catalog.species

Functions

check_species_metadata(name, attrs, species) Check to see if there is a single value for
split_column(col, species) Split the column name of the form ‘species/name’

Classes

MultipleSpeciesCatalog(names, *species, **kwargs) A CatalogSource interface for handling multiples species of particles.
class nbodykit.source.catalog.species.MultipleSpeciesCatalog(names, *species, **kwargs)[source]

A CatalogSource interface for handling multiples species of particles.

This CatalogSource stores a copy of the original CatalogSource objects for each species, providing access to the columns via the format species/ where “species” is one of the species names provided.

Parameters:
  • names (list of str) – list of strings specifying the names of the various species; data columns are prefixed with “species/” where “species” is in names
  • *species (two or more CatalogSource objects) – catalogs to be combined into a single catalog, which give the data for different species of particles; as many catalogs as names must be provided
  • use_cache (bool, optional) – whether to cache data when reading; default is True

Examples

Initialization:

>>> data = UniformCatalog(nbar=3e-5, BoxSize=512., seed=42)
>>> randoms = UniformCatalog(nbar=3e-5, BoxSize=512., seed=84)
>>> cat = MultipleSpeciesCatalog(['data', 'randoms'], data, randoms)

Accessing the Catalogs for individual species:

>>> data = cat["data"] # a copy of the original "data" object

Accessing individual columns:

>>> data_pos = cat["data/Position"]

Setting new columns:

>>> cat["data"]["new_column"] = 1.0
>>> assert "data/new_column" in cat

Attributes

attrs A dictionary storing relevant meta-data about the CatalogSource.
columns Columns for individual species can be accessed using a species/ prefix and the column name, i.e., data/Position.
hardcolumns Hardcolumn of the form species/name
species List of species names
use_cache If set to True, use the built-in caching features of dask to cache data in memory.

Methods

compute(*args, **kwargs) Our version of dask.compute() that computes multiple delayed dask collections at once.
copy() Return a shallow copy of the object, where each column is a reference of the corresponding column in self.
get_hardcolumn(col) Construct and return a hard-coded column.
make_column(array) Utility function to convert an array-like object to a dask.array.Array.
read(columns) Return the requested columns as dask arrays.
save(output, columns[, datasets, header]) Save the CatalogSource to a bigfile.BigFile.
to_mesh([Nmesh, BoxSize, dtype, interlaced, …]) Convert the catalog to a mesh, which knows how to “paint” the the combined density field, summed over all particle species.
view([type]) Return a “view” of the CatalogSource object, with the returned type set by type.
__delitem__(col)[source]

Delete a column of the form species/column

__getitem__(key)[source]

This provides access to the underlying data in two ways:

  • The CatalogSource object for a species can be accessed if key is a species name.
  • Individual columns for a species can be accessed using the format: species/column.
__setitem__(col, value)[source]

Add columns to any of the species catalogs.

Note

New column names should be prefixed by ‘species/’ where ‘species’ is a name in the species attribute.

columns

Columns for individual species can be accessed using a species/ prefix and the column name, i.e., data/Position.

hardcolumns

Hardcolumn of the form species/name

species

List of species names

to_mesh(Nmesh=None, BoxSize=None, dtype='f4', interlaced=False, compensated=False, window='cic', weight='Weight', selection='Selection', value='Value', position='Position')[source]

Convert the catalog to a mesh, which knows how to “paint” the the combined density field, summed over all particle species.

Parameters:
  • Nmesh (int, 3-vector, optional) – the number of cells per box side; can be inferred from attrs if the value is the same for all species
  • BoxSize (float, 3-vector, optional) – the size of the box; can be inferred from attrs if the value is the same for all species
  • dtype (str, dtype, optional) – the data type of the mesh when painting
  • interlaced (bool, optional) – whether to use interlacing to reduce aliasing when painting the particles on the mesh
  • compensated (bool, optional) – whether to apply a Fourier-space transfer function to account for the effects of the gridding + aliasing
  • window (str, optional) – the string name of the window to use when interpolating the
  • weight (str, optional) – the name of the column specifying the weight for each particle
  • selection (str, optional) – the name of the column that specifies which (if any) slice of the CatalogSource to take
  • value (str, optional) – the name of the column specifying the field value for each particle
  • position (str, optional) – the name of the column that specifies the position data of the objects in the catalog
nbodykit.source.catalog.species.check_species_metadata(name, attrs, species)[source]

Check to see if there is a single value for name in the meta-data of all the species

nbodykit.source.catalog.species.split_column(col, species)[source]

Split the column name of the form ‘species/name’