BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Stores radiation power per bin.
Definition at line 30 of file Datafield.h.
Public Member Functions | |
Datafield (const Datafield &)=delete | |
Datafield (const std::vector< IAxis * > &axes) | |
Constructor that takes ownership of supplied axes. More... | |
Datafield (const std::vector< IAxis * > &axes, const std::vector< double > &vector) | |
Constructor that takes ownership of supplied axes. More... | |
Datafield (Datafield &&)=default | |
Datafield (Frame *frame) | |
Constructor that takes ownership of supplied frame. More... | |
Datafield (Frame *frame, const std::vector< double > &vector) | |
Constructor that takes ownership of supplied frame. More... | |
~Datafield () | |
const IAxis & | axis (size_t k) const |
Datafield * | clone () const |
Datafield * | crop (double xmin, double xmax) const |
Datafield * | crop (double xmin, double ymin, double xmax, double ymax) const |
std::vector< double > | flatVector () const |
Returns copy of raw data vector. More... | |
const Frame & | frame () const |
bool | hasSameShape (const Datafield &other) const |
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide. More... | |
bool | hasSameSizes (const Datafield &other) const |
Returns true if object have same dimensions and number of axes bins. More... | |
double | maxVal () const |
double | minVal () const |
Datafield * | normalizedToMaximum () const |
PyObject * | npArray () const |
Returns data as Python numpy array. More... | |
double & | operator[] (size_t i) |
indexed accessor More... | |
const double & | operator[] (size_t i) const |
ied accessor (const) More... | |
size_t | rank () const |
void | setAllTo (const double &value) |
Sets content of output data to specific value. More... | |
void | setAt (size_t i, double val) |
void | setVector (const std::vector< double > &data_vector) |
Sets new values to raw data vector. More... | |
size_t | size () const |
Returns total size of data buffer (product of bin number in every dimension). More... | |
double | valAt (size_t i) const |
const IAxis & | xAxis () const |
Datafield * | xProjection () |
Project a 2D histogram into 1D histogram along X. The projection is made from all bins along y-axis. More... | |
Datafield * | xProjection (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. More... | |
Datafield * | xProjection (double yvalue) |
Project a 2D histogram into 1D histogram along X. The projection is made from the y-bin closest to given ordinate yvalue. More... | |
const IAxis & | yAxis () const |
Datafield * | yProjection () |
Project a 2D histogram into 1D histogram along Y. The projection is made from all bins along x-axis. More... | |
Datafield * | yProjection (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. More... | |
Datafield * | yProjection (double xvalue) |
Project a 2D histogram into 1D histogram along Y. The projection is made from the x-bin closest to given abscissa xvalue. More... | |
Private Member Functions | |
Datafield * | create_xProjection (int ybinlow, int ybinup) |
Creates projection along X. The projections is made by collecting the data in the range between [ybinlow, ybinup]. More... | |
Datafield * | create_yProjection (int xbinlow, int xbinup) |
Creates projection along Y. The projections is made by collecting the data in the range between [xbinlow, xbinup]. More... | |
Private Attributes | |
std::unique_ptr< Frame > | m_frame |
std::vector< double > | m_vec |
Datafield::Datafield | ( | Frame * | frame | ) |
Constructor that takes ownership of supplied frame.
Definition at line 24 of file Datafield.cpp.
Referenced by clone(), create_xProjection(), create_yProjection(), crop(), and normalizedToMaximum().
Datafield::Datafield | ( | Frame * | frame, |
const std::vector< double > & | vector | ||
) |
Constructor that takes ownership of supplied frame.
Definition at line 30 of file Datafield.cpp.
Datafield::Datafield | ( | const std::vector< IAxis * > & | axes | ) |
Constructor that takes ownership of supplied axes.
Definition at line 41 of file Datafield.cpp.
Datafield::Datafield | ( | const std::vector< IAxis * > & | axes, |
const std::vector< double > & | vector | ||
) |
Constructor that takes ownership of supplied axes.
Definition at line 36 of file Datafield.cpp.
|
delete |
|
default |
Datafield::~Datafield | ( | ) |
Definition at line 46 of file Datafield.cpp.
const IAxis & Datafield::axis | ( | size_t | k | ) | const |
Definition at line 91 of file Datafield.cpp.
References m_frame.
Referenced by ConvolutionDetectorResolution::apply1dConvolution(), ConvolutionDetectorResolution::apply2dConvolution(), DataUtils::Data::create2DArrayfromDatafield(), DataUtils::Data::createRearrangedDataSet(), DataUtils::Array::createVector2D(), npArray(), ReadWriteNumpyTXT::write1DRepresentation(), ReadWriteNumpyTXT::write2DRepresentation(), and ReadWriteINT::writeDatafield().
Datafield * Datafield::clone | ( | ) | const |
Definition at line 48 of file Datafield.cpp.
References Datafield(), m_frame, and m_vec.
Referenced by DataUtils::Data::createRearrangedDataSet().
|
private |
Creates projection along X. The projections is made by collecting the data in the range between [ybinlow, ybinup].
Definition at line 260 of file Datafield.cpp.
References Datafield(), ASSERT, IAxis::clone(), IAxis::findClosestIndex(), m_frame, size(), valAt(), and xAxis().
Referenced by xProjection().
|
private |
Creates projection along Y. The projections is made by collecting the data in the range between [xbinlow, xbinup].
Definition at line 275 of file Datafield.cpp.
References Datafield(), ASSERT, IAxis::clone(), IAxis::findClosestIndex(), m_frame, size(), valAt(), and yAxis().
Referenced by yProjection().
Datafield * Datafield::crop | ( | double | xmin, |
double | xmax | ||
) | const |
Definition at line 165 of file Datafield.cpp.
References Datafield(), IAxis::clip(), IAxis::clone(), m_frame, m_vec, size(), and xAxis().
Datafield * Datafield::crop | ( | double | xmin, |
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) | const |
Definition at line 147 of file Datafield.cpp.
References Datafield(), IAxis::clip(), IAxis::clone(), m_frame, m_vec, size(), xAxis(), and yAxis().
std::vector< double > Datafield::flatVector | ( | ) | const |
Returns copy of raw data vector.
Definition at line 119 of file Datafield.cpp.
References size().
Referenced by ConvolutionDetectorResolution::apply1dConvolution(), ConvolutionDetectorResolution::apply2dConvolution(), ICoordSystem::createConvertedData(), CoordSystem1D::createConvertedData(), DataUtils::Array::createVector1D(), SimDataPair::experimental_array(), SimDataPair::simulation_array(), SimDataPair::uncertainties_array(), and SimDataPair::user_weights_array().
const Frame & Datafield::frame | ( | ) | const |
Definition at line 86 of file Datafield.cpp.
References m_frame.
Referenced by ConvolutionDetectorResolution::apply2dConvolution(), IDetector::applyDetectorResolution(), DataUtils::Data::createRearrangedDataSet(), hasSameShape(), hasSameSizes(), normalizedToMaximum(), DiffUtil::relativeDifferenceField(), setVector(), and size().
bool Datafield::hasSameShape | ( | const Datafield & | other | ) | const |
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.
Returns true if object have same dimensions and shape of axis.
Definition at line 114 of file Datafield.cpp.
References frame().
Referenced by DiffUtil::relativeDifferenceField().
bool Datafield::hasSameSizes | ( | const Datafield & | other | ) | const |
Returns true if object have same dimensions and number of axes bins.
Returns true if object have same dimensions.
Definition at line 108 of file Datafield.cpp.
References frame(), and Frame::hasSameSizes().
double Datafield::maxVal | ( | ) | const |
Definition at line 137 of file Datafield.cpp.
References m_vec.
Referenced by normalizedToMaximum().
double Datafield::minVal | ( | ) | const |
Definition at line 142 of file Datafield.cpp.
References m_vec.
Datafield * Datafield::normalizedToMaximum | ( | ) | const |
Definition at line 127 of file Datafield.cpp.
References Datafield(), ASSERT, frame(), m_frame, m_vec, maxVal(), Frame::size(), and size().
PyObject * Datafield::npArray | ( | ) | const |
Returns data as Python numpy array.
Definition at line 181 of file Datafield.cpp.
References ASSERT, axis(), m_frame, rank(), size(), and IAxis::size().
|
inline |
|
inline |
size_t Datafield::rank | ( | ) | const |
Definition at line 75 of file Datafield.cpp.
References m_frame.
Referenced by ConvolutionDetectorResolution::apply1dConvolution(), ConvolutionDetectorResolution::apply2dConvolution(), ConvolutionDetectorResolution::applyDetectorResolution(), DataUtils::Data::create2DArrayfromDatafield(), CoordSystem1D::createConvertedData(), DataUtils::Data::createRearrangedDataSet(), DataUtils::Array::createVector1D(), npArray(), ReadWriteINT::writeDatafield(), and ReadWriteNumpyTXT::writeDatafield().
void Datafield::setAllTo | ( | const double & | value | ) |
Sets content of output data to specific value.
Definition at line 63 of file Datafield.cpp.
References m_vec.
void Datafield::setAt | ( | size_t | i, |
double | val | ||
) |
void Datafield::setVector | ( | const std::vector< double > & | data_vector | ) |
Sets new values to raw data vector.
Definition at line 69 of file Datafield.cpp.
References ASSERT, frame(), m_vec, and size().
Referenced by ConvolutionDetectorResolution::apply1dConvolution(), IDetector::applyDetectorResolution(), ICoordSystem::createConvertedData(), and CoordSystem1D::createConvertedData().
size_t Datafield::size | ( | ) | const |
Returns total size of data buffer (product of bin number in every dimension).
Definition at line 80 of file Datafield.cpp.
References ASSERT, frame(), m_vec, and Frame::size().
Referenced by ConvolutionDetectorResolution::apply2dConvolution(), create_xProjection(), create_yProjection(), CoordSystem1D::createConvertedData(), DataUtils::Data::createRearrangedDataSet(), crop(), DataUtils::Format::fillDatafield(), flatVector(), normalizedToMaximum(), npArray(), DiffUtil::relativeDifferenceField(), setVector(), ReadWriteINT::writeDatafieldDoubles(), xProjection(), and yProjection().
double Datafield::valAt | ( | size_t | i | ) | const |
Definition at line 58 of file Datafield.cpp.
References m_vec.
Referenced by create_xProjection(), create_yProjection(), and DiffUtil::relativeDifferenceField().
const IAxis & Datafield::xAxis | ( | ) | const |
Definition at line 96 of file Datafield.cpp.
References m_frame.
Referenced by create_xProjection(), crop(), DataUtils::Data::FindPeaks(), xProjection(), and yProjection().
Datafield * Datafield::xProjection | ( | ) |
Project a 2D histogram into 1D histogram along X. The projection is made from all bins along y-axis.
Definition at line 224 of file Datafield.cpp.
References create_xProjection(), size(), and xAxis().
Datafield * Datafield::xProjection | ( | 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 235 of file Datafield.cpp.
References create_xProjection(), IAxis::findClosestIndex(), and yAxis().
Datafield * Datafield::xProjection | ( | 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 229 of file Datafield.cpp.
References create_xProjection(), IAxis::findClosestIndex(), and yAxis().
const IAxis & Datafield::yAxis | ( | ) | const |
Definition at line 101 of file Datafield.cpp.
References m_frame.
Referenced by create_yProjection(), crop(), DataUtils::Data::FindPeaks(), and xProjection().
Datafield * Datafield::yProjection | ( | ) |
Project a 2D histogram into 1D histogram along Y. The projection is made from all bins along x-axis.
Definition at line 242 of file Datafield.cpp.
References create_yProjection(), size(), and xAxis().
Datafield * Datafield::yProjection | ( | 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 253 of file Datafield.cpp.
References create_yProjection(), IAxis::findClosestIndex(), and xAxis().
Datafield * Datafield::yProjection | ( | 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 247 of file Datafield.cpp.
References create_yProjection(), IAxis::findClosestIndex(), and xAxis().
|
private |
Definition at line 140 of file Datafield.h.
Referenced by axis(), clone(), create_xProjection(), create_yProjection(), crop(), frame(), normalizedToMaximum(), npArray(), rank(), xAxis(), and yAxis().
|
private |
Definition at line 141 of file Datafield.h.
Referenced by clone(), crop(), maxVal(), minVal(), normalizedToMaximum(), operator[](), setAllTo(), setAt(), setVector(), size(), and valAt().