Mantid
|
#include <TableWorkspaceDomainCreator.h>
Public Member Functions | |
void | createDomain (std::shared_ptr< API::FunctionDomain > &domain, std::shared_ptr< API::FunctionValues > &values, size_t i0=0) override |
Create a domain from the input workspace. More... | |
std::shared_ptr< API::Workspace > | createOutputWorkspace (const std::string &baseName, API::IFunction_sptr function, std::shared_ptr< API::FunctionDomain > domain, std::shared_ptr< API::FunctionValues > values, const std::string &outputWorkspacePropertyName) override |
Create an output workspace with the calculated values. More... | |
void | declareDatasetProperties (const std::string &suffix="", bool addProp=true) override |
Declare properties that specify the dataset within the workspace to fit to. More... | |
size_t | getDomainSize () const override |
Return the size of the domain to be created. More... | |
void | initFunction (API::IFunction_sptr function) override |
Initialize the function with the workspace. More... | |
void | setColumnNames (const std::string &xColName, const std::string &yColName, const std::string &errColName) const |
Set the names Of the x, y and error columns. More... | |
void | setMaxSize (size_t maxSize) |
Set max size for Sequential and Parallel domains. More... | |
void | setRange (double startX, double endX) |
Set the startX and endX. More... | |
void | setWorkspace (API::ITableWorkspace_sptr ws) |
Set the workspace. More... | |
TableWorkspaceDomainCreator (DomainType domainType=Simple) | |
Constructor. More... | |
TableWorkspaceDomainCreator (Kernel::IPropertyManager *fit, const std::string &workspacePropertyName, DomainType domainType=Simple) | |
Constructor. More... | |
Public Member Functions inherited from Mantid::API::IDomainCreator | |
virtual void | createDomain (std::shared_ptr< API::FunctionDomain > &domain, std::shared_ptr< API::FunctionValues > &values, size_t i0=0)=0 |
Create a domain and values from the input workspace. More... | |
virtual std::shared_ptr< API::Workspace > | createOutputWorkspace (const std::string &baseName, API::IFunction_sptr function, std::shared_ptr< API::FunctionDomain > domain, std::shared_ptr< API::FunctionValues > values, const std::string &outputWorkspacePropertyName="OutputWorkspace") |
Create an output workspace filled with data simulated with the fitting function. More... | |
virtual void | declareDatasetProperties (const std::string &suffix="", bool addProp=true) |
Declare properties that specify the dataset within the workspace to fit to. More... | |
virtual size_t | getDomainSize () const =0 |
Return the size of the domain to be created. More... | |
IDomainCreator (Kernel::IPropertyManager *manager, std::vector< std::string > workspacePropertyNames, DomainType domainType=Simple) | |
Constrcutor. More... | |
void | ignoreInvalidData (bool yes) |
Set to ignore invalid data. More... | |
virtual void | initFunction (API::IFunction_sptr function) |
Initialize the function. More... | |
virtual void | initialize (Kernel::IPropertyManager *, const std::string &, DomainType) |
Initialize. More... | |
void | separateCompositeMembersInOutput (const bool value, const bool conv=false) |
Toggle output of either just composite or composite + members. More... | |
virtual | ~IDomainCreator ()=default |
Virtual destructor. More... | |
Private Member Functions | |
void | addFunctionValuesToWS (const API::IFunction_sptr &function, std::shared_ptr< API::MatrixWorkspace > &ws, const size_t wsIndex, const std::shared_ptr< API::FunctionDomain > &domain, const std::shared_ptr< API::FunctionValues > &resultValues) const |
Add the calculated function values to the workspace. More... | |
void | appendCompositeFunctionMembers (std::list< API::IFunction_sptr > &functionList, const API::IFunction_sptr &function) const |
void | appendConvolvedCompositeFunctionMembers (std::list< API::IFunction_sptr > &functionList, const API::IFunction_sptr &function) const |
If the fit function is Convolution and flag m_convolutionCompositeMembers is set and Convolution's second function (the model) is composite then use members of the model for the output. More... | |
std::shared_ptr< API::MatrixWorkspace > | createEmptyResultWS (const size_t nhistograms, const size_t nyvalues) |
Creates the blank output workspace of the correct size. More... | |
std::pair< size_t, size_t > | getXInterval (std::vector< double > XData) const |
Calculate size and starting iterator in the X array. More... | |
void | setAndValidateWorkspace (const API::Workspace_sptr &ws) const |
Check workspace is in the correct form. More... | |
void | setInitialValues (API::IFunction &function) |
Set initial values for parameters with default values. More... | |
void | setParameters () const |
Set all parameters. More... | |
void | setXYEColumnNames (const API::ITableWorkspace_sptr &ws) const |
Set the names of the X, Y and Error columns. More... | |
Private Attributes | |
std::weak_ptr< API::FunctionDomain1D > | m_domain |
Store the created domain and values. More... | |
double | m_endX |
endX More... | |
std::string | m_endXPropertyName |
Store endX property name. More... | |
std::string | m_errColName |
Store the Y Error column name. More... | |
std::string | m_errorColumnPropertyName |
Store errorColumnName property name. More... | |
std::vector< double > | m_exclude |
Ranges that must be excluded from fit. More... | |
std::string | m_excludePropertyName |
Store the Exclude property name. More... | |
size_t | m_maxSize |
Max size for seq domain. More... | |
std::string | m_maxSizePropertyName |
Store maxSize property name. More... | |
bool | m_noErrCol |
Flag to indicate if no error column was found. More... | |
size_t | m_startRowNo |
Store number of the first row used in fitting. More... | |
double | m_startX |
startX More... | |
std::string | m_startXPropertyName |
Store startX property name. More... | |
API::ITableWorkspace_sptr | m_tableWorkspace |
The input TableWorkspace. More... | |
std::weak_ptr< API::FunctionValues > | m_values |
std::string | m_workspacePropertyName |
Store workspace property name. More... | |
std::string | m_xColName |
Store the X column name. More... | |
std::string | m_xColumnPropertyName |
Store XColumnName property name. More... | |
std::string | m_yColName |
Store the Y column name. More... | |
std::string | m_yColumnPropertyName |
Store YColumnName property name. More... | |
Additional Inherited Members | |
Public Types inherited from Mantid::API::IDomainCreator | |
enum | DomainType { Simple = 0 , Sequential , Parallel } |
Type of domain to create. More... | |
Protected Member Functions inherited from Mantid::API::IDomainCreator | |
void | declareProperty (Kernel::Property *prop, const std::string &doc) |
Declare a property to the algorithm. More... | |
Protected Attributes inherited from Mantid::API::IDomainCreator | |
bool | m_convolutionCompositeMembers |
Perform convolution of output composite components. More... | |
DomainType | m_domainType |
Domain type. More... | |
bool | m_ignoreInvalidData |
Flag to ignore nans, infinities and zero errors. More... | |
Kernel::IPropertyManager * | m_manager |
Pointer to a property manager. More... | |
bool | m_outputCompositeMembers |
Output separate composite function values. More... | |
std::vector< std::string > | m_workspacePropertyNames |
Property names for workspaces to get the data from. More... | |
Definition at line 31 of file TableWorkspaceDomainCreator.h.
Mantid::CurveFitting::TableWorkspaceDomainCreator::TableWorkspaceDomainCreator | ( | Kernel::IPropertyManager * | fit, |
const std::string & | workspacePropertyName, | ||
TableWorkspaceDomainCreator::DomainType | domainType = Simple |
||
) |
Constructor.
fit | :: Property manager with properties defining the domain to be created |
workspacePropertyName | :: Name of the workspace property. |
domainType | :: Type of the domain: Simple, Sequential, or Parallel. |
Definition at line 122 of file TableWorkspaceDomainCreator.cpp.
References m_workspacePropertyName, and Mantid::API::IDomainCreator::m_workspacePropertyNames.
Mantid::CurveFitting::TableWorkspaceDomainCreator::TableWorkspaceDomainCreator | ( | TableWorkspaceDomainCreator::DomainType | domainType = Simple | ) |
Constructor.
Methods setWorkspace and setRange must becalled set up the creator.
domainType | :: Type of the domain: Simple, Sequential, or Parallel. |
Definition at line 138 of file TableWorkspaceDomainCreator.cpp.
|
private |
Add the calculated function values to the workspace.
Estimate an error for each calculated value.
function | The function to evaluate |
ws | A workspace to fill |
wsIndex | The index to store the values |
domain | The domain to calculate the values over |
resultValues | A presized values holder for the results |
Definition at line 428 of file TableWorkspaceDomainCreator.cpp.
References Mantid::Geometry::d, Mantid::API::Jacobian::get(), sigma, and tmp.
Referenced by createOutputWorkspace().
|
private |
functionList | The current list of functions to append to |
function | A function that may or not be composite |
Definition at line 363 of file TableWorkspaceDomainCreator.cpp.
References appendCompositeFunctionMembers(), appendConvolvedCompositeFunctionMembers(), and Mantid::API::IDomainCreator::m_convolutionCompositeMembers.
Referenced by appendCompositeFunctionMembers(), and createOutputWorkspace().
|
private |
If the fit function is Convolution and flag m_convolutionCompositeMembers is set and Convolution's second function (the model) is composite then use members of the model for the output.
functionList | :: A list of Convolutions constructed from the resolution of the fitting function (index 0) and members of the model. |
function | A Convolution function which model may or may not be a composite function. |
Definition at line 399 of file TableWorkspaceDomainCreator.cpp.
Referenced by appendCompositeFunctionMembers().
|
overridevirtual |
Create a domain from the input workspace.
Implements Mantid::API::IDomainCreator.
Definition at line 186 of file TableWorkspaceDomainCreator.cpp.
References Mantid::CurveFitting::SeqDomain::addCreator(), Mantid::CurveFitting::SeqDomain::create(), error, getXInterval(), Mantid::CurveFitting::ExcludeRangeFinder::isExcluded(), Mantid::Geometry::m, m_domain, Mantid::API::IDomainCreator::m_domainType, m_errColName, m_exclude, Mantid::API::IDomainCreator::m_ignoreInvalidData, m_maxSize, m_noErrCol, m_startRowNo, m_tableWorkspace, m_values, m_xColName, m_yColName, n, setParameters(), setWorkspace(), Mantid::API::IDomainCreator::Simple, Mantid::Geometry::X, Mantid::Geometry::Y, and Mantid::Geometry::y.
|
private |
Creates the blank output workspace of the correct size.
Creates a workspace to hold the results.
If the input workspace contains histogram data then so will this It assigns the X and input data values but no Y,E data for any functions
nhistograms | The number of histograms |
nyvalues | The number of y values to hold |
Definition at line 533 of file TableWorkspaceDomainCreator.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_errColName, m_startRowNo, m_tableWorkspace, m_xColName, and m_yColName.
Referenced by createOutputWorkspace().
|
overridevirtual |
Create an output workspace with the calculated values.
baseName | :: Specifies the name of the output workspace |
function | :: A Pointer to the fitting function |
domain | :: The domain containing x-values for the function |
values | :: A API::FunctionValues instance containing the fitting data |
outputWorkspacePropertyName | :: The property name |
Reimplemented from Mantid::API::IDomainCreator.
Definition at line 299 of file TableWorkspaceDomainCreator.cpp.
References addFunctionValuesToWS(), appendCompositeFunctionMembers(), createEmptyResultWS(), Mantid::API::IDomainCreator::declareProperty(), Mantid::API::IDomainCreator::m_manager, Mantid::API::IDomainCreator::m_outputCompositeMembers, Mantid::Kernel::Direction::Output, Mantid::API::TextAxis::setLabel(), Mantid::Kernel::IPropertyManager::setProperty(), and Mantid::Kernel::IPropertyManager::setPropertyValue().
|
overridevirtual |
Declare properties that specify the dataset within the workspace to fit to.
suffix | :: names the dataset |
addProp | :: allows for the declaration of certain properties of the dataset |
Reimplemented from Mantid::API::IDomainCreator.
Definition at line 148 of file TableWorkspaceDomainCreator.cpp.
References Mantid::API::IDomainCreator::declareProperty(), Mantid::EMPTY_DBL(), Mantid::Kernel::IPropertyManager::existsProperty(), Mantid::API::IDomainCreator::m_domainType, m_endXPropertyName, m_errorColumnPropertyName, m_excludePropertyName, Mantid::API::IDomainCreator::m_manager, m_maxSizePropertyName, m_startXPropertyName, m_xColumnPropertyName, m_yColumnPropertyName, and Mantid::API::IDomainCreator::Simple.
|
overridevirtual |
Return the size of the domain to be created.
Implements Mantid::API::IDomainCreator.
Definition at line 573 of file TableWorkspaceDomainCreator.cpp.
References getXInterval(), m_tableWorkspace, m_xColName, setParameters(), and Mantid::Geometry::X.
|
private |
Calculate size and starting iterator in the X array.
Definition at line 615 of file TableWorkspaceDomainCreator.cpp.
References Mantid::EMPTY_DBL(), m_endX, m_startX, and setParameters().
Referenced by createDomain(), and getDomainSize().
|
overridevirtual |
Initialize the function with the workspace.
function | :: Function to initialize. |
Reimplemented from Mantid::API::IDomainCreator.
Definition at line 590 of file TableWorkspaceDomainCreator.cpp.
References m_tableWorkspace, setInitialValues(), and setParameters().
|
private |
Check workspace is in the correct form.
Set the table workspace.
Clones the input workspace and makes workspace into form: x data | y data | error data
std::runtime_error | if the Exclude property has an odd number of entries. |
Definition at line 756 of file TableWorkspaceDomainCreator.cpp.
References m_errColName, m_noErrCol, m_tableWorkspace, m_xColName, m_yColName, and setXYEColumnNames().
Referenced by setParameters().
|
inline |
Set the names Of the x, y and error columns.
xColName | :: name of the x column |
yColName | :: name of the y column |
errColName | :: name of the y error column |
Definition at line 70 of file TableWorkspaceDomainCreator.h.
Referenced by setXYEColumnNames().
|
private |
Set initial values for parameters with default values.
function | : A function to set parameters for. |
Definition at line 603 of file TableWorkspaceDomainCreator.cpp.
References Mantid::CurveFitting::ParameterEstimator::estimate(), m_domain, and m_values.
Referenced by initFunction().
|
inline |
Set max size for Sequential and Parallel domains.
maxSize | :: Maximum size of each simple domain |
Definition at line 64 of file TableWorkspaceDomainCreator.h.
|
private |
Set all parameters.
std::runtime_error | if the Exclude property has an odd number of entries. |
Definition at line 668 of file TableWorkspaceDomainCreator.cpp.
References Mantid::Kernel::IPropertyManager::getProperty(), Mantid::API::IDomainCreator::m_domainType, m_endX, m_endXPropertyName, m_exclude, m_excludePropertyName, Mantid::API::IDomainCreator::m_manager, m_maxSize, m_maxSizePropertyName, m_startX, m_startXPropertyName, m_workspacePropertyName, setAndValidateWorkspace(), and Mantid::API::IDomainCreator::Simple.
Referenced by createDomain(), getDomainSize(), getXInterval(), and initFunction().
|
inline |
Set the startX and endX.
startX | :: Start of the domain |
endX | :: End of the domain |
Definition at line 58 of file TableWorkspaceDomainCreator.h.
|
inline |
Set the workspace.
ws | :: workspace to set. |
Definition at line 54 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain().
|
private |
Set the names of the X, Y and Error columns.
Get the X, Y and Error column names as a vector.
If no error column is found there will only be 2 entries in the vector. Gets the name from arguments if specified otherwise it check if any columns have been set as plot type X, Y or Yerror. If none found it will return an error
std::invalid_argument | if no X or Y value can be found or are of the wrong type. |
Definition at line 701 of file TableWorkspaceDomainCreator.cpp.
References Mantid::Kernel::IPropertyManager::getProperty(), m_errorColumnPropertyName, Mantid::API::IDomainCreator::m_manager, m_xColumnPropertyName, m_yColumnPropertyName, and setColumnNames().
Referenced by setAndValidateWorkspace().
|
private |
Store the created domain and values.
Definition at line 130 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and setInitialValues().
|
mutableprivate |
endX
Definition at line 124 of file TableWorkspaceDomainCreator.h.
Referenced by getXInterval(), and setParameters().
|
private |
Store endX property name.
Definition at line 111 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setParameters().
|
mutableprivate |
Store the Y Error column name.
Definition at line 144 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), createEmptyResultWS(), and setAndValidateWorkspace().
|
private |
Store errorColumnName property name.
Definition at line 117 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setXYEColumnNames().
|
mutableprivate |
Ranges that must be excluded from fit.
Definition at line 128 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and setParameters().
|
private |
Store the Exclude property name.
Definition at line 135 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setParameters().
|
mutableprivate |
Max size for seq domain.
Definition at line 126 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and setParameters().
|
private |
Store maxSize property name.
Definition at line 133 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setParameters().
|
mutableprivate |
Flag to indicate if no error column was found.
Definition at line 147 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and setAndValidateWorkspace().
|
private |
Store number of the first row used in fitting.
Definition at line 138 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and createEmptyResultWS().
|
mutableprivate |
startX
Definition at line 122 of file TableWorkspaceDomainCreator.h.
Referenced by getXInterval(), and setParameters().
|
private |
Store startX property name.
Definition at line 109 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setParameters().
|
mutableprivate |
The input TableWorkspace.
Definition at line 120 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), createEmptyResultWS(), getDomainSize(), initFunction(), and setAndValidateWorkspace().
|
private |
Definition at line 131 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), and setInitialValues().
|
private |
Store workspace property name.
Definition at line 107 of file TableWorkspaceDomainCreator.h.
Referenced by setParameters(), and TableWorkspaceDomainCreator().
|
mutableprivate |
Store the X column name.
Definition at line 140 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), createEmptyResultWS(), getDomainSize(), and setAndValidateWorkspace().
|
private |
Store XColumnName property name.
Definition at line 113 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setXYEColumnNames().
|
mutableprivate |
Store the Y column name.
Definition at line 142 of file TableWorkspaceDomainCreator.h.
Referenced by createDomain(), createEmptyResultWS(), and setAndValidateWorkspace().
|
private |
Store YColumnName property name.
Definition at line 115 of file TableWorkspaceDomainCreator.h.
Referenced by declareDatasetProperties(), and setXYEColumnNames().