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

Stores numeric values that are assumed to be bin edge values. More...

#include <BinEdgeAxis.h>

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

Public Member Functions

 BinEdgeAxis (const std::size_t &length)
 Constructor taking a length. More...
 
 BinEdgeAxis (const std::vector< double > &edges)
 Constructor taking a list of edge values. More...
 
Axisclone (const MatrixWorkspace *const parentWorkspace) override
 Virtual constructor. More...
 
Axisclone (const std::size_t length, const MatrixWorkspace *const parentWorkspace) override
 Virtual constructor. More...
 
std::vector< double > createBinBoundaries () const override
 Return the values axis as they are. More...
 
size_t indexOfValue (const double value) const override
 Treats values as bin edges and returns the index of the bin, which the value falls into. More...
 
std::string label (const std::size_t &index) const override
 Returns a text label which shows the value at the given bin index. More...
 
void setValue (const std::size_t &index, const double &value) override
 Sets the axis value at a given position. More...
 
- Public Member Functions inherited from Mantid::API::NumericAxis
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
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::API::NumericAxis
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 inherited from Mantid::API::NumericAxis
std::vector< double > m_values
 A vector holding the centre values. More...
 

Detailed Description

Stores numeric values that are assumed to be bin edge values.

It overrides indexOfValue to search using the values as bin edges are than centre points

Definition at line 20 of file BinEdgeAxis.h.

Constructor & Destructor Documentation

◆ BinEdgeAxis() [1/2]

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

Constructor taking a length.

Parameters
lengthThe length of the axis

Definition at line 18 of file BinEdgeAxis.cpp.

References Mantid::API::NumericAxis::length(), and Mantid::API::NumericAxis::m_values.

◆ BinEdgeAxis() [2/2]

Mantid::API::BinEdgeAxis::BinEdgeAxis ( const std::vector< double > &  edges)

Constructor taking a list of edge values.

Parameters
edgesA list of bin boundaries

Definition at line 28 of file BinEdgeAxis.cpp.

References Mantid::API::NumericAxis::m_values.

Member Function Documentation

◆ clone() [1/2]

Axis * Mantid::API::BinEdgeAxis::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.

Definition at line 39 of file BinEdgeAxis.cpp.

References UNUSED_ARG.

◆ clone() [2/2]

Axis * Mantid::API::BinEdgeAxis::clone ( const std::size_t  length,
const MatrixWorkspace *const  parentWorkspace 
)
overridevirtual

Virtual constructor.

Parameters
lengthA new length for the axis. The values are cleared.
parentWorkspaceThe 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.

Definition at line 49 of file BinEdgeAxis.cpp.

References Mantid::API::NumericAxis::length(), and UNUSED_ARG.

◆ createBinBoundaries()

std::vector< double > Mantid::API::BinEdgeAxis::createBinBoundaries ( ) const
overridevirtual

Return the values axis as they are.

Returns
A vector containing the bin boundaries

Reimplemented from Mantid::API::NumericAxis.

Definition at line 61 of file BinEdgeAxis.cpp.

References Mantid::API::NumericAxis::getValues().

◆ indexOfValue()

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

Treats values as bin edges and returns the index of the bin, which the value falls into.

The maximum value will always be length() - 1

Parameters
valueA value on the axis
Returns
The index closest to given value

Implements Mantid::API::Axis.

Definition at line 82 of file BinEdgeAxis.cpp.

References Mantid::Kernel::VectorHelper::indexOfValueFromEdges(), Mantid::API::NumericAxis::m_values, and value.

◆ label()

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

Returns a text label which shows the value at the given bin index.

Note that the bin index doesn't match the index in the value array for this type of axis. The value array has one more element than number of bins.

Parameters
index:: The bin index of the bin edge axis
Returns
string of the center of that bin
Exceptions
IndexErrorif the bin index is out of range

Implements Mantid::API::Axis.

Definition at line 93 of file BinEdgeAxis.cpp.

References Mantid::API::NumericAxis::formatLabel(), index, and Mantid::API::NumericAxis::length().

Referenced by Mantid::DataHandling::SaveAscii2::createSpectrumFilename(), and Mantid::DataHandling::SaveCanSAS1D2::exec().

◆ setValue()

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

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.

Definition at line 68 of file BinEdgeAxis.cpp.

References index, Mantid::API::NumericAxis::length(), Mantid::API::NumericAxis::m_values, and value.


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