本文整理汇总了C++中api::IAlgorithm_sptr::getProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::getProperty方法的具体用法?C++ IAlgorithm_sptr::getProperty怎么用?C++ IAlgorithm_sptr::getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fitMosaic
/**
* Calls Gaussian1D as a child algorithm to fit the offset peak in a spectrum
* @param mosaic
* @param rcrystallite
* @param inname
* @param corrOption
* @param pointOption
* @param tofParams
* @return
*/
double OptimizeExtinctionParameters::fitMosaic(
double mosaic, double rcrystallite, std::string inname,
std::string corrOption, std::string pointOption, std::string tofParams) {
PeaksWorkspace_sptr inputW = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(inname));
std::vector<double> tofParam =
Kernel::VectorHelper::splitStringIntoVector<double>(tofParams);
if (mosaic < 0.0 || rcrystallite < 0.0)
return 1e300;
API::IAlgorithm_sptr tofextinction =
createChildAlgorithm("TOFExtinction", 0.0, 0.2);
tofextinction->setProperty("InputWorkspace", inputW);
tofextinction->setProperty("OutputWorkspace", "tmp");
tofextinction->setProperty("ExtinctionCorrectionType", corrOption);
tofextinction->setProperty<double>("Mosaic", mosaic);
tofextinction->setProperty<double>("Cell", tofParam[0]);
tofextinction->setProperty<double>("RCrystallite", rcrystallite);
tofextinction->executeAsChildAlg();
PeaksWorkspace_sptr peaksW = tofextinction->getProperty("OutputWorkspace");
API::IAlgorithm_sptr sorthkl = createChildAlgorithm("SortHKL", 0.0, 0.2);
sorthkl->setProperty("InputWorkspace", peaksW);
sorthkl->setProperty("OutputWorkspace", peaksW);
sorthkl->setProperty("PointGroup", pointOption);
sorthkl->executeAsChildAlg();
double Chisq = sorthkl->getProperty("OutputChi2");
std::cout << mosaic << " " << rcrystallite << " " << Chisq << "\n";
return Chisq;
}
示例2: exec
/**
* Execute the algorithm.
*/
void FitResolutionConvolvedModel::exec() {
API::IAlgorithm_sptr fit = createFittingAlgorithm();
fit->setPropertyValue("Function", createFunctionString());
fit->setProperty("InputWorkspace", getPropertyValue(INPUT_WS_NAME));
fit->setProperty("DomainType",
"Simple"); // Parallel not quite giving correct answers
fit->setProperty("Minimizer", "Levenberg-MarquardtMD");
const int maxIter = niterations();
fit->setProperty("MaxIterations", maxIter);
fit->setProperty("CreateOutput", true);
fit->setPropertyValue("Output", getPropertyValue(SIMULATED_NAME));
try {
fit->execute();
} catch (std::exception &exc) {
throw std::runtime_error(
std::string("FitResolutionConvolvedModel - Error running Fit: ") +
exc.what());
}
// Pass on the relevant properties
IMDEventWorkspace_sptr simulatedData = fit->getProperty("OutputWorkspace");
this->setProperty(SIMULATED_NAME, simulatedData);
if (this->existsProperty(OUTPUT_PARS)) {
ITableWorkspace_sptr outputPars = fit->getProperty("OutputParameters");
setProperty(OUTPUT_PARS, outputPars);
}
if (this->existsProperty(OUTPUTCOV_MATRIX)) {
ITableWorkspace_sptr covarianceMatrix =
fit->getProperty("OutputNormalisedCovarianceMatrix");
setProperty(OUTPUTCOV_MATRIX, covarianceMatrix);
}
}
示例3: createChildAlgorithm
/** Fit function
* Minimizer: "Levenberg-MarquardtMD"/"Simplex"
*/
bool RefinePowderInstrumentParameters2::doFitFunction(IFunction_sptr function, Workspace2D_sptr dataws, int wsindex,
string minimizer, int numiters, double& chi2, string& fitstatus)
{
// 0. Debug output
stringstream outss;
outss << "Fit function: " << m_positionFunc->asString() << endl << "Data To Fit: \n";
for (size_t i = 0; i < dataws->readX(0).size(); ++i)
outss << dataws->readX(wsindex)[i] << "\t\t" << dataws->readY(wsindex)[i] << "\t\t"
<< dataws->readE(wsindex)[i] << "\n";
g_log.information() << outss.str();
// 1. Create and setup fit algorithm
API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", 0.0, 0.2, true);
fitalg->initialize();
fitalg->setProperty("Function", function);
fitalg->setProperty("InputWorkspace", dataws);
fitalg->setProperty("WorkspaceIndex", wsindex);
fitalg->setProperty("Minimizer", minimizer);
fitalg->setProperty("CostFunction", "Least squares");
fitalg->setProperty("MaxIterations", numiters);
fitalg->setProperty("CalcErrors", true);
// 2. Fit
bool successfulfit = fitalg->execute();
if (!fitalg->isExecuted() || ! successfulfit)
{
// Early return due to bad fit
g_log.warning("Fitting to instrument geometry function failed. ");
chi2 = DBL_MAX;
fitstatus = "Minimizer throws exception.";
return false;
}
// 3. Understand solution
chi2 = fitalg->getProperty("OutputChi2overDoF");
string tempfitstatus = fitalg->getProperty("OutputStatus");
fitstatus = tempfitstatus;
bool goodfit = fitstatus.compare("success") == 0;
stringstream dbss;
dbss << "Fit Result (GSL): Chi^2 = " << chi2
<< "; Fit Status = " << fitstatus << ", Return Bool = " << goodfit << std::endl;
vector<string> funcparnames = function->getParameterNames();
for (size_t i = 0; i < funcparnames.size(); ++i)
dbss << funcparnames[i] << " = " << setw(20) << function->getParameter(funcparnames[i])
<< " +/- " << function->getError(i) << "\n";
g_log.debug() << dbss.str();
return goodfit;
}
示例4: editInstrument
/** Call edit instrument geometry
*/
API::MatrixWorkspace_sptr AlignAndFocusPowder::editInstrument(
API::MatrixWorkspace_sptr ws, std::vector<double> polars,
std::vector<specnum_t> specids, std::vector<double> l2s,
std::vector<double> phis) {
g_log.information() << "running EditInstrumentGeometry started at "
<< Kernel::DateAndTime::getCurrentTime() << "\n";
API::IAlgorithm_sptr editAlg = createChildAlgorithm("EditInstrumentGeometry");
editAlg->setProperty("Workspace", ws);
if (m_l1 > 0.)
editAlg->setProperty("PrimaryFlightPath", m_l1);
if (!polars.empty())
editAlg->setProperty("Polar", polars);
if (!specids.empty())
editAlg->setProperty("SpectrumIDs", specids);
if (!l2s.empty())
editAlg->setProperty("L2", l2s);
if (!phis.empty())
editAlg->setProperty("Azimuthal", phis);
editAlg->executeAsChildAlg();
ws = editAlg->getProperty("Workspace");
return ws;
}
示例5: removeExpDecay
/**
* Removes exponential decay from a workspace
* @param wsInput :: [input] Workspace to work on
* @return :: Workspace with decay removed
*/
API::MatrixWorkspace_sptr CalMuonDetectorPhases::removeExpDecay(
const API::MatrixWorkspace_sptr &wsInput) {
API::IAlgorithm_sptr remove = createChildAlgorithm("RemoveExpDecay");
remove->setProperty("InputWorkspace", wsInput);
remove->executeAsChildAlg();
API::MatrixWorkspace_sptr wsRem = remove->getProperty("OutputWorkspace");
return wsRem;
}
示例6: groupDetectors
/** Group detectors in the workspace.
* @param ws :: A local workspace
* @param spectraList :: A list of spectra to group.
*/
void PlotAsymmetryByLogValue::groupDetectors(API::MatrixWorkspace_sptr& ws,const std::vector<int>& spectraList)
{
API::IAlgorithm_sptr group = createChildAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace",ws);
group->setProperty("SpectraList",spectraList);
group->setProperty("KeepUngroupedSpectra",true);
group->execute();
ws = group->getProperty("OutputWorkspace");
}
示例7: Workspace_sptr
/**
* Return an output workspace property dealing with the lack of connection
* between of
* WorkspaceProperty types
* @param propName :: The name of the property
* @param loader :: The loader algorithm
* @returns A pointer to the OutputWorkspace property of the Child Algorithm
*/
API::Workspace_sptr
Load::getOutputWorkspace(const std::string &propName,
const API::IAlgorithm_sptr &loader) const {
// @todo Need to try and find a better way using the getValue methods
try {
return loader->getProperty(propName);
} catch (std::runtime_error &) {
}
// Try a MatrixWorkspace
try {
MatrixWorkspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
// EventWorkspace
try {
IEventWorkspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
// IMDEventWorkspace
try {
IMDEventWorkspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
// General IMDWorkspace
try {
IMDWorkspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
// ITableWorkspace?
try {
ITableWorkspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
// Just workspace?
try {
Workspace_sptr childWS = loader->getProperty(propName);
return childWS;
} catch (std::runtime_error &) {
}
g_log.debug() << "Workspace property " << propName
<< " did not return to MatrixWorkspace, EventWorkspace, "
"IMDEventWorkspace, IMDWorkspace\n";
return Workspace_sptr();
}
示例8: doSortHKL
/** Perform SortHKL on the output workspaces
*
* @param ws :: any PeaksWorkspace
* @param runName :: string to put in statistics table
*/
void StatisticsOfPeaksWorkspace::doSortHKL(Mantid::API::Workspace_sptr ws,
std::string runName) {
std::string pointGroup = getPropertyValue("PointGroup");
std::string latticeCentering = getPropertyValue("LatticeCentering");
std::string wkspName = getPropertyValue("OutputWorkspace");
std::string tableName = getPropertyValue("StatisticsTable");
API::IAlgorithm_sptr statsAlg = createChildAlgorithm("SortHKL");
statsAlg->setProperty("InputWorkspace", ws);
statsAlg->setPropertyValue("OutputWorkspace", wkspName);
statsAlg->setPropertyValue("StatisticsTable", tableName);
statsAlg->setProperty("PointGroup", pointGroup);
statsAlg->setProperty("LatticeCentering", latticeCentering);
statsAlg->setProperty("RowName", runName);
if (runName.compare("Overall") != 0)
statsAlg->setProperty("Append", true);
statsAlg->executeAsChildAlg();
PeaksWorkspace_sptr statsWksp = statsAlg->getProperty("OutputWorkspace");
ITableWorkspace_sptr tablews = statsAlg->getProperty("StatisticsTable");
if (runName.compare("Overall") == 0)
setProperty("OutputWorkspace", statsWksp);
setProperty("StatisticsTable", tablews);
}
示例9: createChildAlgorithm
/** Extracts relevant data from a workspace
* @param startTime :: [input] First X value to consider
* @param endTime :: [input] Last X value to consider
* @return :: Pre-processed workspace to fit
*/
API::MatrixWorkspace_sptr
CalMuonDetectorPhases::extractDataFromWorkspace(double startTime,
double endTime) {
// Extract counts from startTime to endTime
API::IAlgorithm_sptr crop = createChildAlgorithm("CropWorkspace");
crop->setProperty("InputWorkspace", m_inputWS);
crop->setProperty("XMin", startTime);
crop->setProperty("XMax", endTime);
crop->executeAsChildAlg();
boost::shared_ptr<API::MatrixWorkspace> wsCrop =
crop->getProperty("OutputWorkspace");
return wsCrop;
}
示例10: convertUnitsToDSpacing
/// Run ConvertUnits as a sub-algorithm to convert to dSpacing
MatrixWorkspace_sptr DiffractionFocussing::convertUnitsToDSpacing(const API::MatrixWorkspace_sptr& workspace)
{
const std::string CONVERSION_UNIT = "dSpacing";
Unit_const_sptr xUnit = workspace->getAxis(0)->unit();
g_log.information() << "Converting units from "<< xUnit->label() << " to " << CONVERSION_UNIT<<".\n";
API::IAlgorithm_sptr childAlg = createSubAlgorithm("ConvertUnits", 0.34, 0.66);
childAlg->setProperty("InputWorkspace", workspace);
childAlg->setPropertyValue("Target",CONVERSION_UNIT);
childAlg->executeAsSubAlg();
return childAlg->getProperty("OutputWorkspace");
}
示例11: ResampleX
/** Rebin
*/
API::MatrixWorkspace_sptr
AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) {
if (m_resampleX != 0) {
// ResampleX
g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX)
<< ", LogBinning=" << (m_resampleX < 0) << ", dMin("
<< m_dmins.size() << "), dmax(" << m_dmaxs.size()
<< ")) started at "
<< Kernel::DateAndTime::getCurrentTime() << "\n";
API::IAlgorithm_sptr alg = createChildAlgorithm("ResampleX");
alg->setProperty("InputWorkspace", matrixws);
alg->setProperty("OutputWorkspace", matrixws);
if ((!m_dmins.empty()) && (!m_dmaxs.empty())) {
size_t numHist = m_outputW->getNumberHistograms();
if ((numHist == m_dmins.size()) && (numHist == m_dmaxs.size())) {
alg->setProperty("XMin", m_dmins);
alg->setProperty("XMax", m_dmaxs);
} else {
g_log.information()
<< "Number of dmin and dmax values don't match the "
<< "number of workspace indices. Ignoring the parameters.\n";
}
}
alg->setProperty("NumberBins", abs(m_resampleX));
alg->setProperty("LogBinning", (m_resampleX < 0));
alg->executeAsChildAlg();
matrixws = alg->getProperty("OutputWorkspace");
return matrixws;
} else {
g_log.information() << "running Rebin( ";
for (double param : m_params)
g_log.information() << param << " ";
g_log.information() << ") started at "
<< Kernel::DateAndTime::getCurrentTime() << "\n";
API::IAlgorithm_sptr rebin3Alg = createChildAlgorithm("Rebin");
rebin3Alg->setProperty("InputWorkspace", matrixws);
rebin3Alg->setProperty("OutputWorkspace", matrixws);
rebin3Alg->setProperty("Params", m_params);
rebin3Alg->executeAsChildAlg();
matrixws = rebin3Alg->getProperty("OutputWorkspace");
return matrixws;
}
}
示例12: setOutputWorkspace
/**
* Set the output workspace(s) if the load's return workspace has type
* API::Workspace
* @param loader :: Shared pointer to load algorithm
*/
void LoadNexus::setOutputWorkspace(const API::IAlgorithm_sptr &loader) {
// Go through each OutputWorkspace property and check whether we need to make
// a counterpart here
const std::vector<Property *> &loaderProps = loader->getProperties();
const size_t count = loader->propertyCount();
for (size_t i = 0; i < count; ++i) {
Property *prop = loaderProps[i];
if (dynamic_cast<IWorkspaceProperty *>(prop) &&
prop->direction() == Direction::Output) {
const std::string &name = prop->name();
if (!this->existsProperty(name)) {
declareProperty(new WorkspaceProperty<Workspace>(
name, loader->getPropertyValue(name), Direction::Output));
}
Workspace_sptr wkspace = loader->getProperty(name);
setProperty(name, wkspace);
}
}
}
示例13: createChildAlgorithm
/** Call diffraction focus to a matrix workspace.
*/
API::MatrixWorkspace_sptr
AlignAndFocusPowder::diffractionFocus(API::MatrixWorkspace_sptr ws) {
if (!m_groupWS) {
g_log.information() << "not focussing data\n";
return ws;
}
g_log.information() << "running DiffractionFocussing. \n";
API::IAlgorithm_sptr focusAlg = createChildAlgorithm("DiffractionFocussing");
focusAlg->setProperty("InputWorkspace", ws);
focusAlg->setProperty("OutputWorkspace", ws);
focusAlg->setProperty("GroupingWorkspace", m_groupWS);
focusAlg->setProperty("PreserveEvents", m_preserveEvents);
focusAlg->executeAsChildAlg();
ws = focusAlg->getProperty("OutputWorkspace");
return ws;
}
示例14: RebinWorkspace
/// Run Rebin as a Child Algorithm to harmonise the bin boundaries
void DiffractionFocussing::RebinWorkspace(
API::MatrixWorkspace_sptr &workspace) {
double min = 0;
double max = 0;
double step = 0;
calculateRebinParams(workspace, min, max, step);
std::vector<double> paramArray{min, -step, max};
g_log.information() << "Rebinning from " << min << " to " << max << " in "
<< step << " logaritmic steps.\n";
API::IAlgorithm_sptr childAlg = createChildAlgorithm("Rebin");
childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", workspace);
childAlg->setProperty<std::vector<double>>("Params", paramArray);
childAlg->executeAsChildAlg();
workspace = childAlg->getProperty("OutputWorkspace");
}
示例15: fitBackgroundFunction
/** Fit background function
*/
void ProcessBackground::fitBackgroundFunction(std::string bkgdfunctiontype) {
// Get background type and create bakground function
BackgroundFunction_sptr bkgdfunction =
createBackgroundFunction(bkgdfunctiontype);
int bkgdorder = getProperty("OutputBackgroundOrder");
bkgdfunction->setAttributeValue("n", bkgdorder);
if (bkgdfunctiontype == "Chebyshev") {
double xmin = m_outputWS->readX(0).front();
double xmax = m_outputWS->readX(0).back();
g_log.information() << "Chebyshev Fit range: " << xmin << ", " << xmax
<< "\n";
bkgdfunction->setAttributeValue("StartX", xmin);
bkgdfunction->setAttributeValue("EndX", xmax);
}
g_log.information() << "Fit selected background " << bkgdfunctiontype
<< " to data workspace with "
<< m_outputWS->getNumberHistograms() << " spectra."
<< "\n";
// Fit input (a few) background pionts to get initial guess
API::IAlgorithm_sptr fit;
try {
fit = this->createChildAlgorithm("Fit", 0.9, 1.0, true);
} catch (Exception::NotFoundError &) {
g_log.error() << "Requires CurveFitting library." << std::endl;
throw;
}
g_log.information() << "Fitting background function: "
<< bkgdfunction->asString() << "\n";
double startx = m_lowerBound;
double endx = m_upperBound;
fit->setProperty("Function",
boost::dynamic_pointer_cast<API::IFunction>(bkgdfunction));
fit->setProperty("InputWorkspace", m_outputWS);
fit->setProperty("WorkspaceIndex", 0);
fit->setProperty("MaxIterations", 500);
fit->setProperty("StartX", startx);
fit->setProperty("EndX", endx);
fit->setProperty("Minimizer", "Levenberg-MarquardtMD");
fit->setProperty("CostFunction", "Least squares");
fit->executeAsChildAlg();
// Get fit status and chi^2
std::string fitStatus = fit->getProperty("OutputStatus");
bool allowedfailure = (fitStatus.find("cannot") < fitStatus.size()) &&
(fitStatus.find("tolerance") < fitStatus.size());
if (fitStatus.compare("success") != 0 && !allowedfailure) {
g_log.error() << "ProcessBackground: Fit Status = " << fitStatus
<< ". Not to update fit result" << std::endl;
throw std::runtime_error("Bad Fit");
}
const double chi2 = fit->getProperty("OutputChi2overDoF");
g_log.information() << "Fit background: Fit Status = " << fitStatus
<< ", chi2 = " << chi2 << "\n";
// Get out the parameter names
API::IFunction_sptr funcout = fit->getProperty("Function");
TableWorkspace_sptr outbkgdparws = boost::make_shared<TableWorkspace>();
outbkgdparws->addColumn("str", "Name");
outbkgdparws->addColumn("double", "Value");
TableRow typerow = outbkgdparws->appendRow();
typerow << bkgdfunctiontype << 0.;
vector<string> parnames = funcout->getParameterNames();
size_t nparam = funcout->nParams();
for (size_t i = 0; i < nparam; ++i) {
TableRow newrow = outbkgdparws->appendRow();
newrow << parnames[i] << funcout->getParameter(i);
}
TableRow chi2row = outbkgdparws->appendRow();
chi2row << "Chi-square" << chi2;
g_log.information() << "Set table workspace (#row = "
<< outbkgdparws->rowCount()
<< ") to OutputBackgroundParameterTable. "
<< "\n";
setProperty("OutputBackgroundParameterWorkspace", outbkgdparws);
// Set output workspace
const MantidVec &vecX = m_outputWS->readX(0);
const MantidVec &vecY = m_outputWS->readY(0);
FunctionDomain1DVector domain(vecX);
FunctionValues values(domain);
funcout->function(domain, values);
MantidVec &dataModel = m_outputWS->dataY(1);
MantidVec &dataDiff = m_outputWS->dataY(2);
for (size_t i = 0; i < dataModel.size(); ++i) {
//.........这里部分代码省略.........