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

Class to represent the spectra axis of a workspace. More...

#include <SpectraAxis.h>

Inheritance diagram for Mantid::API::SpectraAxis:
Mantid::API::Axis

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. More...
 
double getMax () const override
 returns max value defined on axis More...
 
double getMin () const override
 returns min value defined on axis More...
 
spec2index_map getSpectraIndexMap () const
 Returns a map where spectra is the key and index is the value This is used for efficient search of spectra number within a workspace. More...
 
size_t indexOfValue (const double value) const override
 Finds the index of the given value on the axis. More...
 
bool isSpectra () const override
 If this is a spectra Axis - always true for this class. More...
 
std::string label (const std::size_t &index) const override
 Returns a text label which shows the value at index and identifies the type of the axis. More...
 
std::size_t length () const override
 Get the length of the axis. More...
 
double operator() (const std::size_t &index, const std::size_t &verticalIndex=0) const override
 Get the axis value at the position given. 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
 Sets the axis value at a given position. More...
 
 SpectraAxis (const MatrixWorkspace *const parentWorkspace)
 Virtual constructor. More...
 
specnum_t spectraNo (const std::size_t &index) const override
 Returns the spectrum number at the position given (Spectra axis only) 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
 

Private Member Functions

const SpectraAxisoperator= (const SpectraAxis &)
 Private, undefined copy assignment operator. More...
 
 SpectraAxis ()
 Default constructor. More...
 
 SpectraAxis (const SpectraAxis &)
 Private, undefined copy constructor. More...
 

Private Attributes

std::vector< double > m_edges
 List of edge values for quick searching of values as if this is binned data. More...
 
const MatrixWorkspace *const m_parentWS
 A pointer to the workspace holding the axis. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::API::Axis
 Axis (const Axis &)=default
 
Axisoperator= (const Axis &)=default
 

Detailed Description

Class to represent the spectra axis of a workspace.

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

Definition at line 31 of file SpectraAxis.h.

Constructor & Destructor Documentation

◆ SpectraAxis() [1/3]

Mantid::API::SpectraAxis::SpectraAxis ( const MatrixWorkspace *const  parentWorkspace)
explicit

Virtual constructor.

Parameters
parentWorkspaceThe workspace to which this axis belongs

Definition at line 25 of file SpectraAxis.cpp.

References Mantid::API::Axis::unit().

◆ SpectraAxis() [2/3]

Mantid::API::SpectraAxis::SpectraAxis ( )
private

Default constructor.

Referenced by clone().

◆ SpectraAxis() [3/3]

Mantid::API::SpectraAxis::SpectraAxis ( const SpectraAxis )
private

Private, undefined copy constructor.

Member Function Documentation

◆ clone() [1/2]

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

Virtual constructor.

Parameters
parentWorkspaceThe workspace to which the cloned axis belongs
Returns
A pointer to a copy of the SpectraAxis on which the method is called

Implements Mantid::API::Axis.

Definition at line 34 of file SpectraAxis.cpp.

References SpectraAxis(), Mantid::API::Axis::title(), and Mantid::API::Axis::unit().

Referenced by clone().

◆ clone() [2/2]

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

Virtual constructor.

Parameters
lengthNot used in this implementation
parentWorkspaceThe workspace to which the cloned axis belongs
Returns
A pointer to a copy of the SpectraAxis on which the method is called

Implements Mantid::API::Axis.

Definition at line 47 of file SpectraAxis.cpp.

References clone(), length(), and UNUSED_ARG.

◆ getMax()

double Mantid::API::SpectraAxis::getMax ( ) const
overridevirtual

returns max value defined on axis

Implements Mantid::API::Axis.

Definition at line 164 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), length(), and m_parentWS.

◆ getMin()

double Mantid::API::SpectraAxis::getMin ( ) const
overridevirtual

returns min value defined on axis

Implements Mantid::API::Axis.

Definition at line 161 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), and m_parentWS.

◆ getSpectraIndexMap()

spec2index_map Mantid::API::SpectraAxis::getSpectraIndexMap ( ) const

Returns a map where spectra is the key and index is the value This is used for efficient search of spectra number within a workspace.

Returns
:: map of spectra to index

Definition at line 121 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), length(), and m_parentWS.

Referenced by Mantid::DataHandling::GroupDetectors2::getGroups(), Mantid::Algorithms::NormaliseToMonitor::getInWSMonitorSpectrum(), Mantid::DataHandling::GroupDetectors2::processFile(), and Mantid::DataHandling::GroupDetectors2::processXMLFile().

◆ indexOfValue()

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

Finds the index of the given value on the axis.

Parameters
valueA value on the axis. It is treated as a spectrum number and cast to specnum_t on input
Returns
The index closest to given value

Implements Mantid::API::Axis.

Definition at line 89 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getNumberHistograms(), Mantid::API::Axis::getValue(), Mantid::Kernel::VectorHelper::indexOfValueFromEdges(), m_edges, m_parentWS, and value.

◆ isSpectra()

bool Mantid::API::SpectraAxis::isSpectra ( ) const
inlineoverridevirtual

If this is a spectra Axis - always true for this class.

Reimplemented from Mantid::API::Axis.

Definition at line 38 of file SpectraAxis.h.

◆ label()

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

Returns a text label which shows the value at index and identifies the type of the axis.

Parameters
index:: The index of an axis value
Returns
label of requested axis index

Implements Mantid::API::Axis.

Definition at line 158 of file SpectraAxis.cpp.

References index, spectraNo(), and std::to_string().

◆ length()

std::size_t Mantid::API::SpectraAxis::length ( ) const
overridevirtual

Get the length of the axis.

Implements Mantid::API::Axis.

Definition at line 54 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getNumberHistograms(), and m_parentWS.

Referenced by clone(), getMax(), getSpectraIndexMap(), operator()(), operator==(), and spectraNo().

◆ operator()()

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

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.

Definition at line 63 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), index, length(), m_parentWS, and UNUSED_ARG.

◆ operator=()

const SpectraAxis & Mantid::API::SpectraAxis::operator= ( const SpectraAxis )
private

Private, undefined copy assignment operator.

◆ operator==()

bool Mantid::API::SpectraAxis::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 is self and second axis are equal

Implements Mantid::API::Axis.

Definition at line 137 of file SpectraAxis.cpp.

References Mantid::API::Axis::length(), length(), Mantid::API::Axis::spectraNo(), and spectraNo().

◆ setValue()

void Mantid::API::SpectraAxis::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 77 of file SpectraAxis.cpp.

References index, UNUSED_ARG, and value.

◆ spectraNo()

specnum_t Mantid::API::SpectraAxis::spectraNo ( const std::size_t &  index) const
overridevirtual

Returns the spectrum number at the position given (Spectra axis only)

Parameters
indexThe position for which the value is required
Returns
The spectrum number as an int
Exceptions
IndexErrorIf the index requested is not in the range of this axis

Reimplemented from Mantid::API::Axis.

Definition at line 109 of file SpectraAxis.cpp.

References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), index, length(), and m_parentWS.

Referenced by label(), and operator==().

Member Data Documentation

◆ m_edges

std::vector<double> Mantid::API::SpectraAxis::m_edges
mutableprivate

List of edge values for quick searching of values as if this is binned data.

Definition at line 64 of file SpectraAxis.h.

Referenced by indexOfValue().

◆ m_parentWS

const MatrixWorkspace* const Mantid::API::SpectraAxis::m_parentWS
private

A pointer to the workspace holding the axis.

Definition at line 61 of file SpectraAxis.h.

Referenced by getMax(), getMin(), getSpectraIndexMap(), indexOfValue(), length(), operator()(), and spectraNo().


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