Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mantid::API::NumericAxis Class Reference

Class to represent a numeric axis of a workspace. More...

#include <NumericAxis.h>

Inheritance diagram for Mantid::API::NumericAxis:
Mantid::API::Axis Mantid::API::BinEdgeAxis Mantid::API::RefAxis

Public Member Functions

Axisclone (const MatrixWorkspace *const parentWorkspace) override
 Virtual constructor. More...
 
Axisclone (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 Axisclone (const MatrixWorkspace *const parentWorkspace)=0
 Virtual constructor. More...
 
virtual Axisclone (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
 
Axisoperator= (const Axis &)=default
 

Protected Attributes

std::vector< double > m_values
 A vector holding the centre values. More...
 

Detailed Description

Class to represent a numeric axis of a workspace.

Author
Roman Tolchenov, Tessella plc
Date
05/07/2010

Definition at line 29 of file NumericAxis.h.

Constructor & Destructor Documentation

◆ NumericAxis() [1/3]

Mantid::API::NumericAxis::NumericAxis ( const std::size_t &  length)

Constructor.

Parameters
lengthsize of the numeric axis

Definition at line 55 of file NumericAxis.cpp.

◆ NumericAxis() [2/3]

Mantid::API::NumericAxis::NumericAxis ( std::vector< double >  centres)

Constructor taking a set of centre point values.

Parameters
centresA vector of values to assign to the axis

Definition at line 61 of file NumericAxis.cpp.

◆ NumericAxis() [3/3]

Mantid::API::NumericAxis::NumericAxis ( )
protecteddefault

Default constructor.

Sets values vectors to zero size.

Referenced by clone().

Member Function Documentation

◆ clone() [1/2]

Axis * Mantid::API::NumericAxis::clone ( const MatrixWorkspace *const  parentWorkspace)
overridevirtual

Virtual constructor.

Parameters
parentWorkspace:: The workspace is not used in this implementation
Returns
A pointer to a copy of the NumericAxis on which the method is called

Implements Mantid::API::Axis.

Reimplemented in Mantid::API::RefAxis.

Definition at line 68 of file NumericAxis.cpp.

References NumericAxis(), and UNUSED_ARG.

◆ clone() [2/2]

Axis * Mantid::API::NumericAxis::clone ( const std::size_t  length,
const MatrixWorkspace *const  parentWorkspace 
)
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.

◆ createBinBoundaries()

std::vector< double > Mantid::API::NumericAxis::createBinBoundaries ( ) const
virtual

Create bin boundaries from the point values.

Create a set of bin boundaries from the centre point values.

Returns
A vector of bin boundaries

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().

◆ equalWithinTolerance()

bool Mantid::API::NumericAxis::equalWithinTolerance ( const Axis axis2,
const double  tolerance 
) const
virtual

Check if two numeric axis are equivalent to a given tolerance.

Parameters
axis2:: Reference to the axis to compare to
tolerance:: Tolerance to compare to
Returns
true if self and second axis are equal

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==().

◆ formatLabel()

std::string Mantid::API::NumericAxis::formatLabel ( const double  value) const
protected

Get number label.

Formats a numeric label to a string.

Parameters
valuethe numeric value of the label
Returns
formatted value as string

Definition at line 145 of file NumericAxis.cpp.

References value.

Referenced by Mantid::API::BinEdgeAxis::label(), and label().

◆ getMax()

double Mantid::API::NumericAxis::getMax ( ) const
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().

◆ getMin()

double Mantid::API::NumericAxis::getMin ( ) const
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().

◆ getValues()

const std::vector< double > & Mantid::API::NumericAxis::getValues ( ) const
virtual

◆ indexOfValue()

size_t Mantid::API::NumericAxis::indexOfValue ( const double  value) const
overridevirtual

Returns the index of the value wrt bin edge representation of the axis.

Parameters
valueA value to find in a bin
Returns
The index of the bin holding the value

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.

◆ isNumeric()

bool Mantid::API::NumericAxis::isNumeric ( ) const
inlineoverridevirtual

Is the axis numeric - always true for this class.

Reimplemented from Mantid::API::Axis.

Definition at line 37 of file NumericAxis.h.

◆ label()

std::string Mantid::API::NumericAxis::label ( const std::size_t &  index) const
overridevirtual

Returns a text label which shows the value corresponding to a bin index.

Parameters
index:: The index of the bin, matches with the index of the value
Returns
the formatted string

Implements Mantid::API::Axis.

Definition at line 138 of file NumericAxis.cpp.

References formatLabel(), and index.

◆ length()

std::size_t Mantid::API::NumericAxis::length ( ) const
inlineoverridevirtual

◆ operator()()

double Mantid::API::NumericAxis::operator() ( const std::size_t &  index,
const std::size_t &  verticalIndex = 0 
) const
overridevirtual

Get a value at the specified index.

Get the axis value at the position given.

Parameters
indexThe position along the axis for which the value is required
verticalIndexNeeded for the subclass (RefAxis) method, but ignored (and defaulted) here
Returns
The value of the axis as a double
Exceptions
IndexErrorIf 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.

◆ operator==()

bool Mantid::API::NumericAxis::operator== ( const Axis axis2) const
overridevirtual

Check if two axis defined as spectra or numeric axis are equivalent.

Parameters
axis2:: Reference to the axis to compare to
Returns
true if self and second axis are equal

Implements Mantid::API::Axis.

Reimplemented in Mantid::API::RefAxis.

Definition at line 114 of file NumericAxis.cpp.

References equalWithinTolerance().

◆ setValue()

void Mantid::API::NumericAxis::setValue ( const std::size_t &  index,
const double &  value 
)
overridevirtual

Set the value at a specific index.

Sets the axis value at a given position.

Parameters
index:: The position along the axis for which to set the value
value:: The new value
Exceptions
IndexErrorIf 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().

Member Data Documentation

◆ m_values

std::vector<double> Mantid::API::NumericAxis::m_values
protected

The documentation for this class was generated from the following files: