Mantid
Loading...
Searching...
No Matches
Functions
MantidQt::MantidWidgets::WorkspaceUtils Namespace Reference

Functions

EXPORT_OPT_MANTIDQT_COMMON std::vector< std::string > attachPrefix (std::vector< std::string > const &strings, std::string const &prefix)
 
EXPORT_OPT_MANTIDQT_COMMON bool doAllWsExistInADS (std::vector< std::string > const &workspaceNames)
 
EXPORT_OPT_MANTIDQT_COMMON bool doesExistInADS (std::string const &workspaceName)
 
EXPORT_OPT_MANTIDQT_COMMON std::unordered_map< std::string, size_t > extractAxisLabels (const Mantid::API::MatrixWorkspace_const_sptr &workspace, const size_t &axisIndex)
 
template<typename T = Mantid::API::MatrixWorkspace>
std::shared_ptr< T > getADSWorkspace (std::string const &workspaceName)
 
template EXPORT_OPT_MANTIDQT_COMMON std::shared_ptr< Mantid::API::MatrixWorkspace_sptrgetADSWorkspace (std::string const &workspaceName)
 
EXPORT_OPT_MANTIDQT_COMMON std::optional< double > getEFixed (const Mantid::API::MatrixWorkspace_sptr &ws)
 Gets the eFixed value from the workspace using the instrument parameters.
 
EXPORT_OPT_MANTIDQT_COMMON std::string getEMode (const Mantid::API::MatrixWorkspace_sptr &ws)
 Gets the energy mode from a workspace based on the X unit.
 
std::string getIndexString (const MatrixWorkspace_sptr &workspace)
 
EXPORT_OPT_MANTIDQT_COMMON std::string getIndexString (const std::string &workspaceName)
 
EXPORT_OPT_MANTIDQT_COMMON bool getResolutionRangeFromWs (const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::pair< double, double > &res)
 Checks the workspace's instrument for a resolution parameter to use as a default for the energy range on the mini plot.
 
EXPORT_OPT_MANTIDQT_COMMON bool getResolutionRangeFromWs (const std::string &workspace, std::pair< double, double > &res)
 Checks the workspace's instrument for a resolution parameter to use as a default for the energy range on the mini plot.
 
EXPORT_OPT_MANTIDQT_COMMON std::string getWorkspaceBasename (const std::string &wsName)
 Returns the basename of a workspace (i.e.
 
EXPORT_OPT_MANTIDQT_COMMON std::string getWorkspaceSuffix (const std::string &wsName)
 Gets the suffix of a workspace (i.e.
 
EXPORT_OPT_MANTIDQT_COMMON std::pair< double, double > getXRangeFromWorkspace (const Mantid::API::MatrixWorkspace_const_sptr &workspace, double precision=0.00001)
 
EXPORT_OPT_MANTIDQT_COMMON std::pair< double, double > getXRangeFromWorkspace (std::string const &workspaceName, double precision=0.000001)
 
EXPORT_OPT_MANTIDQT_COMMON std::optional< std::size_t > maximumIndex (const Mantid::API::MatrixWorkspace_sptr &workspace)
 Gets the maximum number of histograms for a 2D Workspace.
 
EXPORT_OPT_MANTIDQT_COMMON std::string parseRunNumbers (std::vector< std::string > const &workspaceNames)
 Checks the name of the input workspace against a regexp for prefixes in the form instrName\#runNumber_..., where #runNumber is a number indicating the specific instrument run number that the workspace refers to.
 
template<typename T , typename Predicate >
void removeElementsIf (std::vector< T > &vector, Predicate const &filter)
 
template<typename Iterator , typename Functor >
std::vector< std::string > transformElements (Iterator const fromIter, Iterator const toIter, Functor const &functor)
 

Function Documentation

◆ attachPrefix()

std::vector< std::string > MantidQt::MantidWidgets::WorkspaceUtils::attachPrefix ( std::vector< std::string > const &  strings,
std::string const &  prefix 
)

Definition at line 224 of file WorkspaceUtils.cpp.

References transformElements().

◆ doAllWsExistInADS()

bool MantidQt::MantidWidgets::WorkspaceUtils::doAllWsExistInADS ( std::vector< std::string > const &  workspaceNames)

Definition at line 220 of file WorkspaceUtils.cpp.

◆ doesExistInADS()

bool MantidQt::MantidWidgets::WorkspaceUtils::doesExistInADS ( std::string const &  workspaceName)

◆ extractAxisLabels()

std::unordered_map< std::string, size_t > MantidQt::MantidWidgets::WorkspaceUtils::extractAxisLabels ( const Mantid::API::MatrixWorkspace_const_sptr workspace,
const size_t &  axisIndex 
)

Definition at line 98 of file WorkspaceUtils.cpp.

References Mantid::API::Axis::isText(), and workspace.

◆ getADSWorkspace() [1/2]

template<typename T = Mantid::API::MatrixWorkspace>
template EXPORT_OPT_MANTIDQT_COMMON std::shared_ptr< Mantid::API::ITableWorkspace_sptr > MantidQt::MantidWidgets::WorkspaceUtils::getADSWorkspace ( std::string const &  workspaceName)

◆ getADSWorkspace() [2/2]

template EXPORT_OPT_MANTIDQT_COMMON std::shared_ptr< Mantid::API::MatrixWorkspace_sptr > MantidQt::MantidWidgets::WorkspaceUtils::getADSWorkspace ( std::string const &  workspaceName)

◆ getEFixed()

std::optional< double > MantidQt::MantidWidgets::WorkspaceUtils::getEFixed ( const Mantid::API::MatrixWorkspace_sptr ws)

Gets the eFixed value from the workspace using the instrument parameters.

Parameters
wsPointer to the workspace
Returns
eFixed value

Definition at line 138 of file WorkspaceUtils.cpp.

◆ getEMode()

std::string MantidQt::MantidWidgets::WorkspaceUtils::getEMode ( const Mantid::API::MatrixWorkspace_sptr ws)

Gets the energy mode from a workspace based on the X unit.

Units of dSpacing typically denote diffraction, hence Elastic. All other units default to spectroscopy, therefore Indirect.

Parameters
wsPointer to the workspace
Returns
Energy mode

Definition at line 121 of file WorkspaceUtils.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and Mantid::API::Axis::unit().

◆ getIndexString() [1/2]

std::string MantidQt::MantidWidgets::WorkspaceUtils::getIndexString ( const MatrixWorkspace_sptr workspace)

Definition at line 52 of file WorkspaceUtils.cpp.

References maximumIndex(), std::to_string(), and workspace.

◆ getIndexString() [2/2]

std::string MantidQt::MantidWidgets::WorkspaceUtils::getIndexString ( const std::string &  workspaceName)

◆ getResolutionRangeFromWs() [1/2]

bool MantidQt::MantidWidgets::WorkspaceUtils::getResolutionRangeFromWs ( const Mantid::API::MatrixWorkspace_const_sptr workspace,
std::pair< double, double > &  res 
)

Checks the workspace's instrument for a resolution parameter to use as a default for the energy range on the mini plot.

Parameters
workspace:: Name of the workspace to use
res:: The retrieved values for the resolution parameter (if one was found)

Definition at line 179 of file WorkspaceUtils.cpp.

References workspace.

◆ getResolutionRangeFromWs() [2/2]

bool MantidQt::MantidWidgets::WorkspaceUtils::getResolutionRangeFromWs ( const std::string &  workspace,
std::pair< double, double > &  res 
)

Checks the workspace's instrument for a resolution parameter to use as a default for the energy range on the mini plot.

Parameters
workspace:: Name of the workspace to use
res:: The retrieved values for the resolution parameter (if one was found)

Definition at line 166 of file WorkspaceUtils.cpp.

References getResolutionRangeFromWs(), and workspace.

Referenced by getResolutionRangeFromWs().

◆ getWorkspaceBasename()

std::string MantidQt::MantidWidgets::WorkspaceUtils::getWorkspaceBasename ( const std::string &  wsName)

Returns the basename of a workspace (i.e.

the part before the last underscore)

e.g. basename of irs26176_graphite002_red is irs26176_graphite002

Parameters
wsNameName of workspace
Returns
Base name, or wsName if no underscore

Definition at line 83 of file WorkspaceUtils.cpp.

◆ getWorkspaceSuffix()

std::string MantidQt::MantidWidgets::WorkspaceUtils::getWorkspaceSuffix ( const std::string &  wsName)

Gets the suffix of a workspace (i.e.

part after last underscore (red, sqw)).

Parameters
wsNameName of workspace
Returns
Suffix, or empty string if no underscore

Definition at line 67 of file WorkspaceUtils.cpp.

◆ getXRangeFromWorkspace() [1/2]

std::pair< double, double > MantidQt::MantidWidgets::WorkspaceUtils::getXRangeFromWorkspace ( const Mantid::API::MatrixWorkspace_const_sptr workspace,
double  precision = 0.00001 
)

Definition at line 209 of file WorkspaceUtils.cpp.

References workspace.

Referenced by getXRangeFromWorkspace().

◆ getXRangeFromWorkspace() [2/2]

std::pair< double, double > MantidQt::MantidWidgets::WorkspaceUtils::getXRangeFromWorkspace ( std::string const &  workspaceName,
double  precision = 0.000001 
)

Definition at line 202 of file WorkspaceUtils.cpp.

References getXRangeFromWorkspace().

◆ maximumIndex()

std::optional< std::size_t > MantidQt::MantidWidgets::WorkspaceUtils::maximumIndex ( const Mantid::API::MatrixWorkspace_sptr workspace)

Gets the maximum number of histograms for a 2D Workspace.

Parameters
workspaceWorkspace pointer
Returns
size_t if index is found or null pointer if not found.

Definition at line 43 of file WorkspaceUtils.cpp.

References workspace.

Referenced by getIndexString().

◆ parseRunNumbers()

std::string MantidQt::MantidWidgets::WorkspaceUtils::parseRunNumbers ( std::vector< std::string > const &  workspaceNames)

Checks the name of the input workspace against a regexp for prefixes in the form instrName\#runNumber_..., where #runNumber is a number indicating the specific instrument run number that the workspace refers to.

As output, it returns a single string with format instrName#firstRunNumber-#finalRunNumber_..., if run numbers are found.

Parameters
workspaceNames:: a vector of strings containing a series of workspace names

Definition at line 237 of file WorkspaceUtils.cpp.

References name, std::to_string(), and transformElements().

◆ removeElementsIf()

template<typename T , typename Predicate >
void MantidQt::MantidWidgets::WorkspaceUtils::removeElementsIf ( std::vector< T > &  vector,
Predicate const &  filter 
)

Definition at line 64 of file WorkspaceUtils.h.

◆ transformElements()

template<typename Iterator , typename Functor >
std::vector< std::string > MantidQt::MantidWidgets::WorkspaceUtils::transformElements ( Iterator const  fromIter,
Iterator const  toIter,
Functor const &  functor 
)

Definition at line 57 of file WorkspaceUtils.h.

Referenced by attachPrefix(), and parseRunNumbers().