43 params.
space, params.binning
50 this->dbin_pad_config = (1 + 5.e-3)
52 / *std::min_element(params.
ngrid, params.
ngrid + 3);
53 this->dbin_pad_fourier = (1 + 5.e-3)
61 "Bin range must be non-negative."
66 "Number of bins must be positive."
83 this->compute_binning();
91 double bin_width = 0.;
92 if (this->
space ==
"config") {
93 bin_width = boxsize_max / double(ngrid_min);
94 this->
bin_max = boxsize_max / 2.;
96 if (this->
space ==
"fourier") {
97 bin_width = 2*M_PI / boxsize_max;
98 this->
bin_max = M_PI * double(ngrid_min) / boxsize_max;
100 this->
bin_max += bin_width / 2.;
109 this->compute_binning();
118 this->bin_edges.clear();
125 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
126 double centre = (this->bin_edges[ibin] + this->bin_edges[ibin + 1]) / 2.;
127 double width = this->bin_edges[ibin + 1] - this->bin_edges[ibin];
134void Binning::compute_binning() {
137 if (this->
space ==
"fourier") {
138 dbin_pad = this->dbin_pad_fourier;
140 if (this->
space ==
"config") {
141 dbin_pad = this->dbin_pad_config;
152 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
153 double edge_left = this->
bin_min + dbin * ibin;
154 double centre = edge_left + dbin / 2.;
167 throw trvs::InvalidParameterError(
168 "Cannot use logarithmic binning when the lowest edge is zero."
172 double dlnbin = (std::log(this->
bin_max) - std::log(this->
bin_min))
175 for (
int ibin = 0; ibin < this->
num_bins; ibin++) {
176 double edge_left = this->
bin_min * std::exp(dlnbin * ibin);
177 double edge_right = this->
bin_min * std::exp(dlnbin * (ibin + 1));
178 double centre = (edge_left + edge_right) / 2.;
182 this->
bin_widths.push_back(edge_right - edge_left);
190 for (
int ibin = 0; ibin < this->nbin_pad; ibin++) {
191 double edge_left = dbin_pad * ibin;
192 double centre = edge_left + dbin_pad / 2.;
199 double bin_min = dbin_pad * this->nbin_pad;
202 /
double(this->
num_bins - this->nbin_pad);
204 for (
int ibin = this->nbin_pad; ibin < this->
num_bins; ibin++) {
205 double edge_left =
bin_min + dbin * (ibin - this->nbin_pad);
206 double centre = edge_left + dbin / 2.;
218 for (
int ibin = 0; ibin < this->nbin_pad; ibin++) {
219 double edge_left = dbin_pad * ibin;
220 double centre = edge_left + dbin_pad / 2.;
227 double bin_min = dbin_pad * this->nbin_pad;
230 /
double(this->
num_bins - this->nbin_pad);
232 for (
int ibin = this->nbin_pad; ibin < this->
num_bins; ibin++) {
234 bin_min * std::exp(dlnbin * (ibin - this->nbin_pad));
236 bin_min * std::exp(dlnbin * (ibin - this->nbin_pad + 1));
237 double centre = (edge_left + edge_right) / 2.;
241 this->
bin_widths.push_back(edge_right - edge_left);
245 throw trvs::InvalidParameterError(
246 "Unrecognised/unsupported binning `scheme`: %s.",
scheme.c_str()
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 cell 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.