15 #ifndef BORNAGAIN_CORE_INTENSITY_IHISTOGRAM_H
16 #define BORNAGAIN_CORE_INTENSITY_IHISTOGRAM_H
29 enum DataType { INTEGRAL, AVERAGE, STANDARD_ERROR, NENTRIES };
108 double getBinError(
size_t binx,
size_t biny)
const;
135 void scale(
double value);
143 #ifdef BORNAGAIN_PYTHON
145 PyObject*
array(DataType dataType = DataType::INTEGRAL)
const;
148 PyObject*
getArray(DataType dataType = DataType::INTEGRAL)
const;
187 void check_x_axis()
const;
188 void check_y_axis()
const;
190 double getBinData(
size_t i, DataType dataType)
const;
Defines class CumulativeValue.
Defines and implements template class OutputData.
One dimensional histogram.
Interface for one-dimensional axes.
Base class for 1D and 2D histograms holding values of double type.
double getYmin() const
Returns y-axis min (lower edge of first bin) for 2D histograms.
void addBinContent(size_t i, double value)
Add the value to the bin.
double getYmax() const
Returns y-axis max (upper edge of last bin) for 2D histograms.
void scale(double value)
Multiply this histogram (every bin content value) by a constant.
size_t findGlobalBin(double x, double y) const
Returns closest global bin index for given axes coordinates.
size_t getNbinsY() const
Returns number of bins on y-axis.
size_t getNbinsX() const
Returns number of bins on x-axis.
PyObject * getArray(DataType dataType=DataType::INTEGRAL) const
PyObject * array(DataType dataType=DataType::INTEGRAL) const
Returns numpy array with bin content (accumulated values).
size_t getGlobalBin(size_t binx, size_t biny=0) const
Returns global bin index for given axes indices. For 1D, just returns binx.
virtual size_t getRank() const =0
Returns number of histogram dimensions.
double getMinimum() const
Returns histogram minimum value (minimum of getBinContent() over all bins)
size_t getMinimumBinIndex() const
Returns globalbin index with minimum content.
void load(const std::string &filename)
Loads histogram from file, the shape of array in file should match Following formats are available: *...
double getBinData(size_t i, DataType dataType) const
returns data of requested type for globalbin number
double getXmin() const
Returns x-axis min (lower edge of first bin).
double getYaxisValue(size_t i)
Returns the center of bin i of the y axis.
OutputData< double > * createOutputData(DataType dataType=DataType::INTEGRAL) const
creates new OutputData with histogram's shape and values corresponding to DataType
std::vector< double > getDataVector(DataType dataType) const
returns vector of values of requested DataType
static IHistogram * createFrom(const std::string &filename)
create new histogram from file content
void setBinContent(size_t i, double value)
Sets content of the bin corresponding to the globalbin number.
double integral() const
Returns integral of bins content (computed as a sum of all bin content).
double getBinContent(size_t i) const
Returns content (accumulated value) of bin i.
IHistogram * relativeDifferenceHistogram(const IHistogram &rhs)
returns histogram representing relative difference of two histograms.
size_t getYaxisIndex(size_t i) const
Returns y-axis index for global bin index i.
size_t getTotalNumberOfBins() const
Returns total number of histogram bins.
size_t getMaximumBinIndex() const
Returns globalbin index with maximum content.
size_t getXaxisIndex(size_t i) const
Returns x-axis index for global bin index i.
void copyContentFrom(const IHistogram &other)
Copy content (but not the axes) from other histogram. Dimensions should be the same.
double getMaximum() const
Returns histogram maximum value (maximum of getBinContent() over all bins)
void save(const std::string &filename)
Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt....
double getBinError(size_t i) const
Returns error of the bin with given index.
const IAxis & getYaxis() const
returns y-axis for 2D histograms
int getBinNumberOfEntries(size_t i) const
Returns number of entries in the bin with given index.
void reset()
Reset histogram content (axes remains)
double getBinAverage(size_t i) const
Returns average value in the bin with given index.
double getXmax() const
Returns x-axis max (upper edge of last bin).
bool hasSameDimensions(const IHistogram &other) const
Returns true if object have same rank and number of axes bins.
bool hasSameShape(const IHistogram &other) const
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.
double getXaxisValue(size_t i)
Returns the center of bin i of the x axis.
const IHistogram & operator+=(const IHistogram &right)
addition-assignment operator for two histograms
const IAxis & getXaxis() const
returns x-axis
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")