Several nbodykit algorithms compute binned clustering statistics
and store the results as a BinnedStatistic
object (see a list
of these algorithms here. In this section,
we provide an overview of some of the functionality of this class to help
users better analyze their algorithm results.
The BinnedStatistic
class is designed to hold data variables at
fixed coordinates, i.e., a grid of \((r, \mu)\) or \((k, \mu)\) bins
and is modeled after the syntax of the xarray.Dataset
object.
A BinnedStatistic
object is serialized to disk using a
JSON format. The to_json()
and
from_json()
functions can be used to save and load
BinnedStatistic
objects. respectively.
To start, we read two BinnedStatistic
results from JSON files,
one holding 1D power measurement \(P(k)\) and one holding a 2D power
measurement \(P(k,\mu)\).
In [1]: from nbodykit.binned_statistic import BinnedStatistic
In [2]: power_1d = BinnedStatistic.from_json(os.path.join(data_dir, 'dataset_1d.json'))
In [3]: power_2d = BinnedStatistic.from_json(os.path.join(data_dir, 'dataset_2d.json'))
The clustering statistics are measured for fixed bins, and the
BinnedStatistic
class has several attributes to access the
coordinate grid defined by these bins:
shape
: the shape of the coordinate griddims
: the names of each dimension of the coordinate gridcoords
: a dictionary that gives the center bin values for each dimension of the gridedges
: a dictionary giving the edges of the bins for each coordinate dimensionIn [4]: print(power_1d.shape, power_2d.shape)
(64,) (64, 5)
In [5]: print(power_1d.dims, power_2d.dims)