Mantid
|
Class to represent the spectra axis of a workspace. More...
#include <SpectraAxis.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. 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 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 |
Private Member Functions | |
const SpectraAxis & | operator= (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 | |
Axis & | operator= (const Axis &)=default |
Class to represent the spectra axis of a workspace.
Definition at line 31 of file SpectraAxis.h.
|
explicit |
Virtual constructor.
parentWorkspace | The workspace to which this axis belongs |
Definition at line 25 of file SpectraAxis.cpp.
References Mantid::API::Axis::unit().
|
private |
Default constructor.
Referenced by clone().
|
private |
Private, undefined copy constructor.
|
overridevirtual |
Virtual constructor.
parentWorkspace | The workspace to which the cloned axis belongs |
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().
|
overridevirtual |
Virtual constructor.
length | Not used in this implementation |
parentWorkspace | The workspace to which the cloned axis belongs |
Implements Mantid::API::Axis.
Definition at line 47 of file SpectraAxis.cpp.
References clone(), length(), and UNUSED_ARG.
|
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.
|
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.
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.
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().
|
overridevirtual |
Finds the index of the given value on the axis.
value | A value on the axis. It is treated as a spectrum number and cast to specnum_t on input |
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.
|
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.
|
overridevirtual |
Returns a text label which shows the value at index and identifies the type of the axis.
index | :: The index of an axis value |
Implements Mantid::API::Axis.
Definition at line 158 of file SpectraAxis.cpp.
References index, spectraNo(), and std::to_string().
|
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().
|
overridevirtual |
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.
Definition at line 63 of file SpectraAxis.cpp.
References Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::ISpectrum::getSpectrumNo(), index, length(), m_parentWS, and UNUSED_ARG.
|
private |
Private, undefined copy assignment operator.
|
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.
Definition at line 137 of file SpectraAxis.cpp.
References Mantid::API::Axis::length(), length(), Mantid::API::Axis::spectraNo(), and spectraNo().
|
overridevirtual |
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.
Definition at line 77 of file SpectraAxis.cpp.
References index, UNUSED_ARG, and value.
|
overridevirtual |
Returns the spectrum number at the position given (Spectra axis only)
index | The position for which the value is required |
IndexError | If 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==().
|
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().
|
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().