BornAgain
1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Public Types | |
enum | DataType { INTEGRAL , AVERAGE , STANDARD_ERROR , NENTRIES } |
Public Member Functions | |
Histogram1D (int nbinsx, double xlow, double xup) | |
Histogram1D (int nbinsx, const std::vector< double > &xbins) | |
Histogram1D (const IAxis &axis) | |
Histogram1D (const OutputData< double > &data) | |
Histogram1D * | clone () const |
size_t | getRank () const |
int | fill (double x, double weight=1.0) |
std::vector< double > | getBinCenters () const |
std::vector< double > | getBinValues () const |
std::vector< double > | getBinErrors () const |
PyObject * | getBinCentersNumpy () const |
PyObject * | getBinValuesNumpy () const |
PyObject * | getBinErrorsNumpy () const |
Histogram1D * | crop (double xmin, double xmax) |
size_t | getTotalNumberOfBins () const |
const IAxis & | getXaxis () const |
const IAxis & | getYaxis () const |
double | getXmin () const |
double | getXmax () const |
size_t | getNbinsX () const |
double | getYmin () const |
double | getYmax () const |
size_t | getNbinsY () const |
size_t | getGlobalBin (size_t binx, size_t biny=0) const |
size_t | findGlobalBin (double x, double y) const |
size_t | getXaxisIndex (size_t i) const |
size_t | getYaxisIndex (size_t i) const |
double | getXaxisValue (size_t i) |
double | getYaxisValue (size_t i) |
double | getBinContent (size_t i) const |
double | getBinContent (size_t binx, size_t biny) const |
const OutputData< CumulativeValue > & | getData () const |
OutputData< CumulativeValue > & | getData () |
void | setBinContent (size_t i, double value) |
void | addBinContent (size_t i, double value) |
double | getBinError (size_t i) const |
double | getBinError (size_t binx, size_t biny) const |
double | getBinAverage (size_t i) const |
double | getBinAverage (size_t binx, size_t biny) const |
int | getBinNumberOfEntries (size_t i) const |
int | getBinNumberOfEntries (size_t binx, size_t biny) const |
double | getMaximum () const |
size_t | getMaximumBinIndex () const |
double | getMinimum () const |
size_t | getMinimumBinIndex () const |
void | scale (double value) |
double | integral () const |
PyObject * | array (DataType dataType=DataType::INTEGRAL) const |
PyObject * | getArray (DataType dataType=DataType::INTEGRAL) const |
void | reset () |
OutputData< double > * | createOutputData (DataType dataType=DataType::INTEGRAL) const |
bool | hasSameShape (const IHistogram &other) const |
bool | hasSameDimensions (const IHistogram &other) const |
const IHistogram & | operator+= (const IHistogram &right) |
IHistogram * | relativeDifferenceHistogram (const IHistogram &rhs) |
void | save (const std::string &filename) |
void | load (const std::string &filename) |
Static Public Member Functions | |
static IHistogram * | createHistogram (const OutputData< double > &source) |
static IHistogram * | createFrom (const std::string &filename) |
static IHistogram * | createFrom (const std::vector< std::vector< double >> &data) |
Protected Member Functions | |
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 |
std::vector< double > | getDataVector (DataType dataType) const |
void | copyContentFrom (const IHistogram &other) |
Protected Attributes | |
OutputData< CumulativeValue > | m_data |
One dimensional histogram.
Definition at line 23 of file Histogram1D.h.
|
inherited |
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.
References OutputData< T >::addAxis(), and IHistogram::m_data.
Referenced by clone(), and crop().
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.
References OutputData< T >::addAxis(), and IHistogram::m_data.
Histogram1D::Histogram1D | ( | const IAxis & | axis | ) |
Constructor for 1D histogram with custom axis.
Definition at line 30 of file Histogram1D.cpp.
Histogram1D::Histogram1D | ( | const OutputData< double > & | data | ) |
Constructor for 1D histograms from basic OutputData object.
Definition at line 32 of file Histogram1D.cpp.
References IHistogram::init_from_data().
|
virtual |
Returns clone of other histogram.
Implements IHistogram.
Definition at line 37 of file Histogram1D.cpp.
References Histogram1D().
|
inlinevirtual |
Returns the number of histogram dimensions.
Implements IHistogram.
Definition at line 48 of file Histogram1D.h.
int Histogram1D::fill | ( | double | x, |
double | weight = 1.0 |
||
) |
Increment bin with abscissa x with a weight.
Definition at line 42 of file Histogram1D.cpp.
References IAxis::findClosestIndex(), IAxis::getMax(), IAxis::getMin(), IHistogram::getXaxis(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionX(), and Histogram2D::create_projectionY().
std::vector< double > Histogram1D::getBinCenters | ( | ) | const |
returns vector of histogram bin centers
Definition at line 52 of file Histogram1D.cpp.
References IAxis::getBinCenters(), and IHistogram::getXaxis().
Referenced by getBinCentersNumpy().
std::vector< double > Histogram1D::getBinValues | ( | ) | const |
returns vector of bin content (the value accumulated by bins)
Definition at line 57 of file Histogram1D.cpp.
References IHistogram::getDataVector().
Referenced by getBinValuesNumpy().
std::vector< double > Histogram1D::getBinErrors | ( | ) | const |
returns vector of bin errors
Definition at line 62 of file Histogram1D.cpp.
References IHistogram::getDataVector().
Referenced by getBinErrorsNumpy().
PyObject * Histogram1D::getBinCentersNumpy | ( | ) | const |
Definition at line 69 of file Histogram1D.cpp.
References ArrayUtils::createNumpyArray(), and getBinCenters().
PyObject * Histogram1D::getBinValuesNumpy | ( | ) | const |
Definition at line 74 of file Histogram1D.cpp.
References ArrayUtils::createNumpyArray(), and getBinValues().
PyObject * Histogram1D::getBinErrorsNumpy | ( | ) | const |
Definition at line 79 of file Histogram1D.cpp.
References ArrayUtils::createNumpyArray(), and getBinErrors().
Histogram1D * Histogram1D::crop | ( | double | xmin, |
double | xmax | ||
) |
Creates new histogram by applying crop on axis.
Definition at line 86 of file Histogram1D.cpp.
References OutputData< T >::begin(), IAxis::contains(), OutputData< T >::end(), OutputData< T >::getAxisValue(), IHistogram::getXaxis(), Histogram1D(), and IHistogram::m_data.
|
inherited |
Returns total number of histogram bins.
For 2D histograms the result will be the product of bin numbers along X and Y axes.
Definition at line 39 of file IHistogram.cpp.
References OutputData< T >::getAllocatedSize(), and IHistogram::m_data.
Referenced by IHistogram::copyContentFrom(), Histogram2D::create_projectionX(), Histogram2D::create_projectionY(), IHistogram::createOutputData(), IHistogram::getDataVector(), IHistogram::integral(), IHistogram::operator+=(), IHistogram::relativeDifferenceHistogram(), and IHistogram::scale().
|
inherited |
returns x-axis
Definition at line 44 of file IHistogram.cpp.
References IHistogram::check_x_axis(), OutputData< T >::getAxis(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionX(), crop(), Histogram2D::crop(), fill(), Histogram2D::fill(), SpectrumUtils::FindPeaks(), getBinCenters(), IHistogram::getNbinsX(), IHistogram::getXmax(), IHistogram::getXmin(), Histogram2D::projectionX(), and Histogram2D::projectionY().
|
inherited |
returns y-axis for 2D histograms
Definition at line 50 of file IHistogram.cpp.
References IHistogram::check_y_axis(), OutputData< T >::getAxis(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionY(), Histogram2D::crop(), Histogram2D::fill(), SpectrumUtils::FindPeaks(), IHistogram::getNbinsY(), IHistogram::getYmax(), IHistogram::getYmin(), and Histogram2D::projectionX().
|
inherited |
Returns x-axis min (lower edge of first bin).
Definition at line 56 of file IHistogram.cpp.
References IAxis::getMin(), and IHistogram::getXaxis().
|
inherited |
Returns x-axis max (upper edge of last bin).
Definition at line 61 of file IHistogram.cpp.
References IAxis::getMax(), and IHistogram::getXaxis().
|
inherited |
Returns number of bins on x-axis.
Definition at line 66 of file IHistogram.cpp.
References IHistogram::getXaxis(), and IAxis::size().
|
inherited |
Returns y-axis min (lower edge of first bin) for 2D histograms.
Definition at line 71 of file IHistogram.cpp.
References IAxis::getMin(), and IHistogram::getYaxis().
|
inherited |
Returns y-axis max (upper edge of last bin) for 2D histograms.
Definition at line 76 of file IHistogram.cpp.
References IAxis::getMax(), and IHistogram::getYaxis().
|
inherited |
Returns number of bins on y-axis.
Definition at line 81 of file IHistogram.cpp.
References IHistogram::getYaxis(), and IAxis::size().
|
inherited |
Returns global bin index for given axes indices. For 1D, just returns binx.
Definition at line 86 of file IHistogram.cpp.
References IHistogram::getRank(), IHistogram::m_data, and OutputData< T >::toGlobalIndex().
Referenced by IHistogram::getBinAverage(), IHistogram::getBinContent(), IHistogram::getBinError(), and IHistogram::getBinNumberOfEntries().
|
inherited |
Returns closest global bin index for given axes coordinates.
Definition at line 95 of file IHistogram.cpp.
References OutputData< T >::findGlobalIndex(), IHistogram::getRank(), and IHistogram::m_data.
|
inherited |
Returns x-axis index for global bin index i.
Definition at line 104 of file IHistogram.cpp.
References OutputData< T >::getAxisBinIndex(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionY().
|
inherited |
Returns y-axis index for global bin index i.
Definition at line 109 of file IHistogram.cpp.
References OutputData< T >::getAxisBinIndex(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionX().
|
inherited |
Returns the center of bin i of the x axis.
Definition at line 114 of file IHistogram.cpp.
References IHistogram::check_x_axis(), OutputData< T >::getAxisValue(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionX().
|
inherited |
Returns the center of bin i of the y axis.
Definition at line 120 of file IHistogram.cpp.
References IHistogram::check_y_axis(), OutputData< T >::getAxisValue(), and IHistogram::m_data.
Referenced by Histogram2D::create_projectionY().
|
inherited |
Returns content (accumulated value) of bin i.
Definition at line 126 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by Histogram2D::create_projectionX(), Histogram2D::create_projectionY(), IHistogram::getBinContent(), IHistogram::getBinData(), IHistogram::operator+=(), and IHistogram::relativeDifferenceHistogram().
|
inherited |
Returns content (accumulated value) of the 2D histogram bin.
Definition at line 131 of file IHistogram.cpp.
References IHistogram::getBinContent(), and IHistogram::getGlobalBin().
|
inlineinherited |
Definition at line 92 of file IHistogram.h.
References IHistogram::m_data.
Referenced by IntensityDataFunctions::getRelativeDifference().
|
inlineinherited |
|
inherited |
Sets content of the bin corresponding to the globalbin number.
Definition at line 136 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by IHistogram::relativeDifferenceHistogram().
|
inherited |
Add the value to the bin.
Definition at line 141 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by IHistogram::operator+=().
|
inherited |
Returns error of the bin with given index.
Definition at line 146 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by IHistogram::getBinData(), and IHistogram::getBinError().
|
inherited |
Returns error of the bin with given indices (for 2D histograms).
Definition at line 151 of file IHistogram.cpp.
References IHistogram::getBinError(), and IHistogram::getGlobalBin().
|
inherited |
Returns average value in the bin with given index.
Definition at line 156 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by IHistogram::getBinAverage(), and IHistogram::getBinData().
|
inherited |
Returns average value of the bin with given indices (for 2D histograms).
Definition at line 161 of file IHistogram.cpp.
References IHistogram::getBinAverage(), and IHistogram::getGlobalBin().
|
inherited |
Returns number of entries in the bin with given index.
Definition at line 166 of file IHistogram.cpp.
References IHistogram::m_data.
Referenced by IHistogram::getBinData(), and IHistogram::getBinNumberOfEntries().
|
inherited |
Returns number of entries in the bin with given indices (for 2D histograms).
Definition at line 171 of file IHistogram.cpp.
References IHistogram::getBinNumberOfEntries(), and IHistogram::getGlobalBin().
|
inherited |
Returns histogram maximum value (maximum of getBinContent() over all bins)
Definition at line 176 of file IHistogram.cpp.
References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.
|
inherited |
Returns globalbin index with maximum content.
Definition at line 182 of file IHistogram.cpp.
References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.
|
inherited |
Returns histogram minimum value (minimum of getBinContent() over all bins)
Definition at line 188 of file IHistogram.cpp.
References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.
|
inherited |
Returns globalbin index with minimum content.
Definition at line 194 of file IHistogram.cpp.
References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.
|
inherited |
Multiply this histogram (every bin content value) by a constant.
Definition at line 199 of file IHistogram.cpp.
References IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.
|
inherited |
Returns integral of bins content (computed as a sum of all bin content).
Definition at line 206 of file IHistogram.cpp.
References IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.
Returns numpy array with bin content (accumulated values).
Definition at line 216 of file IHistogram.cpp.
References IHistogram::createOutputData().
Referenced by IHistogram::getArray().
Definition at line 222 of file IHistogram.cpp.
References IHistogram::array().
|
inherited |
Reset histogram content (axes remains)
Definition at line 228 of file IHistogram.cpp.
References IHistogram::m_data, and OutputData< T >::setAllTo().
Referenced by IHistogram::copyContentFrom(), IHistogram::relativeDifferenceHistogram(), and Histogram2D::setContent().
|
staticinherited |
Definition at line 233 of file IHistogram.cpp.
References OutputData< T >::getRank().
Referenced by DetectorMask::createHistogram(), and IntensityDataIOFactory::readIntensityData().
|
staticinherited |
create new histogram from file content
Definition at line 248 of file IHistogram.cpp.
References FileSystemUtils::filename(), and IntensityDataIOFactory::readIntensityData().
|
staticinherited |
create new histogram from numpy array
Definition at line 253 of file IHistogram.cpp.
|
inherited |
creates new OutputData with histogram's shape and values corresponding to DataType
creates new OutputData with histogram's shape and put there values corresponding to DataType
Definition at line 334 of file IHistogram.cpp.
References OutputData< T >::copyShapeFrom(), IHistogram::getBinData(), IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.
Referenced by IHistogram::array(), SpectrumUtils::FindPeaks(), and IntensityDataIOFactory::writeIntensityData().
|
inherited |
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.
Definition at line 344 of file IHistogram.cpp.
References OutputData< T >::hasSameShape(), and IHistogram::m_data.
|
inherited |
Returns true if object have same rank and number of axes bins.
Definition at line 349 of file IHistogram.cpp.
References OutputData< T >::hasSameDimensions(), and IHistogram::m_data.
Referenced by IHistogram::copyContentFrom(), IHistogram::operator+=(), and IHistogram::relativeDifferenceHistogram().
|
inherited |
addition-assignment operator for two histograms
Definition at line 354 of file IHistogram.cpp.
References IHistogram::addBinContent(), IHistogram::getBinContent(), IHistogram::getTotalNumberOfBins(), and IHistogram::hasSameDimensions().
|
inherited |
returns histogram representing relative difference of two histograms.
Definition at line 364 of file IHistogram.cpp.
References IHistogram::clone(), IHistogram::getBinContent(), Numeric::GetRelativeDifference(), IHistogram::getTotalNumberOfBins(), IHistogram::hasSameDimensions(), IHistogram::reset(), and IHistogram::setBinContent().
|
inherited |
Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz)
Definition at line 380 of file IHistogram.cpp.
References FileSystemUtils::filename(), and IntensityDataIOFactory::writeIntensityData().
|
inherited |
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.
Definition at line 385 of file IHistogram.cpp.
References IHistogram::copyContentFrom(), FileSystemUtils::filename(), and IntensityDataIOFactory::readIntensityData().
|
protectedinherited |
Definition at line 258 of file IHistogram.cpp.
References IHistogram::getRank().
Referenced by IHistogram::getXaxis(), and IHistogram::getXaxisValue().
|
protectedinherited |
Definition at line 268 of file IHistogram.cpp.
References IHistogram::getRank().
Referenced by IHistogram::getYaxis(), and IHistogram::getYaxisValue().
|
protectedinherited |
Definition at line 278 of file IHistogram.cpp.
References OutputData< T >::copyShapeFrom(), OutputData< T >::getAllocatedSize(), OutputData< T >::getRank(), IHistogram::getRank(), and IHistogram::m_data.
Referenced by Histogram1D(), and Histogram2D::Histogram2D().
|
protectedinherited |
returns data of requested type for globalbin number
Definition at line 295 of file IHistogram.cpp.
References IHistogram::getBinAverage(), IHistogram::getBinContent(), IHistogram::getBinError(), and IHistogram::getBinNumberOfEntries().
Referenced by IHistogram::createOutputData(), and IHistogram::getDataVector().
|
protectedinherited |
returns vector of values of requested DataType
Definition at line 311 of file IHistogram.cpp.
References IHistogram::getBinData(), and IHistogram::getTotalNumberOfBins().
Referenced by getBinErrors(), and getBinValues().
|
protectedinherited |
Copy content (but not the axes) from other histogram. Dimensions should be the same.
Definition at line 322 of file IHistogram.cpp.
References IHistogram::getTotalNumberOfBins(), IHistogram::hasSameDimensions(), IHistogram::m_data, and IHistogram::reset().
Referenced by IHistogram::load().
|
protectedinherited |
Definition at line 193 of file IHistogram.h.
Referenced by IHistogram::addBinContent(), Histogram2D::addContent(), IHistogram::copyContentFrom(), IHistogram::createOutputData(), crop(), Histogram2D::crop(), fill(), Histogram2D::fill(), IHistogram::findGlobalBin(), IHistogram::getBinAverage(), IHistogram::getBinContent(), IHistogram::getBinError(), IHistogram::getBinNumberOfEntries(), IHistogram::getData(), IHistogram::getGlobalBin(), IHistogram::getMaximum(), IHistogram::getMaximumBinIndex(), IHistogram::getMinimum(), IHistogram::getMinimumBinIndex(), IHistogram::getTotalNumberOfBins(), IHistogram::getXaxis(), IHistogram::getXaxisIndex(), IHistogram::getXaxisValue(), IHistogram::getYaxis(), IHistogram::getYaxisIndex(), IHistogram::getYaxisValue(), IHistogram::hasSameDimensions(), IHistogram::hasSameShape(), Histogram1D(), Histogram2D::Histogram2D(), IHistogram::IHistogram(), IHistogram::init_from_data(), Histogram2D::initFromShape(), IHistogram::integral(), IHistogram::reset(), IHistogram::scale(), and IHistogram::setBinContent().