当前位置: 首页>>代码示例>>C++>>正文


C++ TableWorkspace_sptr::name方法代码示例

本文整理汇总了C++中TableWorkspace_sptr::name方法的典型用法代码示例。如果您正苦于以下问题:C++ TableWorkspace_sptr::name方法的具体用法?C++ TableWorkspace_sptr::name怎么用?C++ TableWorkspace_sptr::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableWorkspace_sptr的用法示例。


在下文中一共展示了TableWorkspace_sptr::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyTableWorkspaceContent

/** Copy table workspace content from one workspace to another
  * @param sourceWS :: table workspace from which the content is copied;
  * @param targetWS :: table workspace to which the content is copied;
  */
void ExtractMaskToTable::copyTableWorkspaceContent(
    TableWorkspace_sptr sourceWS, TableWorkspace_sptr targetWS) {
  // Compare the column names.  They must be exactly the same
  vector<string> sourcecolnames = sourceWS->getColumnNames();
  vector<string> targetcolnames = targetWS->getColumnNames();
  if (sourcecolnames.size() != targetcolnames.size()) {
    stringstream errmsg;
    errmsg << "Soruce table workspace " << sourceWS->name()
           << " has different number of columns (" << sourcecolnames.size()
           << ") than target table workspace's (" << targetcolnames.size()
           << ")";
    throw runtime_error(errmsg.str());
  }
  for (size_t i = 0; i < sourcecolnames.size(); ++i) {
    if (sourcecolnames[i].compare(targetcolnames[i])) {
      stringstream errss;
      errss << "Source and target have incompatible column name at column " << i
            << ". "
            << "Column name of source is " << sourcecolnames[i] << "; "
            << "Column name of target is " << targetcolnames[i];
      throw runtime_error(errss.str());
    }
  }

  // Copy over the content
  size_t numrows = sourceWS->rowCount();
  for (size_t i = 0; i < numrows; ++i) {
    double xmin, xmax;
    string speclist;
    TableRow tmprow = sourceWS->getRow(i);
    tmprow >> xmin >> xmax >> speclist;

    TableRow newrow = targetWS->appendRow();
    newrow << xmin << xmax << speclist;
  }

  return;
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:42,代码来源:ExtractMaskToTable.cpp

示例2: processMaskBinWorkspace

/** Process input Mask bin TableWorkspace.
  * It will convert detector IDs list to spectra list
  * @param masktblws :: TableWorkspace for mask bins
  * @param dataws :: MatrixWorkspace to mask
  */
void MaskBinsFromTable::processMaskBinWorkspace(
    TableWorkspace_sptr masktblws, API::MatrixWorkspace_sptr dataws) {
  // Check input
  if (!masktblws)
    throw std::invalid_argument("Input workspace is not a table workspace.");
  g_log.debug() << "Lines of parameters workspace = " << masktblws->rowCount()
                << '\n';

  // Check column names type and sequence
  vector<std::string> colnames = masktblws->getColumnNames();

  // check colum name order
  id_xmin = -1;
  id_xmax = -1;
  id_spec = -1;
  id_dets = -1;
  m_useDetectorID = false;
  m_useSpectrumID = false;

  for (int i = 0; i < static_cast<int>(colnames.size()); ++i) {
    string colname = colnames[i];
    transform(colname.begin(), colname.end(), colname.begin(), ::tolower);
    if (colname.compare("xmin") == 0)
      id_xmin = i;
    else if (colname.compare("xmax") == 0)
      id_xmax = i;
    else if (boost::algorithm::starts_with(colname, "spec")) {
      id_spec = i;
    } else if (boost::algorithm::starts_with(colname, "detectorid")) {
      id_dets = i;
    } else {
      g_log.warning() << "In TableWorkspace " << masktblws->name()
                      << ", column " << i << " with name " << colname
                      << " is not used by MaskBinsFromTable.";
    }
  }

  if (id_xmin < 0 || id_xmax < 0 || id_xmin == id_xmax)
    throw runtime_error("Either Xmin nor Xmax is not given. ");
  if (id_spec == id_dets)
    throw runtime_error("Neither SpectraList nor DetectorIDList is given.");
  else if (id_dets >= 0)
    m_useDetectorID = true;
  else
    m_useSpectrumID = true;

  // Construct vectors for xmin, xmax and spectra-list
  size_t numrows = masktblws->rowCount();
  for (size_t i = 0; i < numrows; ++i) {
    double xmin = masktblws->cell<double>(i, static_cast<size_t>(id_xmin));
    double xmax = masktblws->cell<double>(i, static_cast<size_t>(id_xmax));

    string spectralist;
    if (m_useSpectrumID) {
      spectralist = masktblws->cell<string>(i, static_cast<size_t>(id_spec));
    } else {
      // Convert detectors list to spectra list
      string detidslist =
          masktblws->cell<string>(i, static_cast<size_t>(id_dets));
      spectralist = convertToSpectraList(dataws, detidslist);
    }

    g_log.debug() << "Row " << i << " XMin = " << xmin << "  XMax = " << xmax
                  << " SpectraList = " << spectralist << ".\n";

    // Store to class variables
    m_xminVec.push_back(xmin);
    m_xmaxVec.push_back(xmax);
    m_spectraVec.push_back(spectralist);
  }
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:76,代码来源:MaskBinsFromTable.cpp


注:本文中的TableWorkspace_sptr::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。