38 space(space), scheme(scheme) {}
41 params.space, params.binning
48 this->dbin_pad_config = (1 + 5.e-3)
50 / *std::min_element(params.
ngrid, params.
ngrid + 3);
51 this->dbin_pad_fourier = (1 + 5.e-3)
59 "Bin range must be non-negative."
64 "Number of bins must be positive."
81 this->compute_binning();
89 double bin_width = 0.;
90 if (this->
space ==
"config") {
91 bin_width = boxsize_max / double(ngrid_min);
92 this->
bin_max = boxsize_max / 2.;
94 if (this->
space ==
"fourier") {
95 bin_width = 2*M_PI / boxsize_max;
96 this->
bin_max = M_PI * double(ngrid_min) / boxsize_max;
98 this->
bin_max += bin_width / 2.;
107 this->compute_binning();
111 this->
bin_min = bin_edges.front();
112 this->
bin_max = bin_edges.back();
113 this->
num_bins = bin_edges.size() - 1;
116 this->bin_edges.clear();
123 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
124 double centre = (this->bin_edges[ibin] + this->bin_edges[ibin + 1]) / 2.;
125 double width = this->bin_edges[ibin + 1] - this->bin_edges[ibin];
132void Binning::compute_binning() {
135 if (this->
space ==
"fourier") {
136 dbin_pad = this->dbin_pad_fourier;
138 if (this->
space ==
"config") {
139 dbin_pad = this->dbin_pad_config;
150 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
151 double edge_left = this->
bin_min + dbin * ibin;
152 double centre = edge_left + dbin / 2.;
166 "Cannot use logarithmic binning when the lowest edge is zero."
170 double dlnbin = (std::log(this->
bin_max) - std::log(this->
bin_min))
171 /
double(this->num_bins);
173 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
174 double edge_left = this->
bin_min * std::exp(dlnbin * ibin);
175 double edge_right = this->
bin_min * std::exp(dlnbin * (ibin + 1));
176 double centre = (edge_left + edge_right) / 2.;
180 this->
bin_widths.push_back(edge_right - edge_left);
188 for (
int ibin = 0; ibin < this->nbin_pad; ibin++) {
189 double edge_left = dbin_pad * ibin;
190 double centre = edge_left + dbin_pad / 2.;
197 double bin_min = dbin_pad * this->nbin_pad;
200 /
double(this->num_bins - this->nbin_pad);
202 for (
int ibin = this->nbin_pad; ibin < this->
num_bins; ibin++) {
203 double edge_left =
bin_min + dbin * (ibin - this->nbin_pad);
204 double centre = edge_left + dbin / 2.;
216 for (
int ibin = 0; ibin < this->nbin_pad; ibin++) {
217 double edge_left = dbin_pad * ibin;
218 double centre = edge_left + dbin_pad / 2.;
225 double bin_min = dbin_pad * this->nbin_pad;
228 /
double(this->num_bins - this->nbin_pad);
230 for (
int ibin = this->nbin_pad; ibin < this->
num_bins; ibin++) {
232 bin_min * std::exp(dlnbin * (ibin - this->nbin_pad));
234 bin_min * std::exp(dlnbin * (ibin - this->nbin_pad + 1));
235 double centre = (edge_left + edge_right) / 2.;
239 this->
bin_widths.push_back(edge_right - edge_left);
244 "Unrecognised/unsupported binning `scheme`: %s.",
scheme.c_str()
Isotropic coordinate binning.
std::vector< double > bin_widths
bin widths
std::vector< double > bin_edges
bin edges
Binning(std::string space, std::string scheme)
Construct binnng from bin specification.
std::vector< double > bin_centres
bin centres
std::string scheme
binning scheme
double bin_min
lowest bin edge
std::string space
coordinate space
double bin_max
highest bin edge
int num_bins
number of bins
double bin_min
measurement range minimum (in Mpc/h or h/Mpc)
int num_bins
number of measurement bins
int ngrid[3]
grid number in each dimension
double boxsize[3]
box size (in Mpc/h) in each dimension
double bin_max
measurement range maximum (in Mpc/h or h/Mpc)
Exception raised when parameters are invalid.
Clustering measurement data objects.