本文整理汇总了C++中WorkspaceGroup_sptr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkspaceGroup_sptr::size方法的具体用法?C++ WorkspaceGroup_sptr::size怎么用?C++ WorkspaceGroup_sptr::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkspaceGroup_sptr
的用法示例。
在下文中一共展示了WorkspaceGroup_sptr::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: algorithmComplete
/**
* 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();
}
示例2: exec
/** Execute the algorithm.
*/
void PolarizationCorrectionFredrikze::exec() {
WorkspaceGroup_sptr inWS = getProperty("InputWorkspace");
const std::string analysisMode = getProperty("PolarizationAnalysis");
const size_t nWorkspaces = inWS->size();
validateInputWorkspace(inWS);
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);
}
示例3: transmissionRunSum
/**
* Sum over transmission group workspaces to produce one
* workspace.
* @param transGroup : The transmission group to be processed
* @return A workspace pointer containing the sum of transmission workspaces.
*/
Mantid::API::Workspace_sptr
ReflectometryReductionOneAuto::sumOverTransmissionGroup(
WorkspaceGroup_sptr &transGroup) {
// Handle transmission runs
// we clone the first member of transmission group as to
// avoid addition in place which would affect the original
// workspace member.
//
// We used .release because clone() will return a unique_ptr.
// we need to release the ownership of the pointer so that it
// can be cast into a shared_ptr of type Workspace.
Workspace_sptr transmissionRunSum(transGroup->getItem(0)->clone().release());
// make a variable to store the overall total of the summation
MatrixWorkspace_sptr total;
// set up and initialize plus algorithm.
auto plusAlg = this->createChildAlgorithm("Plus");
plusAlg->setChild(true);
// plusAlg->setRethrows(true);
plusAlg->initialize();
// now accumalate the group members
for (size_t item = 1; item < transGroup->size(); ++item) {
plusAlg->setProperty("LHSWorkspace", transmissionRunSum);
plusAlg->setProperty("RHSWorkspace", transGroup->getItem(item));
plusAlg->setProperty("OutputWorkspace", transmissionRunSum);
plusAlg->execute();
total = plusAlg->getProperty("OutputWorkspace");
}
return total;
}
示例4: algorithmComplete
/**
* 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 ISISEnergyTransfer::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];
m_outputWorkspaces = energyTransferOutputGroup->getNames();
// Ungroup the output workspace
energyTransferOutputGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectEnergyTransfer_Workspaces");
// Enable plotting and saving
m_uiForm.pbPlot->setEnabled(true);
m_uiForm.cbPlotType->setEnabled(true);
m_uiForm.pbSave->setEnabled(true);
m_uiForm.ckSaveAclimax->setEnabled(true);
m_uiForm.ckSaveASCII->setEnabled(true);
m_uiForm.ckSaveDaveGrp->setEnabled(true);
m_uiForm.ckSaveNexus->setEnabled(true);
m_uiForm.ckSaveNXSPE->setEnabled(true);
m_uiForm.ckSaveSPE->setEnabled(true);
}
示例5: calPlotEnergy
/**
* 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();
}
示例6: exec
/** 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);
}
示例7: updatePlot
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);
}
}
}
示例8: validateMultiPeriodGroupInputs
/**
* Validate the multiperiods workspace groups. Gives the opportunity to exit
* processing if things don't look right.
* @param vecMultiPeriodGroups : vector of multiperiod groups.
*/
void MultiPeriodGroupWorker::validateMultiPeriodGroupInputs(
const VecWSGroupType &vecMultiPeriodGroups) const {
const size_t multiPeriodGroupsSize = vecMultiPeriodGroups.size();
if (multiPeriodGroupsSize > 0) {
const size_t benchMarkGroupSize = vecMultiPeriodGroups[0]->size();
for (size_t i = 0; i < multiPeriodGroupsSize; ++i) {
WorkspaceGroup_sptr currentGroup = vecMultiPeriodGroups[i];
if (currentGroup->size() != benchMarkGroupSize) {
throw std::runtime_error("Not all the input Multi-period-group input "
"workspaces are the same size.");
}
for (size_t j = 0; j < currentGroup->size(); ++j) {
MatrixWorkspace_const_sptr currentNestedWS =
boost::dynamic_pointer_cast<const MatrixWorkspace>(
currentGroup->getItem(j));
Property *nPeriodsProperty =
currentNestedWS->run().getLogData("nperiods");
size_t nPeriods = std::stoul(nPeriodsProperty->value());
if (nPeriods != benchMarkGroupSize) {
throw std::runtime_error("Missmatch between nperiods log and the "
"number of workspaces in the input group: " +
vecMultiPeriodGroups[i]->getName());
}
Property *currentPeriodProperty =
currentNestedWS->run().getLogData("current_period");
size_t currentPeriod = std::stoul(currentPeriodProperty->value());
if (currentPeriod != (j + 1)) {
throw std::runtime_error("Multiperiod group workspaces must be "
"ordered by current_period. Correct: " +
currentNestedWS->getName());
}
}
}
}
}
示例9: absCorComplete
/**
* 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();
}
示例10: algorithmComplete
/**
* 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");
}
示例11: 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;
}
示例12: deepRemoveGroup
/**
* Remove a workspace group and all its members from the ADS.
* @param name :: A group to remove.
*/
void AnalysisDataServiceImpl::deepRemoveGroup(const std::string &name) {
WorkspaceGroup_sptr group = retrieveWS<WorkspaceGroup>(name);
if (!group) {
throw std::runtime_error("Workspace " + name +
" is not a workspace group.");
}
group->observeADSNotifications(false);
for (size_t i = 0; i < group->size(); ++i) {
auto ws = group->getItem(i);
WorkspaceGroup_sptr gws = boost::dynamic_pointer_cast<WorkspaceGroup>(ws);
if (gws) {
// if a member is a group remove its items as well
deepRemoveGroup(gws->name());
} else {
remove(ws->name());
}
}
remove(name);
}
示例13: getSecondPeriodWS
/**
* Returns a workspace for the second period as specified using SecondPeriod
* property.
* @param group :: Loaded group of workspaces to use
* @return Workspace for the period
*/
MatrixWorkspace_sptr MuonLoad::getSecondPeriodWS(WorkspaceGroup_sptr group) {
int secondPeriod = getProperty("SecondPeriod");
MatrixWorkspace_sptr resultWS;
if (secondPeriod != EMPTY_INT()) {
if (secondPeriod < 0 || secondPeriod >= static_cast<int>(group->size()))
throw std::invalid_argument(
"Workspace doesn't contain specified second period");
resultWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
group->getItem(secondPeriod));
if (!resultWS)
throw std::invalid_argument(
"Second period workspace is not a MatrixWorkspace");
}
return resultWS;
}
示例14: sliceAlgDone
/**
* Updates the preview plot when the algorithm is complete.
*
* @param error True if the algorithm was stopped due to error, false otherwise
*/
void ISISDiagnostics::sliceAlgDone(bool error) {
disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
SLOT(sliceAlgDone(bool)));
if (error)
return;
QStringList filenames = m_uiForm.dsInputFiles->getFilenames();
if (filenames.size() < 1)
return;
WorkspaceGroup_sptr sliceOutputGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
"IndirectDiagnostics_Workspaces");
if (sliceOutputGroup->size() == 0) {
g_log.warning("No result workspaces, cannot plot preview.");
return;
}
MatrixWorkspace_sptr sliceWs = boost::dynamic_pointer_cast<MatrixWorkspace>(
sliceOutputGroup->getItem(0));
if (!sliceWs) {
g_log.warning("No result workspaces, cannot plot preview.");
return;
}
// Set workspace for Python export as the first result workspace
m_pythonExportWsName = sliceWs->getName();
// Plot result spectrum
m_uiForm.ppSlicePreview->clear();
m_uiForm.ppSlicePreview->addSpectrum("Slice", sliceWs, 0);
m_uiForm.ppSlicePreview->resizeX();
// Ungroup the output workspace
sliceOutputGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectDiagnostics_Workspaces");
}
示例15: sliceAlgDone
/**
* Updates the preview plot when the algorithm is complete.
*
* @param error True if the algorithm was stopped due to error, false otherwise
*/
void IndirectDiagnostics::sliceAlgDone(bool error)
{
if(error)
return;
QStringList filenames = m_uiForm.dsInputFiles->getFilenames();
if(filenames.size() < 1)
return;
WorkspaceGroup_sptr sliceOutputGroup = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("IndirectDiagnostics_Workspaces");
if(sliceOutputGroup->size() == 0)
{
g_log.warning("No result workspaces, cannot plot preview.");
return;
}
MatrixWorkspace_sptr sliceWs = boost::dynamic_pointer_cast<MatrixWorkspace>(sliceOutputGroup->getItem(0));
if(!sliceWs)
{
g_log.warning("No result workspaces, cannot plot preview.");
return;
}
// Set workspace for Python export as the first result workspace
m_pythonExportWsName = sliceWs->getName();
// Plot result spectrum
plotMiniPlot(sliceWs, 0, "SlicePreviewPlot", "SlicePreviewCurve");
// Set X range to data range
setXAxisToCurve("SlicePreviewPlot", "SlicePreviewCurve");
m_plots["SlicePreviewPlot"]->replot();
// Ungroup the output workspace
sliceOutputGroup->removeAll();
AnalysisDataService::Instance().remove("IndirectDiagnostics_Workspaces");
}