BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Histogram2D Class Reference

Two dimensional histogram. More...

+ Inheritance diagram for Histogram2D:

Public Member Functions

 Histogram2D (const IAxis &axis_x, const IAxis &axis_y)
 Constructor for 2D histogram with custom axes.
 
 Histogram2D (const OutputData< double > &data)
 Constructor for 2D histograms from basic OutputData object.
 
 Histogram2D (int nbinsx, const std::vector< double > &xbins, int nbinsy, const std::vector< double > &ybins)
 Constructor for variable bin size histograms. More...
 
 Histogram2D (int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup)
 Constructor for fix bin size histograms. More...
 
 Histogram2D (std::vector< std::vector< double >> data)
 Constructor for 2D histograms from numpy array (thanks to swig)
 
void addContent (const std::vector< std::vector< double >> &data)
 Add to values in histograms channels from numpy array,.
 
Histogram2D * clone () const
 Returns clone of other histogram.
 
Histogram2D * crop (double xmin, double ymin, double xmax, double ymax)
 Creates new histogram by applying rectangular clip.
 
int fill (double x, double y, double weight=1.0)
 Increment bin with abscissa x and ordinate y with a weight.
 
Histogram1D * projectionX ()
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1D * projectionX (double ylow, double yup)
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1D * projectionX (double yvalue)
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1D * projectionY ()
 Project a 2D histogram into 1D histogram along Y. More...
 
Histogram1D * projectionY (double xlow, double xup)
 Project a 2D histogram into 1D histogram along Y. More...
 
Histogram1D * projectionY (double xvalue)
 Project a 2D histogram into 1D histogram along Y. More...
 
size_t rank () const
 Returns the number of histogram dimensions.
 
void setContent (const std::vector< std::vector< double >> &data)
 Sets the values in histograms channels from numpy array,.
 

Protected Member Functions

Histogram1D * create_projectionX (int ybinlow, int ybinup)
 Creates projection along X. More...
 
Histogram1D * create_projectionY (int xbinlow, int xbinup)
 Creates projection along Y. More...
 
template<typename T >
void initFromShape (const T &data)
 

Detailed Description

Two dimensional histogram.

Constructor & Destructor Documentation

◆ Histogram2D() [1/2]

Histogram2D::Histogram2D ( int  nbinsx,
double  xlow,
double  xup,
int  nbinsy,
double  ylow,
double  yup 
)

Constructor for fix bin size histograms.

Parameters
nbinsxnumber of bins on X-axis
xlowlow edge of the first bin of X-axis
xupupper edge of the last bin of X-axis
nbinsynumber of bins on Y axis
ylowlow edge of the first bin of Y-axis
yupupper edge of the last bin of Y-axis

◆ Histogram2D() [2/2]

Histogram2D::Histogram2D ( int  nbinsx,
const std::vector< double > &  xbins,
int  nbinsy,
const std::vector< double > &  ybins 
)

Constructor for variable bin size histograms.

Parameters
nbinsxnumber of bins on X-axis
xbinsArray of size nbins+1 containing low-edges for each bin and upper edge of last bin.
nbinsynumber of bins on Y-axis
ybinsArray of size nbins+1 containing low-edges for each bin and upper edge of last bin.

Member Function Documentation

◆ create_projectionX()

Histogram1D * Histogram2D::create_projectionX ( int  ybinlow,
int  ybinup 
)
protected

Creates projection along X.

The projections is made by collecting the data in the range between [ybinlow, ybinup].

◆ create_projectionY()

Histogram1D * Histogram2D::create_projectionY ( int  xbinlow,
int  xbinup 
)
protected

Creates projection along Y.

The projections is made by collecting the data in the range between [xbinlow, xbinup].

◆ projectionX() [1/3]

Histogram1D * Histogram2D::projectionX ( )

Project a 2D histogram into 1D histogram along X.

The projection is made from all bins along y-axis.

◆ projectionX() [2/3]

Histogram1D * Histogram2D::projectionX ( double  ylow,
double  yup 
)

Project a 2D histogram into 1D histogram along X.

The projection is made from all y-bins corresponding to ordinate between ylow and yup.

Parameters
ylowlower edje on y-axis
yupupper edje on y-axis

◆ projectionX() [3/3]

Histogram1D * Histogram2D::projectionX ( double  yvalue)

Project a 2D histogram into 1D histogram along X.

The projection is made from the y-bin closest to given ordinate yvalue.

Parameters
yvaluethe value on y-axis at which projection is taken

◆ projectionY() [1/3]

Histogram1D * Histogram2D::projectionY ( )

Project a 2D histogram into 1D histogram along Y.

The projection is made from all bins along x-axis.

◆ projectionY() [2/3]

Histogram1D * Histogram2D::projectionY ( double  xlow,
double  xup 
)

Project a 2D histogram into 1D histogram along Y.

The projection is made from all x-bins corresponding to abscissa between xlow and xup.

Parameters
xlowlower edje on x-axis
xupupper edje on x-axis

◆ projectionY() [3/3]

Histogram1D * Histogram2D::projectionY ( double  xvalue)

Project a 2D histogram into 1D histogram along Y.

The projection is made from the x-bin closest to given abscissa xvalue.

Parameters
xvaluethe value on x-axis at which projection is taken