15 #ifndef BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
16 #define BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
33 Histogram2D(
int nbinsx,
double xlow,
double xup,
int nbinsy,
double ylow,
double yup);
42 Histogram2D(
int nbinsx,
const std::vector<double>& xbins,
int nbinsy,
43 const std::vector<double>& ybins);
58 size_t rank()
const {
return 2; }
61 int fill(
double x,
double y,
double weight = 1.0);
97 void setContent(
const std::vector<std::vector<double>>& data);
100 void addContent(
const std::vector<std::vector<double>>& data);
117 const size_t nrows = shape.first;
118 const size_t ncols = shape.second;
120 if (nrows == 0 || ncols == 0)
121 throw std::runtime_error(
"Histogram2D::Histogram2D() -> Error. "
122 "Not a two-dimensional numpy array");
Defines various functions to interact from numpy on Python side.
Defines interface IHistogram.
Axis with fixed bin size.
One dimensional histogram.
Two dimensional histogram.
Histogram1D * create_projectionY(int xbinlow, int xbinup)
Creates projection along Y.
void setContent(const std::vector< std::vector< double >> &data)
Sets the values in histograms channels from numpy array,.
int fill(double x, double y, double weight=1.0)
Increment bin with abscissa x and ordinate y with a weight.
void addContent(const std::vector< std::vector< double >> &data)
Add to values in histograms channels from numpy array,.
size_t rank() const
Returns the number of histogram dimensions.
Histogram1D * projectionY()
Project a 2D histogram into 1D histogram along Y.
void initFromShape(const T &data)
Histogram2D * crop(double xmin, double ymin, double xmax, double ymax)
Creates new histogram by applying rectangular clip.
Histogram1D * projectionX()
Project a 2D histogram into 1D histogram along X.
Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup)
Constructor for fix bin size histograms.
Histogram1D * create_projectionX(int ybinlow, int ybinup)
Creates projection along X.
Histogram2D * clone() const
Returns clone of other histogram.
Interface for one-dimensional axes.
Base class for 1D and 2D histograms holding values of double type.
OutputData< CumulativeValue > m_data
void addAxis(const IAxis &new_axis)
std::pair< size_t, size_t > getShape(const T &data)
Returns shape nrows, ncols of 2D array.