Mantid
|
Class to represent a numeric axis of a workspace. More...
#include <NumericAxis.h>
Public Member Functions | |
Axis * | clone (const MatrixWorkspace *const parentWorkspace) override |
Virtual constructor. More... | |
Axis * | clone (const std::size_t length, const MatrixWorkspace *const parentWorkspace) override |
Virtual constructor for axis of different length. More... | |
virtual std::vector< double > | createBinBoundaries () const |
Create bin boundaries from the point values. More... | |
virtual bool | equalWithinTolerance (const Axis &axis2, const double tolerance) const |
Check if two numeric axis are equivalent to a given tolerance. More... | |
double | getMax () const override |
returns max value defined on axis More... | |
double | getMin () const override |
returns min value defined on axis More... | |
virtual const std::vector< double > & | getValues () const |
Return a const reference to the values. More... | |
size_t | indexOfValue (const double value) const override |
Returns the index of the value wrt bin edge representation of the axis. More... | |
bool | isNumeric () const override |
Is the axis numeric - always true for this class. More... | |
std::string | label (const std::size_t &index) const override |
Returns a text label which shows the value corresponding to a bin index. More... | |
std::size_t | length () const override |
Get the length of the axis. More... | |
NumericAxis (const std::size_t &length) | |
Constructor. More... | |
NumericAxis (std::vector< double > centres) | |
Constructor taking a set of centre point values. More... | |
double | operator() (const std::size_t &index, const std::size_t &verticalIndex=0) const override |
Get a value at the specified index. More... | |
bool | operator== (const Axis &) const override |
Check if two axis defined as spectra or numeric axis are equivalent. More... | |
void | setValue (const std::size_t &index, const double &value) override |
Set the value at a specific index. More... | |
Public Member Functions inherited from Mantid::API::Axis | |
Axis () | |
Constructor. More... | |
virtual Axis * | clone (const MatrixWorkspace *const parentWorkspace)=0 |
Virtual constructor. More... | |
virtual Axis * | clone (const std::size_t length, const MatrixWorkspace *const parentWorkspace)=0 |
Virtual constructor for axis of different length. More... | |
virtual double | getMax () const =0 |
returns max value defined on axis More... | |
virtual double | getMin () const =0 |
returns min value defined on axis More... | |
double | getValue (const std::size_t &index, const std::size_t &verticalIndex=0) const |
Gets the value at the specified index. More... | |
virtual size_t | indexOfValue (const double value) const =0 |
Find the index of the given double value. More... | |
virtual bool | isNumeric () const |
Returns true if the axis is numeric. More... | |
virtual bool | isSpectra () const |
Returns true is the axis is a Spectra axis. More... | |
virtual bool | isText () const |
Returns true if the axis is Text. More... | |
virtual std::string | label (const std::size_t &index) const =0 |
Returns a text label of for a value Note that the index here is not the index of a value, but the effective index of the bin. More... | |
virtual std::size_t | length () const =0 |
Get the length of the axis. More... | |
virtual double | operator() (const std::size_t &index, const std::size_t &verticalIndex=0) const =0 |
Returns the value at a specified index. More... | |
virtual bool | operator== (const Axis &) const =0 |
Check whether two axis are the same, i.e same length and same spectra_values for all elements in the axis. More... | |
virtual const std::shared_ptr< Kernel::Unit > & | setUnit (const std::string &unitName) |
Set the unit on the Axis. More... | |
virtual void | setValue (const std::size_t &index, const double &value)=0 |
Sets the value at the specified index. More... | |
virtual specnum_t | spectraNo (const std::size_t &index) const |
Get the spectrum number. More... | |
std::string & | title () |
Returns a reference to the user-defined title for this axis. More... | |
const std::string & | title () const |
Returns the user-defined title for this axis. More... | |
std::shared_ptr< Kernel::Unit > & | unit () |
The unit object for this workspace (non const version) More... | |
const std::shared_ptr< Kernel::Unit > & | unit () const |
The unit for this axis. More... | |
virtual | ~Axis ()=default |
Protected Member Functions | |
std::string | formatLabel (const double value) const |
Get number label. More... | |
NumericAxis () | |
Default constructor. More... | |
Protected Member Functions inherited from Mantid::API::Axis | |
Axis (const Axis &)=default | |
Axis & | operator= (const Axis &)=default |
Protected Attributes | |
std::vector< double > | m_values |
A vector holding the centre values. More... | |
Class to represent a numeric axis of a workspace.
Definition at line 29 of file NumericAxis.h.
Mantid::API::NumericAxis::NumericAxis | ( | const std::size_t & | length | ) |
Constructor.
length | size of the numeric axis |
Definition at line 55 of file NumericAxis.cpp.
Mantid::API::NumericAxis::NumericAxis | ( | std::vector< double > | centres | ) |
Constructor taking a set of centre point values.
centres | A vector of values to assign to the axis |
Definition at line 61 of file NumericAxis.cpp.
|
protecteddefault |
|
overridevirtual |
Virtual constructor.
parentWorkspace | :: The workspace is not used in this implementation |
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 68 of file NumericAxis.cpp.
References NumericAxis(), and UNUSED_ARG.
|
overridevirtual |
Virtual constructor for axis of different length.
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 73 of file NumericAxis.cpp.
References length(), NumericAxis(), and UNUSED_ARG.
|
virtual |
Create bin boundaries from the point values.
Create a set of bin boundaries from the centre point values.
Reimplemented in Mantid::API::BinEdgeAxis, and Mantid::API::RefAxis.
Definition at line 168 of file NumericAxis.cpp.
References Mantid::Kernel::VectorHelper::convertToBinBoundary(), and m_values.
Referenced by Mantid::Algorithms::Rebin2D::exec().
|
virtual |
Check if two numeric axis are equivalent to a given tolerance.
axis2 | :: Reference to the axis to compare to |
tolerance | :: Tolerance to compare to |
Reimplemented in Mantid::API::RefAxis.
Definition at line 121 of file NumericAxis.cpp.
References Mantid::API::Axis::length(), length(), m_values, and tolerance.
Referenced by operator==().
|
protected |
Get number label.
Formats a numeric label to a string.
value | the numeric value of the label |
Definition at line 145 of file NumericAxis.cpp.
References value.
Referenced by Mantid::API::BinEdgeAxis::label(), and label().
|
inlineoverridevirtual |
returns max value defined on axis
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 54 of file NumericAxis.h.
Referenced by Mantid::Algorithms::RingProfile::checkInputsForNumericWorkspace(), and Mantid::Algorithms::RadiusSum::getBoundariesOfNumericImage().
|
inlineoverridevirtual |
returns min value defined on axis
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 52 of file NumericAxis.h.
Referenced by Mantid::Algorithms::RingProfile::checkInputsForNumericWorkspace(), and Mantid::Algorithms::RadiusSum::getBoundariesOfNumericImage().
|
virtual |
Return a const reference to the values.
Get a const reference to the vector of values in this axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 179 of file NumericAxis.cpp.
References m_values.
Referenced by Mantid::API::MatrixWorkspaceMDIterator::calcWorkspacePos(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::convertWsBothAxesToPoints(), Mantid::API::BinEdgeAxis::createBinBoundaries(), Mantid::Algorithms::Bin2DPowderDiffraction::normalizeToBinArea(), and Mantid::Algorithms::DiscusMultipleScatteringCorrection::validateInputs().
|
overridevirtual |
Returns the index of the value wrt bin edge representation of the axis.
value | A value to find in a bin |
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 48 of file NumericAxis.cpp.
References Mantid::Kernel::VectorHelper::indexOfValueFromCenters(), m_values, and value.
|
inlineoverridevirtual |
Is the axis numeric - always true for this class.
Reimplemented from Mantid::API::Axis.
Definition at line 37 of file NumericAxis.h.
|
overridevirtual |
Returns a text label which shows the value corresponding to a bin index.
index | :: The index of the bin, matches with the index of the value |
Implements Mantid::API::Axis.
Definition at line 138 of file NumericAxis.cpp.
References formatLabel(), and index.
|
inlineoverridevirtual |
Get the length of the axis.
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 38 of file NumericAxis.h.
Referenced by Mantid::API::BinEdgeAxis::BinEdgeAxis(), Mantid::API::BinEdgeAxis::clone(), clone(), equalWithinTolerance(), Mantid::API::BinEdgeAxis::label(), Mantid::Algorithms::Bin2DPowderDiffraction::normalizeToBinArea(), operator()(), Mantid::API::BinEdgeAxis::setValue(), and setValue().
|
overridevirtual |
Get a value at the specified index.
Get the axis value at the position given.
index | The position along the axis for which the value is required |
verticalIndex | Needed for the subclass (RefAxis) method, but ignored (and defaulted) here |
IndexError | If the index requested is not in the range of this axis |
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 88 of file NumericAxis.cpp.
References index, length(), m_values, and UNUSED_ARG.
|
overridevirtual |
Check if two axis defined as spectra or numeric axis are equivalent.
axis2 | :: Reference to the axis to compare to |
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 114 of file NumericAxis.cpp.
References equalWithinTolerance().
|
overridevirtual |
Set the value at a specific index.
Sets the axis value at a given position.
index | :: The position along the axis for which to set the value |
value | :: The new value |
IndexError | If the index requested is not in the range of this axis |
Implements Mantid::API::Axis.
Reimplemented in Mantid::API::RefAxis.
Definition at line 102 of file NumericAxis.cpp.
References index, length(), m_values, and value.
Referenced by Mantid::Algorithms::ExtractSpectra2::exec(), and Mantid::Algorithms::Integration::exec().
|
protected |
A vector holding the centre values.
Definition at line 61 of file NumericAxis.h.
Referenced by Mantid::API::BinEdgeAxis::BinEdgeAxis(), createBinBoundaries(), equalWithinTolerance(), getValues(), Mantid::API::BinEdgeAxis::indexOfValue(), indexOfValue(), operator()(), Mantid::API::BinEdgeAxis::setValue(), and setValue().