本文整理汇总了C++中TableWorkspace_sptr::columnCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TableWorkspace_sptr::columnCount方法的具体用法?C++ TableWorkspace_sptr::columnCount怎么用?C++ TableWorkspace_sptr::columnCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableWorkspace_sptr
的用法示例。
在下文中一共展示了TableWorkspace_sptr::columnCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importFitWindowTableWorkspace
/** Executes the algorithm
*
* @throw Exception::RuntimeError If ... ...
*/
void GetDetOffsetsMultiPeaks::importFitWindowTableWorkspace(TableWorkspace_sptr windowtablews)
{
// Check number of columns matches number of peaks
size_t numcols = windowtablews->columnCount();
size_t numpeaks = m_peakPositions.size();
if (numcols != 2*numpeaks+1)
throw std::runtime_error("Number of columns is not 2 times of number of referenced peaks. ");
// Check number of spectra should be same to input workspace
size_t numrows = windowtablews->rowCount();
if (numrows != m_inputWS->getNumberHistograms())
throw std::runtime_error("Number of spectra in fit window workspace does not match input workspace. ");
// Create workspace
m_vecFitWindow.clear();
m_vecFitWindow.resize(numrows);
for (size_t i = 0; i < numrows; ++i)
{
// spectrum number
int spec = windowtablews->cell<int>(i, 0);
if (spec < 0 || spec >= static_cast<int>(numrows))
{
std::stringstream ess;
ess << "Peak fit windows at row " << i << " has spectrum " << spec
<< ", which is out of allowed range! ";
throw std::runtime_error(ess.str());
}
else if (m_vecFitWindow[spec].size() != 0)
{
std::stringstream ess;
ess << "Peak fit windows at row " << i << " has spectrum " << spec
<< ", which appears before in fit window table workspace. ";
throw std::runtime_error(ess.str());
}
// fit windows
std::vector<double> fitwindows(numcols-1);
for (size_t j = 1; j < numcols; ++j)
{
double dtmp = windowtablews->cell<double>(i, j);
fitwindows[j-1] = dtmp;
}
// add to vector of fit windows
m_vecFitWindow[spec] = fitwindows;
}
return;
}
示例2: checkColumns
bool PoldiPeakCollection::checkColumns(
const TableWorkspace_sptr &tableWorkspace) {
if (tableWorkspace->columnCount() != 9) {
return false;
}
std::vector<std::string> shouldNames{"HKL", "d", "delta d", "Q", "delta Q",
"Intensity", "delta Intensity",
"FWHM (rel.)", "delta FWHM (rel.)"};
std::vector<std::string> columnNames = tableWorkspace->getColumnNames();
return columnNames == shouldNames;
}
示例3: importFitWindowTableWorkspace
/** Executes the algorithm
*
* @throw Exception::RuntimeError If ... ...
*/
void GetDetOffsetsMultiPeaks::importFitWindowTableWorkspace(
TableWorkspace_sptr windowtablews) {
// Check number of columns matches number of peaks
size_t numcols = windowtablews->columnCount();
size_t numpeaks = m_peakPositions.size();
if (numcols != 2 * numpeaks + 1)
throw std::runtime_error(
"Number of columns is not 2 times of number of referenced peaks. ");
// Check number of spectra should be same to input workspace
size_t numrows = windowtablews->rowCount();
bool needuniversal = false;
if (numrows < m_inputWS->getNumberHistograms())
needuniversal = true;
else if (numrows > m_inputWS->getNumberHistograms())
throw std::runtime_error(
"Number of rows in table workspace is larger than number of spectra.");
// Clear and re-size of the vector for fit windows
m_vecFitWindow.clear();
m_vecFitWindow.resize(m_inputWS->getNumberHistograms());
std::vector<double> vec_univFitWindow;
bool founduniversal = false;
// Parse the table workspace
for (size_t i = 0; i < numrows; ++i) {
// spectrum number
int spec = windowtablews->cell<int>(i, 0);
if (spec >= static_cast<int>(numrows)) {
std::stringstream ess;
ess << "Peak fit windows at row " << i << " has spectrum " << spec
<< ", which is out of allowed range! ";
throw std::runtime_error(ess.str());
}
if (spec < 0 && founduniversal) {
throw std::runtime_error("There are more than 1 universal spectrum (spec "
"< 0) in TableWorkspace.");
} else if (spec >= 0 && m_vecFitWindow[spec].size() != 0) {
std::stringstream ess;
ess << "Peak fit windows at row " << i << " has spectrum " << spec
<< ", which appears before in fit window table workspace. ";
throw std::runtime_error(ess.str());
}
// fit windows
std::vector<double> fitwindows(numcols - 1);
for (size_t j = 1; j < numcols; ++j) {
double dtmp = windowtablews->cell<double>(i, j);
fitwindows[j - 1] = dtmp;
}
// add to vector of fit windows
if (spec >= 0)
m_vecFitWindow[spec] = fitwindows;
else {
vec_univFitWindow = fitwindows;
founduniversal = true;
}
}
// Check and fill if using universal
if (needuniversal && !founduniversal) {
// Invalid case
throw std::runtime_error("Number of rows in TableWorkspace is smaller than "
"number of spectra. But "
"there is no universal fit window given!");
} else if (founduniversal) {
// Fill the universal
for (size_t i = 0; i < m_inputWS->getNumberHistograms(); ++i)
if (m_vecFitWindow[i].size() == 0)
m_vecFitWindow[i] = vec_univFitWindow;
}
return;
}