本文整理汇总了C++中api::IAlgorithm_sptr类的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr类的具体用法?C++ IAlgorithm_sptr怎么用?C++ IAlgorithm_sptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IAlgorithm_sptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:dezed,项目名称:mantid,代码行数:40,代码来源:OptimizeExtinctionParameters.cpp
示例2: createChildAlgorithm
/**
* Places the detector at the right sample_detector_distance
*/
void LoadSpice2D::moveDetector(double sample_detector_distance,
double translation_distance) {
// Some tests fail if the detector is moved here.
// TODO: Move the detector here and not the SANSLoad
UNUSED_ARG(translation_distance);
// Move the detector to the right position
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
// Finding the name of the detector object.
std::string detID =
m_workspace->getInstrument()->getStringParameter("detector-name")[0];
g_log.information("Moving " + detID);
try {
mover->setProperty<API::MatrixWorkspace_sptr>("Workspace", m_workspace);
mover->setProperty("ComponentName", detID);
mover->setProperty("Z", sample_detector_distance / 1000.0);
// mover->setProperty("X", -translation_distance);
mover->execute();
} catch (std::invalid_argument &e) {
g_log.error("Invalid argument to MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
} catch (std::runtime_error &e) {
g_log.error(
"Unable to successfully run MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
}
}
开发者ID:stuartcampbell,项目名称:mantid,代码行数:32,代码来源:LoadSpice2D.cpp
示例3: startingHandle
/** Handler of the start notifications. Adds an algorithm call to the script.
* @param alg :: Shared pointer to the starting algorithm.
*/
void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg)
{
auto props= alg->getProperties();
std::string algString;
for(auto p = props.begin() ; p != props.end(); ++p)
{
std::string opener = "='";
if ((**p).value().find('\\') != std::string::npos )
{
opener= "=r'";
}
std::string paramString = (**p).name() + opener + (**p).value() + "'";
// Miss out parameters that are empty.
if(paramString.length() != 0)
{
if(algString.length() != 0)
{
algString += ",";
}
algString += paramString;
}
}
m_generatedScript += alg->name() + "(" + algString + ")\n";
}
开发者ID:BigShows,项目名称:mantid,代码行数:31,代码来源:RecordPythonScript.cpp
示例4: 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;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:CalMuonDetectorPhases.cpp
示例5: 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;
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:27,代码来源:AlignAndFocusPowder.cpp
示例6: createAlgorithmDocs
std::string FrameworkManagerProxy::createAlgorithmDocs(const std::string& algName, const int version)
{
const std::string EOL="\n";
API::IAlgorithm_sptr algm = API::AlgorithmManager::Instance().createUnmanaged(algName, version);
algm->initialize();
// Put in the quick overview message
std::stringstream buffer;
std::string temp = algm->getOptionalMessage();
if (temp.size() > 0)
buffer << temp << EOL << EOL;
// get a sorted copy of the properties
PropertyVector properties(algm->getProperties());
std::sort(properties.begin(), properties.end(), PropertyOrdering());
// generate the sanitized names
StringVector names(properties.size());
size_t numProps = properties.size();
for ( size_t i = 0; i < numProps; ++i)
{
names[i] = removeCharacters(properties[i]->name(), "");
}
buffer << "Property descriptions: " << EOL << EOL;
// write the actual property descriptions
Mantid::Kernel::Property *prop;
for ( size_t i = 0; i < numProps; ++i)
{
prop = properties[i];
buffer << names[i] << "("
<< Mantid::Kernel::Direction::asText(prop->direction());
if (!prop->isValid().empty())
buffer << ":req";
buffer << ") *" << prop->type() << "* ";
std::set<std::string> allowed = prop->allowedValues();
if (!prop->documentation().empty() || !allowed.empty())
{
buffer << " " << prop->documentation();
if (!allowed.empty())
{
buffer << " [" << Kernel::Strings::join(allowed.begin(), allowed.end(), ", ");
buffer << "]";
}
buffer << EOL;
if( i < numProps - 1 ) buffer << EOL;
}
}
return buffer.str();
}
开发者ID:trnielsen,项目名称:mantid,代码行数:51,代码来源:FrameworkManagerProxy.cpp
示例7: createLoader
/**
* Create the concrete instance use for the actual loading.
* @param startProgress :: The percentage progress value of the overall
* algorithm where this child algorithm starts
* @param endProgress :: The percentage progress value of the overall
* algorithm where this child algorithm ends
* @param logging :: Set to false to disable logging from the child algorithm
*/
API::IAlgorithm_sptr Load::createLoader(const double startProgress,
const double endProgress,
const bool logging) const {
std::string name = getPropertyValue("LoaderName");
int version = getProperty("LoaderVersion");
API::IAlgorithm_sptr loader =
API::AlgorithmManager::Instance().createUnmanaged(name, version);
loader->initialize();
if (!loader) {
throw std::runtime_error("Cannot create loader for \"" +
getPropertyValue("Filename") + "\"");
}
setUpLoader(loader, startProgress, endProgress, logging);
return loader;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:23,代码来源:Load.cpp
示例8: 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");
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例9: declareLoaderProperties
/**
* Declare any additional properties of the concrete loader here
* @param loader A pointer to the concrete loader
*/
void Load::declareLoaderProperties(const API::IAlgorithm_sptr &loader) {
// If we have switch loaders then the concrete loader will have different
// properties
// so take care of ensuring Load has the correct ones
// THIS IS A COPY as the properties are mutated as we move through them
const std::vector<Property *> existingProps = this->getProperties();
for (auto existingProp : existingProps) {
const std::string &name = existingProp->name();
// Wipe all properties except the Load native ones
if (m_baseProps.find(name) == m_baseProps.end()) {
this->removeProperty(name);
}
}
const std::vector<Property *> &loaderProps = loader->getProperties();
size_t numProps(loaderProps.size());
for (size_t i = 0; i < numProps; ++i) {
Property *loadProp = loaderProps[i];
if (loadProp->name() == m_filenamePropName)
continue;
try {
auto propClone = std::unique_ptr<Property>(loadProp->clone());
propClone->clearSettings(); // Get rid of special settings because it
// does not work in custom GUI.
declareProperty(std::move(propClone), loadProp->documentation());
} catch (Exception::ExistsError &) {
// Already exists as a static property
continue;
}
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:35,代码来源:Load.cpp
示例10: createChildAlgorithm
void LoadNexusMonitors2::runLoadLogs(const std::string filename,
API::MatrixWorkspace_sptr localWorkspace) {
// do the actual work
API::IAlgorithm_sptr loadLogs = createChildAlgorithm("LoadNexusLogs");
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
g_log.information() << "Loading logs from NeXus file..." << std::endl;
loadLogs->setPropertyValue("Filename", filename);
loadLogs->setProperty<API::MatrixWorkspace_sptr>("Workspace",
localWorkspace);
loadLogs->execute();
} catch (...) {
g_log.error() << "Error while loading Logs from Nexus. Some sample logs "
"may be missing." << std::endl;
}
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:17,代码来源:LoadNexusMonitors2.cpp
示例11: setOutputWorkspace
/**
* Set the output workspace(s) if the load's return workspace has type
* API::Workspace
* @param loader :: Shared pointer to load algorithm
*/
void Load::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(Kernel::make_unique<WorkspaceProperty<Workspace>>(
name, loader->getPropertyValue(name), Direction::Output));
}
Workspace_sptr wkspace = getOutputWorkspace(name, loader);
setProperty(name, wkspace);
}
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:24,代码来源:Load.cpp
示例12: 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");
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:20,代码来源:DiffractionFocussing.cpp
示例13: 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();
}
开发者ID:mantidproject,项目名称:mantid,代码行数:64,代码来源:Load.cpp
示例14: findFilenameProperty
void Load::findFilenameProperty(const API::IAlgorithm_sptr &loader) {
// Use the first file property as the main Filename
const auto &props = loader->getProperties();
for (auto prop : props) {
auto *fp = dynamic_cast<API::MultipleFileProperty *>(prop);
auto *fp2 = dynamic_cast<API::FileProperty *>(prop);
if (fp) {
m_filenamePropName = fp->name();
break;
}
if (fp2) {
m_filenamePropName = fp2->name();
break;
}
}
if (m_filenamePropName.empty()) {
setPropertyValue("LoaderName", "");
setProperty("LoaderVersion", -1);
throw std::runtime_error("Cannot find FileProperty on " + loader->name() +
" algorithm.");
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:22,代码来源:Load.cpp
示例15: setUpLoader
/**
* Set the loader option for use as a Child Algorithm.
* @param loader :: Concrete loader
* @param startProgress :: The start progress fraction
* @param endProgress :: The end progress fraction
* @param logging:: If true, enable logging
*/
void Load::setUpLoader(API::IAlgorithm_sptr &loader, const double startProgress,
const double endProgress, const bool logging) const {
// Set as a child so that we are in control of output storage
loader->setChild(true);
loader->setLogging(logging);
// If output workspaces are nameless, give them a temporary name to satisfy
// validator
const std::vector<Property *> &props = loader->getProperties();
for (auto prop : props) {
auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (wsProp && !wsProp->isOptional() &&
prop->direction() == Direction::Output) {
if (prop->value().empty())
prop->setValue("LoadChildWorkspace");
}
}
if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) {
loader->addObserver(this->progressObserver());
setChildStartProgress(startProgress);
setChildEndProgress(endProgress);
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:Load.cpp
示例16: 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");
}
开发者ID:trnielsen,项目名称:mantid,代码行数:13,代码来源:PlotAsymmetryByLogValue.cpp
示例17: 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;
}
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:45,代码来源:AlignAndFocusPowder.cpp
示例18: 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;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:18,代码来源:CalMuonDetectorPhases.cpp
示例19: 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;
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:21,代码来源:AlignAndFocusPowder.cpp
示例20: moveDetectorVertical
void LoadILLSANS::moveDetectorVertical(double shift,
const std::string &componentName) {
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
V3D pos = getComponentPosition(componentName);
try {
mover->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
mover->setProperty("ComponentName", componentName);
mover->setProperty("X", pos.X());
mover->setProperty("Y", shift);
mover->setProperty("Z", pos.Z());
mover->setProperty("RelativePosition", false);
mover->executeAsChildAlg();
g_log.debug() << "Moving component '" << componentName
<< "' to Y = " << shift << '\n';
} catch (std::exception &e) {
g_log.error() << "Cannot move the component '" << componentName
<< "' to Y = " << shift << '\n';
g_log.error() << e.what() << '\n';
}
}
开发者ID:liyulun,项目名称:mantid,代码行数:21,代码来源:LoadILLSANS.cpp
注:本文中的api::IAlgorithm_sptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论