本文整理汇总了C++中IAlgorithm_sptr::setPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::setPropertyValue方法的具体用法?C++ IAlgorithm_sptr::setPropertyValue怎么用?C++ IAlgorithm_sptr::setPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::setPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transposeWs
/**
* @brief MDHWInMemoryLoadingPresenter::transposeWs
*
* vtkDataSets are usually provided in 3D, trying to create these where one of
*those dimensions
* might be integrated out leads to empty datasets. To avoid this we reorder the
*dimensions in our workspace
* prior to visualisation by transposing if if needed.
*
* @param inHistoWs : An input workspace that may integrated dimensions
*anywhere.
* @param outCachedHistoWs : Cached histo workspace. To write to if needed.
* @return A workspace that can be directly rendered from. Integrated dimensions
*are always last.
*/
void MDHWLoadingPresenter::transposeWs(
Mantid::API::IMDHistoWorkspace_sptr &inHistoWs,
Mantid::API::IMDHistoWorkspace_sptr &outCachedHistoWs) {
using namespace Mantid::API;
if (!outCachedHistoWs) {
/*
Construct dimension indexes list for transpose. We do this by forcing
integrated
dimensions to be the last in the list. All other orderings are kept.
*/
std::vector<int> integratedDims;
std::vector<int> nonIntegratedDims;
for (int i = 0; i < int(inHistoWs->getNumDims()); ++i) {
auto dim = inHistoWs->getDimension(i);
if (dim->getIsIntegrated()) {
integratedDims.push_back(i);
} else {
nonIntegratedDims.push_back(i);
}
}
std::vector<int> orderedDims = nonIntegratedDims;
orderedDims.insert(orderedDims.end(), integratedDims.begin(),
integratedDims.end());
/*
If there has been any reordering above, then the dimension indexes will
no longer be sorted. We use that to determine if we can avoid transposing
the workspace.
*/
if (!std::is_sorted(orderedDims.begin(), orderedDims.end())) {
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("TransposeMD");
alg->setChild(true);
alg->initialize();
alg->setProperty("InputWorkspace", inHistoWs);
alg->setPropertyValue("OutputWorkspace", "dummy");
alg->setProperty("Axes", orderedDims);
alg->execute();
IMDHistoWorkspace_sptr visualHistoWs =
alg->getProperty("OutputWorkspace");
outCachedHistoWs = visualHistoWs;
} else {
// No need to transpose anything.
outCachedHistoWs = inHistoWs;
}
}
}
示例2: root
/// Run the LoadLog Child Algorithm
void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) {
IAlgorithm_sptr loadLog = createChildAlgorithm("LoadMuonLog");
// Pass through the same input filename
loadLog->setPropertyValue("Filename", m_filename);
// Set the workspace property to be the same one filled above
loadLog->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
loadLog->execute();
} catch (std::runtime_error &) {
g_log.error("Unable to successfully run LoadMuonLog Child Algorithm");
} catch (std::logic_error &) {
g_log.error("Unable to successfully run LoadMuonLog Child Algorithm");
}
if (!loadLog->isExecuted())
g_log.error("Unable to successfully run LoadMuonLog Child Algorithm");
NXRoot root(m_filename);
// Get main field direction
std::string mainFieldDirection = "Longitudinal"; // default
try {
NXChar orientation = root.openNXChar("run/instrument/detector/orientation");
// some files have no data there
orientation.load();
if (orientation[0] == 't') {
auto p =
Kernel::make_unique<Kernel::TimeSeriesProperty<double>>("fromNexus");
std::string start_time = root.getString("run/start_time");
p->addValue(start_time, -90.0);
localWorkspace->mutableRun().addLogData(std::move(p));
mainFieldDirection = "Transverse";
}
} catch (...) {
// no data - assume main field was longitudinal
}
// set output property and add to workspace logs
auto &run = localWorkspace->mutableRun();
setProperty("MainFieldDirection", mainFieldDirection);
run.addProperty("main_field_direction", mainFieldDirection);
ISISRunLogs runLogs(run);
runLogs.addStatusLog(run);
}
示例3: runLoadInstrument
/**
* Run the Child Algorithm LoadInstrument.
*/
void LoadILLIndirect::runLoadInstrument() {
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
loadInst->setPropertyValue("InstrumentName", m_instrumentName);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
loadInst->setProperty("RewriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
loadInst->execute();
} catch (...) {
g_log.information("Cannot load the instrument definition.");
}
}
示例4: runLoadInstrument
/**
* Run the Child Algorithm LoadInstrument.
*/
void LoadSINQFocus::runLoadInstrument() {
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
// TODO: depending on the m_numberOfPixelsPerTube we might need to load a different IDF
loadInst->setPropertyValue("InstrumentName", m_instrumentName);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace",
m_localWorkspace);
loadInst->execute();
} catch (...) {
g_log.information("Cannot load the instrument definition.");
}
}
示例5: root
/// Run the LoadLog Child Algorithm
void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) {
IAlgorithm_sptr loadLog = createChildAlgorithm("LoadMuonLog");
// Pass through the same input filename
loadLog->setPropertyValue("Filename", m_filename);
// Set the workspace property to be the same one filled above
loadLog->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
loadLog->execute();
} catch (std::runtime_error &) {
g_log.error("Unable to successfully run LoadLog Child Algorithm");
} catch (std::logic_error &) {
g_log.error("Unable to successfully run LoadLog Child Algorithm");
}
if (!loadLog->isExecuted())
g_log.error("Unable to successfully run LoadLog Child Algorithm");
NXRoot root(m_filename);
try {
NXChar orientation = root.openNXChar("run/instrument/detector/orientation");
// some files have no data there
orientation.load();
if (orientation[0] == 't') {
Kernel::TimeSeriesProperty<double> *p =
new Kernel::TimeSeriesProperty<double>("fromNexus");
std::string start_time = root.getString("run/start_time");
p->addValue(start_time, -90.0);
localWorkspace->mutableRun().addLogData(p);
setProperty("MainFieldDirection", "Transverse");
} else {
setProperty("MainFieldDirection", "Longitudinal");
}
} catch (...) {
setProperty("MainFieldDirection", "Longitudinal");
}
auto &run = localWorkspace->mutableRun();
int n = static_cast<int>(m_numberOfPeriods);
ISISRunLogs runLogs(run, n);
runLogs.addStatusLog(run);
}
示例6: loadInstrument
/// Run the Child Algorithm LoadInstrument.
void LoadILLReflectometry::loadInstrument() {
// execute the Child Algorithm. Catch and log any error, but don't stop.
g_log.debug("Loading instrument definition...");
try {
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
const std::string instrumentName =
m_instrument == Supported::D17 ? "D17" : "Figaro";
loadInst->setPropertyValue("InstrumentName", instrumentName);
loadInst->setProperty("RewriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
loadInst->executeAsChildAlg();
} catch (std::runtime_error &e) {
g_log.information()
<< "Unable to succesfully run LoadInstrument child algorithm: "
<< e.what() << '\n';
}
}
示例7: exec
/** Execute the algorithm.
*/
void MergeMDFiles::exec()
{
// clear disk buffer which can remain from previous runs
// the existance/ usage of the buffer idicates if the algorithm works with file based or memory based target workspaces;
// pDiskBuffer = NULL;
MultipleFileProperty * multiFileProp = dynamic_cast<MultipleFileProperty*>(getPointerToProperty("Filenames"));
m_Filenames = MultipleFileProperty::flattenFileNames(multiFileProp->operator()());
if (m_Filenames.size() == 0)
throw std::invalid_argument("Must specify at least one filename.");
std::string firstFile = m_Filenames[0];
std::string outputFile = getProperty("OutputFilename");
m_fileBasedTargetWS = false;
if (!outputFile.empty())
{
m_fileBasedTargetWS = true;
if (Poco::File(outputFile).exists())
throw std::invalid_argument(" File "+outputFile+" already exists. Can not use existing file as the target to MergeMD files.\n"+
" Use it as one of source files if you want to add MD data to it" );
}
// Start by loading the first file but just the box structure, no events, and not file-backed
//m_BoxStruct.loadBoxStructure(firstFile,
IAlgorithm_sptr loader = createChildAlgorithm("LoadMD", 0.0, 0.05, false);
loader->setPropertyValue("Filename", firstFile);
loader->setProperty("MetadataOnly", false);
loader->setProperty("BoxStructureOnly", true);
loader->setProperty("FileBackEnd", false);
loader->executeAsChildAlg();
IMDWorkspace_sptr result= (loader->getProperty("OutputWorkspace"));
auto firstWS = boost::dynamic_pointer_cast<API::IMDEventWorkspace>(result);
if(!firstWS)
throw std::runtime_error("Can not load MDEventWorkspace from initial file "+firstFile);
// do the job
this->doExecByCloning(firstWS,outputFile);
m_OutIWS->setFileNeedsUpdating(false);
setProperty("OutputWorkspace", m_OutIWS);
}
示例8: createChildAlgorithm
Workspace_sptr
GenericDataProcessorAlgorithm<Base>::assemble(Workspace_sptr partialWS) {
Workspace_sptr outputWS = partialWS;
#ifdef MPI_BUILD
IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces");
gatherAlg->setLogging(true);
gatherAlg->setAlwaysStoreInADS(true);
gatherAlg->setProperty("InputWorkspace", partialWS);
gatherAlg->setProperty("PreserveEvents", true);
gatherAlg->setPropertyValue("OutputWorkspace", "_total");
gatherAlg->execute();
if (isMainThread()) {
outputWS = AnalysisDataService::Instance().retrieve("_total");
}
#endif
return outputWS;
}
示例9: runLoadInstrumentFromRaw
/// Run LoadInstrumentFromRaw as a Child Algorithm (only if loading from instrument definition file fails)
void LoadRaw::runLoadInstrumentFromRaw(DataObjects::Workspace2D_sptr localWorkspace)
{
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrumentFromRaw");
loadInst->setPropertyValue("Filename", m_filename);
// Set the workspace property to be the same one filled above
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace",localWorkspace);
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try
{
loadInst->execute();
}
catch (std::runtime_error&)
{
g_log.error("Unable to successfully run LoadInstrumentFromRaw Child Algorithm");
}
if ( ! loadInst->isExecuted() ) g_log.error("No instrument definition loaded");
}
示例10: makeAlgorithm
/** Using the [Post]ProcessingAlgorithm and [Post]ProcessingProperties
*properties,
* create and initialize an algorithm for processing.
*
* @param postProcessing :: true to create the PostProcessingAlgorithm.
* false to create the ProcessingAlgorithm
* @return shared pointer to the algorithm, ready for execution.
* Returns a NULL pointer if no algorithm was chosen.
*/
IAlgorithm_sptr LiveDataAlgorithm::makeAlgorithm(bool postProcessing) {
std::string prefix = "";
if (postProcessing)
prefix = "Post";
// Get the name of the algorithm to run
std::string algoName = this->getPropertyValue(prefix + "ProcessingAlgorithm");
algoName = Strings::strip(algoName);
// Get the script to run. Ignored if algo is specified
std::string script = this->getPropertyValue(prefix + "ProcessingScript");
script = Strings::strip(script);
if (!algoName.empty()) {
// Properties to pass to algo
std::string props = this->getPropertyValue(prefix + "ProcessingProperties");
// Create the UNMANAGED algorithm
IAlgorithm_sptr alg = this->createChildAlgorithm(algoName);
// Skip some of the properties when setting
std::set<std::string> ignoreProps;
ignoreProps.insert("InputWorkspace");
ignoreProps.insert("OutputWorkspace");
// ...and pass it the properties
alg->setPropertiesWithSimpleString(props, ignoreProps);
// Warn if someone put both values.
if (!script.empty())
g_log.warning() << "Running algorithm " << algoName
<< " and ignoring the script code in "
<< prefix + "ProcessingScript" << std::endl;
return alg;
} else if (!script.empty()) {
// Run a snippet of python
IAlgorithm_sptr alg = this->createChildAlgorithm("RunPythonScript");
alg->setLogging(false);
alg->setPropertyValue("Code", script);
return alg;
} else
return IAlgorithm_sptr();
}
示例11: exec
/**
* Execute the algorithm
*/
void RebinToWorkspace::exec() {
// The input workspaces ...
MatrixWorkspace_sptr toRebin = getProperty("WorkspaceToRebin");
MatrixWorkspace_sptr toMatch = getProperty("WorkspaceToMatch");
bool PreserveEvents = getProperty("PreserveEvents");
// First we need to create the parameter vector from the workspace with which
// we are matching
std::vector<double> rb_params = createRebinParameters(toMatch);
IAlgorithm_sptr runRebin = createChildAlgorithm("Rebin");
runRebin->setProperty<MatrixWorkspace_sptr>("InputWorkspace", toRebin);
runRebin->setPropertyValue("OutputWorkspace", "rebin_out");
runRebin->setProperty("params", rb_params);
runRebin->setProperty("PreserveEvents", PreserveEvents);
runRebin->executeAsChildAlg();
progress(1);
MatrixWorkspace_sptr ws = runRebin->getProperty("OutputWorkspace");
setProperty("OutputWorkspace", ws);
}
示例12: runLoadLog
/// Run the LoadLog Child Algorithm
void LoadRaw::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace)
{
IAlgorithm_sptr loadLog = createChildAlgorithm("LoadLog");
// Pass through the same input filename
loadLog->setPropertyValue("Filename",m_filename);
// Set the workspace property to be the same one filled above
loadLog->setProperty<MatrixWorkspace_sptr>("Workspace",localWorkspace);
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try
{
loadLog->execute();
}
catch (std::runtime_error&)
{
g_log.error("Unable to successfully run LoadLog Child Algorithm");
}
if ( ! loadLog->isExecuted() ) g_log.error("Unable to successfully run LoadLog Child Algorithm");
}
示例13: d
/// Creates a PoldiPeak from the given profile function/hkl pair.
PoldiPeak_sptr
PoldiFitPeaks2D::getPeakFromPeakFunction(IPeakFunction_sptr profileFunction,
const V3D &hkl) {
// Use EstimatePeakErrors to calculate errors of FWHM and so on
IAlgorithm_sptr errorAlg = createChildAlgorithm("EstimatePeakErrors");
errorAlg->setProperty(
"Function", boost::dynamic_pointer_cast<IFunction>(profileFunction));
errorAlg->setPropertyValue("OutputWorkspace", "Errors");
errorAlg->execute();
double centre = profileFunction->centre();
double fwhmValue = profileFunction->fwhm();
ITableWorkspace_sptr errorTable = errorAlg->getProperty("OutputWorkspace");
double centreError = errorTable->cell<double>(0, 2);
double fwhmError = errorTable->cell<double>(2, 2);
UncertainValue d(centre, centreError);
UncertainValue fwhm(fwhmValue, fwhmError);
UncertainValue intensity;
bool useIntegratedIntensities = getProperty("OutputIntegratedIntensities");
if (useIntegratedIntensities) {
double integratedIntensity = profileFunction->intensity();
double integratedIntensityError = errorTable->cell<double>(3, 2);
intensity = UncertainValue(integratedIntensity, integratedIntensityError);
} else {
double height = profileFunction->height();
double heightError = errorTable->cell<double>(1, 2);
intensity = UncertainValue(height, heightError);
}
// Create peak with extracted parameters and supplied hkl
PoldiPeak_sptr peak =
PoldiPeak::create(MillerIndices(hkl), d, intensity, UncertainValue(1.0));
peak->setFwhm(fwhm, PoldiPeak::FwhmRelation::AbsoluteD);
return peak;
}
示例14: extractSpec
/** Calls CropWorkspace as a sub-algorithm and passes to it the InputWorkspace property
* @param specInd :: the index number of the histogram to extract
* @param start :: the number of the first bin to include (starts counting bins at 0)
* @param end :: the number of the last bin to include (starts counting bins at 0)
* @throw out_of_range if start, end or specInd are set outside of the vaild range for the workspace
* @throw runtime_error if the algorithm just falls over
* @throw invalid_argument if the input workspace does not have common binning
*/
void GetEi::extractSpec(int64_t specInd, double start, double end)
{
IAlgorithm_sptr childAlg =
createSubAlgorithm("CropWorkspace", 100*m_fracCompl, 100*(m_fracCompl+CROP) );
m_fracCompl += CROP;
childAlg->setPropertyValue( "InputWorkspace",
getPropertyValue("InputWorkspace") );
childAlg->setProperty( "XMin", start);
childAlg->setProperty( "XMax", end);
childAlg->setProperty( "StartWorkspaceIndex", specInd);
childAlg->setProperty( "EndWorkspaceIndex", specInd);
childAlg->executeAsSubAlg();
m_tempWS = childAlg->getProperty("OutputWorkspace");
//DEBUGGING CODE uncomment out the line below if you want to see the TOF window that was analysed
//AnalysisDataService::Instance().addOrReplace("croped_dist_del", m_tempWS);
progress(m_fracCompl);
interruption_point();
}
示例15: runLoadNexusProcessed
void LoadNexus::runLoadNexusProcessed() {
IAlgorithm_sptr loadNexusPro =
createChildAlgorithm("LoadNexusProcessed", 0., 1.);
// Pass through the same input filename
loadNexusPro->setPropertyValue("Filename", m_filename);
// Set the workspace property
loadNexusPro->setPropertyValue("OutputWorkspace", m_workspace);
loadNexusPro->setPropertyValue("SpectrumMin",
getPropertyValue("SpectrumMin"));
loadNexusPro->setPropertyValue("SpectrumMax",
getPropertyValue("SpectrumMax"));
loadNexusPro->setPropertyValue("SpectrumList",
getPropertyValue("SpectrumList"));
/* !!! The spectrum min/max/list properties are currently missing from
LoadNexus
so don't pass them through here, just print a warning !!! */
// Get the array passed in the spectrum_list, if an empty array was passed use
// the default
// std::vector<int> specList = getProperty("SpectrumList");
// if ( !specList.empty() )
//{
// g_log.warning("SpectrumList property ignored - it is not implemented in
// LoadNexusProcessed.");
// //loadNexusPro->setProperty("SpectrumList",specList);
//}
// int specMin = getProperty("SpectrumMin");
// int specMax = getProperty("SpectrumMax");
// if ( specMax != Mantid::EMPTY_INT() || specMin != 0 )
//{
// g_log.warning("SpectrumMin/Max properties ignored - they are not
// implemented in LoadNexusProcessed.");
// //loadNexusPro->setProperty("SpectrumMax",specMin);
// //loadNexusPro->setProperty("SpectrumMin",specMax);
//}
loadNexusPro->setPropertyValue("EntryNumber",
getPropertyValue("EntryNumber"));
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
loadNexusPro->execute();
if (!loadNexusPro->isExecuted())
g_log.error(
"Unable to successfully run LoadNexusProcessed Child Algorithm");
setOutputWorkspace(loadNexusPro);
}