BornAgain
1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
One dimensional histogram. More...
Public Member Functions | |
Histogram1D (int nbinsx, double xlow, double xup) | |
Constructor for fix bin size histograms. More... | |
Histogram1D (int nbinsx, const std::vector< double > &xbins) | |
Constructor for variable bin size histograms. More... | |
Histogram1D (const IAxis &axis) | |
Constructor for 1D histogram with custom axis. | |
Histogram1D (const OutputData< double > &data) | |
Constructor for 1D histograms from basic OutputData object. | |
Histogram1D * | clone () const |
Returns clone of other histogram. | |
size_t | getRank () const |
Returns the number of histogram dimensions. | |
int | fill (double x, double weight=1.0) |
Increment bin with abscissa x with a weight. | |
std::vector< double > | getBinCenters () const |
returns vector of histogram bin centers | |
std::vector< double > | getBinValues () const |
returns vector of bin content (the value accumulated by bins) | |
std::vector< double > | getBinErrors () const |
returns vector of bin errors | |
PyObject * | getBinCentersNumpy () const |
PyObject * | getBinValuesNumpy () const |
PyObject * | getBinErrorsNumpy () const |
Histogram1D * | crop (double xmin, double xmax) |
Creates new histogram by applying crop on axis. | |
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. | |
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 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. | |
Protected Attributes inherited from IHistogram | |
OutputData< CumulativeValue > | m_data |
One dimensional histogram.
Definition at line 23 of file Histogram1D.h.
Histogram1D::Histogram1D | ( | int | nbinsx, |
double | xlow, | ||
double | xup | ||
) |
Constructor for fix bin size histograms.
nbinsx | number of bins |
xlow | low edge of the first bin |
xup | upper edge of the last bin |
Definition at line 20 of file Histogram1D.cpp.
Histogram1D::Histogram1D | ( | int | nbinsx, |
const std::vector< double > & | xbins | ||
) |
Constructor for variable bin size histograms.
nbinsx | number of bins |
xbins | Array of size nbins+1 containing low-edges for each bin and upper edge of last bin. |
Definition at line 25 of file Histogram1D.cpp.