16 #ifndef BORNAGAIN_DEVICE_HISTO_IHISTOGRAM_H
17 #define BORNAGAIN_DEVICE_HISTO_IHISTOGRAM_H
41 virtual size_t rank()
const = 0;
96 double binContent(
size_t binx,
size_t biny)
const;
108 double binError(
size_t binx,
size_t biny)
const;
114 double binAverage(
size_t binx,
size_t biny)
const;
135 void scale(
double value);
143 #ifdef BORNAGAIN_PYTHON
Defines class CumulativeValue.
Defines and implements templated 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.
double binError(size_t i) const
Returns error of the bin with given index.
const IAxis & yAxis() const
returns y-axis for 2D histograms
double yAxisValue(size_t i)
Returns the center of bin i of the y 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.
const IAxis & xAxis() const
returns x-axis
double binData(size_t i, DataType dataType) const
returns data of requested type for globalbin number
double getMinimum() const
Returns histogram minimum value (minimum of binContent() over all bins)
virtual size_t rank() const =0
Returns number of histogram dimensions.
const OutputData< CumulativeValue > & getData() const
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: *...
void check_x_axis() const
double getXmin() const
Returns x-axis min (lower edge of first bin).
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
OutputData< CumulativeValue > m_data
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).
size_t yAxisIndex(size_t i) const
Returns y-axis index for global bin index i.
IHistogram * relativeDifferenceHistogram(const IHistogram &rhs)
returns histogram representing relative difference of two histograms.
double xAxisValue(size_t i)
Returns the center of bin i of the x axis.
void check_y_axis() const
double binContent(size_t i) const
Returns content (accumulated value) of bin i.
size_t getTotalNumberOfBins() const
Returns total number of histogram bins.
size_t getMaximumBinIndex() const
Returns globalbin index with maximum content.
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 binContent() over all bins)
void save(const std::string &filename)
Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt....
double binAverage(size_t i) const
Returns average value in the bin with given index.
int binNumberOfEntries(size_t i) const
Returns number of entries in the bin with given index.
virtual IHistogram * clone() const =0
virtual ~IHistogram()=default
void reset()
Reset histogram content (axes remains)
static IHistogram * createHistogram(const OutputData< double > &source)
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.
const IHistogram & operator+=(const IHistogram &right)
addition-assignment operator for two histograms
void init_from_data(const OutputData< double > &source)
size_t xAxisIndex(size_t i) const
Returns x-axis index for global bin index i.
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")