本文整理汇总了C++中WorkspaceGroup_sptr类的典型用法代码示例。如果您正苦于以下问题:C++ WorkspaceGroup_sptr类的具体用法?C++ WorkspaceGroup_sptr怎么用?C++ WorkspaceGroup_sptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkspaceGroup_sptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
/**
* Groups together a vector of workspaces. This is done "manually", since the
* workspaces being passed will be outside of the ADS and so the GroupWorkspaces
* alg is not an option here.
*
* @param wsList :: the list of workspaces to group
*/
API::WorkspaceGroup_sptr
Load::groupWsList(const std::vector<API::Workspace_sptr> &wsList) {
auto group = boost::make_shared<WorkspaceGroup>();
for (const auto &ws : wsList) {
WorkspaceGroup_sptr isGroup =
boost::dynamic_pointer_cast<WorkspaceGroup>(ws);
// If the ws to add is already a group, then add its children individually.
if (isGroup) {
std::vector<std::string> childrenNames = isGroup->getNames();
size_t count = 1;
for (auto childName = childrenNames.begin();
childName != childrenNames.end(); ++childName, ++count) {
Workspace_sptr childWs = isGroup->getItem(*childName);
isGroup->remove(*childName);
// childWs->setName(isGroup->getName() + "_" +
// boost::lexical_cast<std::string>(count));
group->addWorkspace(childWs);
}
// Remove the old group from the ADS
AnalysisDataService::Instance().remove(isGroup->getName());
} else {
group->addWorkspace(ws);
}
}
return group;
}
开发者ID:peterfpeterson,项目名称:mantid,代码行数:36,代码来源:Load.cpp
示例2: plotWorkspaces
/**
* Handles the plotting of workspace post algorithm completion
*/
void Stretch::plotWorkspaces() {
WorkspaceGroup_sptr fitWorkspace;
fitWorkspace = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
m_fitWorkspaceName);
auto sigma = QString::fromStdString(fitWorkspace->getItem(0)->getName());
auto beta = QString::fromStdString(fitWorkspace->getItem(1)->getName());
// Check Sigma and Beta workspaces exist
if (sigma.right(5).compare("Sigma") == 0) {
if (beta.right(4).compare("Beta") == 0) {
// Plot Beta workspace
QString pyInput = "from mantidplot import plot2D\n";
if (m_plotType.compare("All") == 0 || m_plotType.compare("Beta") == 0) {
pyInput += "importMatrixWorkspace('";
pyInput += beta;
pyInput += "').plotGraph2D()\n";
}
// Plot Sigma workspace
if (m_plotType.compare("All") == 0 || m_plotType.compare("Sigma") == 0) {
pyInput += "importMatrixWorkspace('";
pyInput += sigma;
pyInput += "').plotGraph2D()\n";
}
m_pythonRunner.runPythonCode(pyInput);
}
} else {
g_log.error(
"Beta and Sigma workspace were not found and could not be plotted.");
}
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:35,代码来源:Stretch.cpp
示例3: processGroups
/** Process WorkspaceGroup inputs.
*
* Overriden from Algorithm base class.
*
* This should be called after checkGroups(), which sets up required members.
* It goes through each member of the group(s), creates and sets an algorithm
* for each and executes them one by one.
*
* If there are several group input workspaces, then the member of each group
* is executed pair-wise.
*
* @param sourceAlg : Source algorithm
* @param vecMultiPeriodGroups : Vector of pre-identified multiperiod groups.
* @return true - if all the workspace members are executed.
*/
bool MultiPeriodGroupWorker::processGroups(
Algorithm *const sourceAlg,
const VecWSGroupType &vecMultiPeriodGroups) const {
// If we are not processing multiperiod groups, use the base behaviour.
if (vecMultiPeriodGroups.empty()) {
return false; // Indicates that this is not a multiperiod group workspace.
}
Property *outputWorkspaceProperty = sourceAlg->getProperty("OutputWorkspace");
const std::string outName = outputWorkspaceProperty->value();
const size_t nPeriods = vecMultiPeriodGroups[0]->size();
WorkspaceGroup_sptr outputWS = boost::make_shared<WorkspaceGroup>();
AnalysisDataService::Instance().addOrReplace(outName, outputWS);
double progress_proportion = 1.0 / static_cast<double>(nPeriods);
// Loop through all the periods. Create spawned algorithms of the same type as
// this to process pairs from the input groups.
for (size_t i = 0; i < nPeriods; ++i) {
const int periodNumber = static_cast<int>(i + 1);
// use create Child Algorithm that look like this one
Algorithm_sptr alg = sourceAlg->createChildAlgorithm(
sourceAlg->name(), progress_proportion * periodNumber,
progress_proportion * (1 + periodNumber), sourceAlg->isLogging(),
sourceAlg->version());
if (!alg) {
throw std::runtime_error("Algorithm creation failed.");
}
// Don't make the new algorithm a child so that it's workspaces are stored
// correctly
alg->setChild(false);
alg->setRethrows(true);
alg->initialize();
// Copy properties that aren't workspaces properties.
sourceAlg->copyNonWorkspaceProperties(alg.get(), periodNumber);
if (this->useCustomWorkspaceProperty()) {
const std::string inputWorkspaces =
createFormattedInputWorkspaceNames(i, vecMultiPeriodGroups);
// Set the input workspace property.
alg->setPropertyValue(this->m_workspacePropertyName, inputWorkspaces);
} else {
// Configure input properties that are group workspaces.
copyInputWorkspaceProperties(alg.get(), sourceAlg, periodNumber);
}
const std::string outName_i = outName + "_" + Strings::toString(i + 1);
alg->setPropertyValue("OutputWorkspace", outName_i);
// Run the spawned algorithm.
if (!alg->execute()) {
throw std::runtime_error("Execution of " + sourceAlg->name() +
" for group entry " + Strings::toString(i + 1) +
" failed.");
}
// Add the output workpace from the spawned algorithm to the group.
outputWS->add(outName_i);
}
sourceAlg->setProperty("OutputWorkspace", outputWS);
return true;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:75,代码来源:MultiPeriodGroupWorker.cpp
示例4: disconnect
/**
* Handles completion of algorithm
*
* @param error True if the chain was stopped due to error
*/
void IndirectDiffractionReduction::algorithmComplete(bool error) {
// Handles completion of the diffraction algorithm chain
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(algorithmComplete(bool)));
if (error) {
showInformationBox(
"Error running diffraction reduction.\nSee Results Log for details.");
return;
}
// Ungroup the output workspace if generic reducer was used
if (AnalysisDataService::Instance().doesExist(
"IndirectDiffraction_Workspaces")) {
WorkspaceGroup_sptr diffResultsGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
"IndirectDiffraction_Workspaces");
m_plotWorkspaces.clear();
m_plotWorkspaces = diffResultsGroup->getNames();
diffResultsGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectDiffraction_Workspaces");
}
// Enable plotting
m_uiForm.pbPlot->setEnabled(true);
m_uiForm.cbPlotType->setEnabled(true);
// Enable saving
m_uiForm.ckAscii->setEnabled(true);
m_uiForm.ckGSS->setEnabled(true);
m_uiForm.ckNexus->setEnabled(true);
m_uiForm.pbSave->setEnabled(true);
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:37,代码来源:IndirectDiffractionReduction.cpp
示例5: setPlotResultIsPlotting
/**
* Handles the plotting of workspace post algorithm completion
*/
void Stretch::plotWorkspaces() {
setPlotResultIsPlotting(true);
WorkspaceGroup_sptr fitWorkspace;
fitWorkspace = getADSWorkspaceGroup(m_fitWorkspaceName);
auto sigma = QString::fromStdString(fitWorkspace->getItem(0)->getName());
auto beta = QString::fromStdString(fitWorkspace->getItem(1)->getName());
// Check Sigma and Beta workspaces exist
if (sigma.right(5).compare("Sigma") == 0 &&
beta.right(4).compare("Beta") == 0) {
QString pyInput = "from mantidplot import plot2D\n";
std::string const plotType = m_uiForm.cbPlot->currentText().toStdString();
if (plotType == "All" || plotType == "Beta") {
pyInput += "importMatrixWorkspace('";
pyInput += beta;
pyInput += "').plotGraph2D()\n";
}
if (plotType == "All" || plotType == "Sigma") {
pyInput += "importMatrixWorkspace('";
pyInput += sigma;
pyInput += "').plotGraph2D()\n";
}
m_pythonRunner.runPythonCode(pyInput);
} else {
g_log.error(
"Beta and Sigma workspace were not found and could not be plotted.");
}
setPlotResultIsPlotting(false);
}
开发者ID:mantidproject,项目名称:mantid,代码行数:34,代码来源:Stretch.cpp
示例6: disconnect
/**
* Handles completion of the algorithm.
*
* @param error If the algorithm failed
*/
void ISISDiagnostics::algorithmComplete(bool error) {
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(algorithmComplete(bool)));
if (error)
return;
WorkspaceGroup_sptr sliceOutputGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
"IndirectDiagnostics_Workspaces");
if (sliceOutputGroup->size() == 0) {
g_log.warning("No result workspaces, cannot plot preview.");
return;
}
for (size_t i = 0; i < sliceOutputGroup->size(); i++) {
QString wsName =
QString::fromStdString(sliceOutputGroup->getItem(i)->name());
}
// Enable plot and save buttons
m_uiForm.pbSave->setEnabled(true);
m_uiForm.pbPlot->setEnabled(true);
// Update the preview plots
sliceAlgDone(false);
m_batchAlgoRunner->executeBatchAsync();
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:33,代码来源:ISISDiagnostics.cpp
示例7: copyShapeAndFill
WorkspaceGroup_sptr PolarizationCorrection::execPNR(WorkspaceGroup_sptr inWS) {
size_t itemIndex = 0;
MatrixWorkspace_sptr Ip =
boost::dynamic_pointer_cast<MatrixWorkspace>(inWS->getItem(itemIndex++));
MatrixWorkspace_sptr Ia =
boost::dynamic_pointer_cast<MatrixWorkspace>(inWS->getItem(itemIndex++));
MatrixWorkspace_sptr ones = copyShapeAndFill(Ip, 1.0);
const VecDouble c_rho = getProperty(crhoLabel());
const VecDouble c_pp = getProperty(cppLabel());
const auto rho = this->execPolynomialCorrection(
ones, c_rho); // Execute polynomial expression
const auto pp = this->execPolynomialCorrection(
ones, c_pp); // Execute polynomial expression
const auto D = pp * (rho + 1);
const auto nIp = (Ip * (rho * pp + 1.0) + Ia * (pp - 1.0)) / D;
const auto nIa = (Ip * (rho * pp - 1.0) + Ia * (pp + 1.0)) / D;
// Preserve the history of the inside workspaces
nIp->history().addHistory(Ip->getHistory());
nIa->history().addHistory(Ia->getHistory());
WorkspaceGroup_sptr dataOut = boost::make_shared<WorkspaceGroup>();
dataOut->addWorkspace(nIp);
dataOut->addWorkspace(nIa);
return dataOut;
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:32,代码来源:PolarizationCorrection.cpp
示例8: handleAlgorithmComplete
/**
* Handle completion of the algorithm.
*
* @param error If the algorithm failed
*/
void ResNorm::handleAlgorithmComplete(bool error) {
if (error)
return;
QString outputBase = (m_uiForm.dsResolution->getCurrentDataName()).toLower();
const int indexCut = outputBase.lastIndexOf("_");
outputBase = outputBase.left(indexCut);
outputBase += "_ResNorm";
std::string outputBaseStr = outputBase.toStdString();
WorkspaceGroup_sptr fitWorkspaces =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
outputBaseStr + "_Fit_Workspaces");
QString fitWsName("");
if (fitWorkspaces)
fitWsName =
QString::fromStdString(fitWorkspaces->getItem(m_previewSpec)->name());
// MantidPlot plotting
QString plotOptions(m_uiForm.cbPlot->currentText());
if (plotOptions == "Intensity" || plotOptions == "All")
plotSpectrum(QString::fromStdString(m_pythonExportWsName) + "_Intensity");
if (plotOptions == "Stretch" || plotOptions == "All")
plotSpectrum(QString::fromStdString(m_pythonExportWsName) + "_Stretch");
if (plotOptions == "Fit" || plotOptions == "All")
plotSpectrum(fitWsName, 0, 1);
loadFile(m_uiForm.dsResolution->getFullFilePath(),
m_uiForm.dsResolution->getCurrentDataName());
// Update preview plot
previewSpecChanged(m_previewSpec);
}
开发者ID:dezed,项目名称:mantid,代码行数:39,代码来源:ResNorm.cpp
示例9: showMessageBox
/**
* Replots the energy mini plot
*/
void ISISCalibration::calPlotEnergy()
{
if ( ! m_uiForm.leRunNo->isValid() )
{
emit showMessageBox("Run number not valid.");
return;
}
QString files = m_uiForm.leRunNo->getFilenames().join(",");
QFileInfo fi(m_uiForm.leRunNo->getFirstFilename());
QString detRange = QString::number(m_dblManager->value(m_properties["ResSpecMin"])) + ","
+ QString::number(m_dblManager->value(m_properties["ResSpecMax"]));
IAlgorithm_sptr reductionAlg = AlgorithmManager::Instance().create("ISISIndirectEnergyTransfer");
reductionAlg->initialize();
reductionAlg->setProperty("Instrument", getInstrumentConfiguration()->getInstrumentName().toStdString());
reductionAlg->setProperty("Analyser", getInstrumentConfiguration()->getAnalyserName().toStdString());
reductionAlg->setProperty("Reflection", getInstrumentConfiguration()->getReflectionName().toStdString());
reductionAlg->setProperty("InputFiles", files.toStdString());
reductionAlg->setProperty("OutputWorkspace", "__IndirectCalibration_reduction");
reductionAlg->setProperty("SpectraRange", detRange.toStdString());
reductionAlg->execute();
if(!reductionAlg->isExecuted())
{
g_log.warning("Could not generate energy preview plot.");
return;
}
WorkspaceGroup_sptr reductionOutputGroup = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("__IndirectCalibration_reduction");
if(reductionOutputGroup->size() == 0)
{
g_log.warning("No result workspaces, cannot plot energy preview.");
return;
}
MatrixWorkspace_sptr energyWs = boost::dynamic_pointer_cast<MatrixWorkspace>(reductionOutputGroup->getItem(0));
if(!energyWs)
{
g_log.warning("No result workspaces, cannot plot energy preview.");
return;
}
const Mantid::MantidVec & dataX = energyWs->readX(0);
QPair<double, double> range(dataX.front(), dataX.back());
auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground");
setPlotPropertyRange(resBackground, m_properties["ResStart"], m_properties["ResEnd"], range);
m_uiForm.ppResolution->clear();
m_uiForm.ppResolution->addSpectrum("Energy", energyWs, 0);
m_uiForm.ppResolution->resizeX();
calSetDefaultResolution(energyWs);
m_uiForm.ppResolution->replot();
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:62,代码来源:ISISCalibration.cpp
示例10: sortGroupByName
/**
* Sort members by Workspace name. The group must be in the ADS.
* @param groupName :: A group name.
*/
void AnalysisDataServiceImpl::sortGroupByName(const std::string &groupName) {
WorkspaceGroup_sptr group = retrieveWS<WorkspaceGroup>(groupName);
if (!group) {
throw std::runtime_error("Workspace " + groupName +
" is not a workspace group.");
}
group->sortMembersByName();
notificationCenter.postNotification(new GroupUpdatedNotification(groupName));
}
开发者ID:mcvine,项目名称:mantid,代码行数:13,代码来源:AnalysisDataService.cpp
示例11: getProperty
/** Execute the algorithm.
*/
void PolarizationCorrection::exec() {
WorkspaceGroup_sptr inWS = getProperty("InputWorkspace");
const std::string analysisMode = getProperty("PolarizationAnalysis");
const size_t nWorkspaces = inWS->size();
validateInputWorkspace(inWS);
Instrument_const_sptr instrument = fetchInstrument(inWS.get());
// Check if we need to fetch polarization parameters from the instrument's
// parameters
std::map<std::string, std::string> loadableProperties;
loadableProperties[crhoLabel()] = "crho";
loadableProperties[cppLabel()] = "cPp";
// In PA mode, we also require cap and calpha
if (analysisMode == pALabel()) {
loadableProperties[cApLabel()] = "cAp";
loadableProperties[cAlphaLabel()] = "calpha";
}
for (auto propName = loadableProperties.begin();
propName != loadableProperties.end(); ++propName) {
Property *prop = getProperty(propName->first);
if (!prop)
continue;
if (prop->isDefault()) {
auto vals = instrument->getStringParameter(propName->second);
if (vals.empty())
throw std::runtime_error(
"Cannot find value for " + propName->first +
" in parameter file. Please specify this property manually.");
prop->setValue(vals[0]);
}
}
WorkspaceGroup_sptr outWS;
if (analysisMode == pALabel()) {
if (nWorkspaces != 4) {
throw std::invalid_argument(
"For PA analysis, input group must have 4 periods.");
}
g_log.notice("PA polarization correction");
outWS = execPA(inWS);
} else if (analysisMode == pNRLabel()) {
if (nWorkspaces != 2) {
throw std::invalid_argument(
"For PNR analysis, input group must have 2 periods.");
}
outWS = execPNR(inWS);
g_log.notice("PNR polarization correction");
}
this->setProperty("OutputWorkspace", outWS);
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:58,代码来源:PolarizationCorrection.cpp
示例12: addToGroup
/**
* Add a workspace to a group. The group and the workspace must be in the ADS.
* @param groupName :: A group name.
* @param wsName :: Name of a workspace to add to the group.
*/
void AnalysisDataServiceImpl::addToGroup(const std::string &groupName,
const std::string &wsName) {
WorkspaceGroup_sptr group = retrieveWS<WorkspaceGroup>(groupName);
if (!group) {
throw std::runtime_error("Workspace " + groupName +
" is not a workspace group.");
}
auto ws = retrieve(wsName);
group->addWorkspace(ws);
notificationCenter.postNotification(new GroupUpdatedNotification(groupName));
}
开发者ID:mcvine,项目名称:mantid,代码行数:16,代码来源:AnalysisDataService.cpp
示例13: tryAddInputWorkspaceToInputGroups
/**
* Try to add the input workspace to the multiperiod input group list.
* @param ws: candidate workspace
* @param vecMultiPeriodWorkspaceGroups: Vector of multi period workspace
* groups.
* @param vecWorkspaceGroups: Vector of non-multi period workspace groups.
*/
void MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups(
Workspace_sptr ws,
MultiPeriodGroupWorker::VecWSGroupType &vecMultiPeriodWorkspaceGroups,
MultiPeriodGroupWorker::VecWSGroupType &vecWorkspaceGroups) const {
WorkspaceGroup_sptr inputGroup =
boost::dynamic_pointer_cast<WorkspaceGroup>(ws);
if (inputGroup) {
if (inputGroup->isMultiperiod()) {
vecMultiPeriodWorkspaceGroups.push_back(inputGroup);
} else {
vecWorkspaceGroups.push_back(inputGroup);
}
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:21,代码来源:MultiPeriodGroupWorker.cpp
示例14: removeFromGroup
/**
* Remove a workspace from a group but not from the ADS.
*
* @param groupName :: Name of a workspace group.
* @param wsName :: Name of a workspace to remove.
*/
void AnalysisDataServiceImpl::removeFromGroup(const std::string &groupName,
const std::string &wsName) {
WorkspaceGroup_sptr group = retrieveWS<WorkspaceGroup>(groupName);
if (!group) {
throw std::runtime_error("Workspace " + groupName +
" is not a workspace group.");
}
if (!group->contains(wsName)) {
throw std::runtime_error("WorkspaceGroup " + groupName +
" does not containt workspace " + wsName);
}
group->removeByADS(wsName);
notificationCenter.postNotification(new GroupUpdatedNotification(groupName));
}
开发者ID:mcvine,项目名称:mantid,代码行数:20,代码来源:AnalysisDataService.cpp
示例15: range
void IqtFit::updatePlot() {
if (!m_ffInputWS) {
g_log.error("No workspace loaded, cannot create preview plot.");
return;
}
int specNo = m_uiForm.spPlotSpectrum->value();
m_uiForm.ppPlot->clear();
m_uiForm.ppPlot->addSpectrum("Sample", m_ffInputWS, specNo);
try {
const QPair<double, double> curveRange =
m_uiForm.ppPlot->getCurveRange("Sample");
const std::pair<double, double> range(curveRange.first, curveRange.second);
m_uiForm.ppPlot->getRangeSelector("FuryFitRange")
->setRange(range.first, range.second);
m_ffRangeManager->setRange(m_properties["StartX"], range.first,
range.second);
m_ffRangeManager->setRange(m_properties["EndX"], range.first, range.second);
setDefaultParameters("Exponential1");
setDefaultParameters("Exponential2");
setDefaultParameters("StretchedExp");
m_uiForm.ppPlot->resizeX();
m_uiForm.ppPlot->setAxisRange(qMakePair(0.0, 1.0), QwtPlot::yLeft);
} catch (std::invalid_argument &exc) {
showMessageBox(exc.what());
}
// If there is a result plot then plot it
if (AnalysisDataService::Instance().doesExist(m_pythonExportWsName)) {
WorkspaceGroup_sptr outputGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
m_pythonExportWsName);
if (specNo >= static_cast<int>(outputGroup->size()))
return;
MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(
outputGroup->getItem(specNo));
if (ws) {
if (m_uiForm.ckPlotGuess->isChecked()) {
m_uiForm.ppPlot->removeSpectrum("Guess");
}
m_uiForm.ppPlot->addSpectrum("Fit", ws, 1, Qt::red);
m_uiForm.ppPlot->addSpectrum("Diff", ws, 2, Qt::blue);
}
}
}
开发者ID:dezed,项目名称:mantid,代码行数:49,代码来源:IqtFit.cpp
示例16: disconnect
/**
* Handles completion of the correction algorithm.
*
* @param error True of the algorithm failed
*/
void CalculatePaalmanPings::absCorComplete(bool error) {
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(absCorComplete(bool)));
if (error) {
emit showMessageBox("Absorption correction calculation failed.\nSee "
"Results Log for more details.");
return;
}
// Convert the spectrum axis of correction factors to Q
const auto sampleWsName =
m_uiForm.dsSample->getCurrentDataName().toStdString();
MatrixWorkspace_sptr sampleWs =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(sampleWsName);
WorkspaceGroup_sptr corrections =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
m_pythonExportWsName);
for (size_t i = 0; i < corrections->size(); i++) {
MatrixWorkspace_sptr factorWs =
boost::dynamic_pointer_cast<MatrixWorkspace>(corrections->getItem(i));
if (!factorWs || !sampleWs)
continue;
if (getEMode(sampleWs) == "Indirect") {
API::BatchAlgorithmRunner::AlgorithmRuntimeProps convertSpecProps;
IAlgorithm_sptr convertSpecAlgo =
AlgorithmManager::Instance().create("ConvertSpectrumAxis");
convertSpecAlgo->initialize();
convertSpecAlgo->setProperty("InputWorkspace", factorWs);
convertSpecAlgo->setProperty("OutputWorkspace", factorWs->getName());
convertSpecAlgo->setProperty("Target", "ElasticQ");
convertSpecAlgo->setProperty("EMode", "Indirect");
try {
convertSpecAlgo->setProperty("EFixed", getEFixed(factorWs));
} catch (std::runtime_error &) {
}
m_batchAlgoRunner->addAlgorithm(convertSpecAlgo);
}
}
// Run algorithm queue
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(postProcessComplete(bool)));
m_batchAlgoRunner->executeBatchAsync();
}
开发者ID:DanNixon,项目名称:mantid,代码行数:53,代码来源:CalculatePaalmanPings.cpp
示例17: disconnect
/**
* Handles plotting result spectra from algorithm chains.
*
* @param error True if the chain was stopped due to error
*/
void IndirectDiffractionReduction::plotResults(bool error) {
// Handles completion of the diffraction algorithm chain
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(plotResults(bool)));
// Nothing can be plotted
if (error) {
showInformationBox(
"Error running diffraction reduction.\nSee Results Log for details.");
return;
}
// Ungroup the output workspace if generic reducer was used
if (AnalysisDataService::Instance().doesExist(
"IndirectDiffraction_Workspaces")) {
WorkspaceGroup_sptr diffResultsGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
"IndirectDiffraction_Workspaces");
m_plotWorkspaces.clear();
m_plotWorkspaces = diffResultsGroup->getNames();
diffResultsGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectDiffraction_Workspaces");
saveGenericReductions();
}
QString instName = m_uiForm.iicInstrumentConfiguration->getInstrumentName();
QString mode = m_uiForm.iicInstrumentConfiguration->getReflectionName();
QString plotType = m_uiForm.cbPlotType->currentText();
QString pyInput = "from mantidplot import plotSpectrum, plot2D\n";
if (plotType == "Spectra" || plotType == "Both") {
for (auto it = m_plotWorkspaces.begin(); it != m_plotWorkspaces.end(); ++it)
pyInput += "plotSpectrum('" + QString::fromStdString(*it) + "', 0)\n";
}
if (plotType == "Contour" || plotType == "Both") {
for (auto it = m_plotWorkspaces.begin(); it != m_plotWorkspaces.end(); ++it)
pyInput += "plot2D('" + QString::fromStdString(*it) + "')\n";
}
runPythonCode(pyInput);
}
开发者ID:liyulun,项目名称:mantid,代码行数:52,代码来源:IndirectDiffractionReduction.cpp
示例18: disconnect
/**
* Handles completion of the algorithm.
*
* Sets result workspace for Python export and ungroups result WorkspaceGroup.
*
* @param error True if the algorithm was stopped due to error, false otherwise
*/
void IndirectConvertToEnergy::algorithmComplete(bool error)
{
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmComplete(bool)));
if(error)
return;
WorkspaceGroup_sptr energyTransferOutputGroup = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("IndirectEnergyTransfer_Workspaces");
if(energyTransferOutputGroup->size() == 0)
return;
// Set workspace for Python export as the first result workspace
m_pythonExportWsName = energyTransferOutputGroup->getNames()[0];
// Ungroup the output workspace
energyTransferOutputGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectEnergyTransfer_Workspaces");
}
开发者ID:mkoennecke,项目名称:mantid,代码行数:25,代码来源:IndirectConvertToEnergy.cpp
示例19: getFirstPeriodWS
/**
* Returns a workspace for the first period as specified using FirstPeriod
* property.
* @param group :: Loaded group of workspaces to use
* @return Workspace for the period
*/
MatrixWorkspace_sptr MuonLoad::getFirstPeriodWS(WorkspaceGroup_sptr group) {
int firstPeriod = getProperty("FirstPeriod");
MatrixWorkspace_sptr resultWS;
if (firstPeriod < 0 || firstPeriod >= static_cast<int>(group->size()))
throw std::invalid_argument(
"Workspace doesn't contain specified first period");
resultWS =
boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(firstPeriod));
if (!resultWS)
throw std::invalid_argument(
"First period workspace is not a MatrixWorkspace");
return resultWS;
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:24,代码来源:MuonLoad.cpp
示例20: getPropertyValue
/**
* Run instead of exec when operating on groups
*/
bool SaveNXTomo::processGroups() {
try {
std::string name = getPropertyValue("InputWorkspaces");
WorkspaceGroup_sptr groupWS =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(name);
for (int i = 0; i < groupWS->getNumberOfEntries(); ++i) {
m_workspaces.push_back(
boost::dynamic_pointer_cast<Workspace2D>(groupWS->getItem(i)));
}
} catch (...) {
}
if (m_workspaces.size() != 0)
processAll();
return true;
}
开发者ID:mkoennecke,项目名称:mantid,代码行数:21,代码来源:SaveNXTomo.cpp
注:本文中的WorkspaceGroup_sptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论