BornAgain
1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Two dimensional histogram. More...
Public Member Functions | |
Histogram2D (int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup) | |
Constructor for fix bin size histograms. More... | |
Histogram2D (int nbinsx, const std::vector< double > &xbins, int nbinsy, const std::vector< double > &ybins) | |
Constructor for variable bin size histograms. More... | |
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 (std::vector< std::vector< double >> data) | |
Constructor for 2D histograms from numpy array (thanks to swig) | |
Histogram2D * | clone () const |
Returns clone of other histogram. | |
size_t | getRank () const |
Returns the number of histogram dimensions. | |
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 yvalue) |
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 * | projectionY () |
Project a 2D histogram into 1D histogram along Y. More... | |
Histogram1D * | projectionY (double xvalue) |
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... | |
Histogram2D * | crop (double xmin, double ymin, double xmax, double ymax) |
Creates new histogram by applying rectangular clip. | |
void | setContent (const std::vector< std::vector< double >> &data) |
Sets the values in histograms channels from numpy array,. | |
void | addContent (const std::vector< std::vector< double >> &data) |
Add to values in histograms channels from numpy array,. | |
Public Member Functions inherited from IHistogram | |
IHistogram (const IHistogram &other) | |
IHistogram (const IAxis &axis_x) | |
IHistogram (const IAxis &axis_x, const IAxis &axis_y) | |
size_t | getTotalNumberOfBins () const |
Returns total number of histogram bins. More... | |
const IAxis & | getXaxis () const |
returns x-axis | |
const IAxis & | getYaxis () const |
returns y-axis for 2D histograms | |
double | getXmin () const |
Returns x-axis min (lower edge of first bin). | |
double | getXmax () const |
Returns x-axis max (upper edge of last bin). | |
size_t | getNbinsX () const |
Returns number of bins on x-axis. | |
double | getYmin () const |
Returns y-axis min (lower edge of first bin) for 2D histograms. | |
double | getYmax () const |
Returns y-axis max (upper edge of last bin) for 2D histograms. | |
size_t | getNbinsY () const |
Returns number of bins on y-axis. | |
size_t | getGlobalBin (size_t binx, size_t biny=0) const |
Returns global bin index for given axes indices. For 1D, just returns binx. | |
size_t | findGlobalBin (double x, double y) const |
Returns closest global bin index for given axes coordinates. | |
size_t | getXaxisIndex (size_t i) const |
Returns x-axis index for global bin index i. | |
size_t | getYaxisIndex (size_t i) const |
Returns y-axis index for global bin index i. | |
double | getXaxisValue (size_t i) |
Returns the center of bin i of the x axis. | |
double | getYaxisValue (size_t i) |
Returns the center of bin i of the y axis. | |
double | getBinContent (size_t i) const |
Returns content (accumulated value) of bin i. | |
const OutputData< CumulativeValue > & | getData () const |
OutputData< CumulativeValue > & | getData () |
double | getBinContent (size_t binx, size_t biny) const |
Returns content (accumulated value) of the 2D histogram bin. | |
void | setBinContent (size_t i, double value) |
Sets content of the bin corresponding to the globalbin number. | |
void | addBinContent (size_t i, double value) |
Add the value to the bin. | |
double | getBinError (size_t i) const |
Returns error of the bin with given index. | |
double | getBinError (size_t binx, size_t biny) const |
Returns error of the bin with given indices (for 2D histograms). | |
double | getBinAverage (size_t i) const |
Returns average value in the bin with given index. | |
double | getBinAverage (size_t binx, size_t biny) const |
Returns average value of the bin with given indices (for 2D histograms). | |
int | getBinNumberOfEntries (size_t i) const |
Returns number of entries in the bin with given index. | |
int | getBinNumberOfEntries (size_t binx, size_t biny) const |
Returns number of entries in the bin with given indices (for 2D histograms). | |
double | getMaximum () const |
Returns histogram maximum value (maximum of getBinContent() over all bins) | |
size_t | getMaximumBinIndex () const |
Returns globalbin index with maximum content. | |
double | getMinimum () const |
Returns histogram minimum value (minimum of getBinContent() over all bins) | |
size_t | getMinimumBinIndex () const |
Returns globalbin index with minimum content. | |
void | scale (double value) |
Multiply this histogram (every bin content value) by a constant. | |
double | integral () const |
Returns integral of bins content (computed as a sum of all bin content). | |
PyObject * | array (DataType dataType=DataType::INTEGRAL) const |
Returns numpy array with bin content (accumulated values). | |
PyObject * | getArray (DataType dataType=DataType::INTEGRAL) const |
void | reset () |
Reset histogram content (axes remains) | |
OutputData< double > * | createOutputData (DataType dataType=DataType::INTEGRAL) const |
creates new OutputData with histogram's shape and values corresponding to DataType More... | |
bool | hasSameShape (const IHistogram &other) const |
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide. | |
bool | hasSameDimensions (const IHistogram &other) const |
Returns true if object have same rank and number of axes bins. | |
const IHistogram & | operator+= (const IHistogram &right) |
addition-assignment operator for two histograms | |
IHistogram * | relativeDifferenceHistogram (const IHistogram &rhs) |
returns histogram representing relative difference of two histograms. | |
void | save (const std::string &filename) |
Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) | |
void | load (const std::string &filename) |
Loads histogram from file, the shape of array in file should match Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) Only bin content will be loaded, histogram axes remain the same. | |
Protected Member Functions | |
template<typename T > | |
void | initFromShape (const T &data) |
Histogram1D * | create_projectionX (int ybinlow, int ybinup) |
Creates projection along X. More... | |
Histogram1D * | create_projectionY (int xbinlow, int xbinup) |
Creates projection along Y. More... | |
Protected Member Functions inherited from IHistogram | |
void | check_x_axis () const |
void | check_y_axis () const |
void | init_from_data (const OutputData< double > &source) |
double | getBinData (size_t i, DataType dataType) const |
returns data of requested type for globalbin number | |
std::vector< double > | getDataVector (DataType dataType) const |
returns vector of values of requested DataType | |
void | copyContentFrom (const IHistogram &other) |
Copy content (but not the axes) from other histogram. Dimensions should be the same. | |
Additional Inherited Members | |
Public Types inherited from IHistogram | |
enum | DataType { INTEGRAL , AVERAGE , STANDARD_ERROR , NENTRIES } |
Static Public Member Functions inherited from IHistogram | |
static IHistogram * | createHistogram (const OutputData< double > &source) |
static IHistogram * | createFrom (const std::string &filename) |
create new histogram from file content | |
static IHistogram * | createFrom (const std::vector< std::vector< double >> &data) |
create new histogram from numpy array | |
Protected Attributes inherited from IHistogram | |
OutputData< CumulativeValue > | m_data |
Two dimensional histogram.
Definition at line 24 of file Histogram2D.h.
Histogram2D::Histogram2D | ( | int | nbinsx, |
double | xlow, | ||
double | xup, | ||
int | nbinsy, | ||
double | ylow, | ||
double | yup | ||
) |
Constructor for fix bin size histograms.
nbinsx | number of bins on X-axis |
xlow | low edge of the first bin of X-axis |
xup | upper edge of the last bin of X-axis |
nbinsy | number of bins on Y axis |
ylow | low edge of the first bin of Y-axis |
yup | upper edge of the last bin of Y-axis |
Definition at line 20 of file Histogram2D.cpp.
Histogram2D::Histogram2D | ( | int | nbinsx, |
const std::vector< double > & | xbins, | ||
int | nbinsy, | ||
const std::vector< double > & | ybins | ||
) |
Constructor for variable bin size histograms.
nbinsx | number of bins on X-axis |
xbins | Array of size nbins+1 containing low-edges for each bin and upper edge of last bin. |
nbinsy | number of bins on Y-axis |
ybins | Array of size nbins+1 containing low-edges for each bin and upper edge of last bin. |
Definition at line 26 of file Histogram2D.cpp.
Histogram1D * Histogram2D::projectionX | ( | ) |
Project a 2D histogram into 1D histogram along X.
The projection is made from all bins along y-axis.
Definition at line 63 of file Histogram2D.cpp.
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.
yvalue | the value on y-axis at which projection is taken |
Definition at line 68 of file Histogram2D.cpp.
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.
ylow | lower edje on y-axis |
yup | upper edje on y-axis |
Definition at line 74 of file Histogram2D.cpp.
Histogram1D * Histogram2D::projectionY | ( | ) |
Project a 2D histogram into 1D histogram along Y.
The projection is made from all bins along x-axis.
Definition at line 81 of file Histogram2D.cpp.
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.
xvalue | the value on x-axis at which projection is taken |
Definition at line 86 of file Histogram2D.cpp.
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.
xlow | lower edje on x-axis |
xup | upper edje on x-axis |
Definition at line 92 of file Histogram2D.cpp.
|
protected |
Creates projection along X.
The projections is made by collecting the data in the range between [ybinlow, ybinup].
Definition at line 148 of file Histogram2D.cpp.
|
protected |
Creates projection along Y.
The projections is made by collecting the data in the range between [xbinlow, xbinup].
Definition at line 163 of file Histogram2D.cpp.