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


C++ TableWorkspace_sptr类代码示例

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


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

示例1: parsePeakTableWorkspace

/** Parse table workspace
  */
void RemovePeaks::parsePeakTableWorkspace(TableWorkspace_sptr peaktablews,
                                          vector<double> &vec_peakcentre,
                                          vector<double> &vec_peakfwhm) {
  // Get peak table workspace information
  vector<string> colnames = peaktablews->getColumnNames();
  int index_centre = -1;
  int index_fwhm = -1;
  for (int i = 0; i < static_cast<int>(colnames.size()); ++i) {
    string colname = colnames[i];
    if (colname.compare("TOF_h") == 0)
      index_centre = i;
    else if (colname.compare("FWHM") == 0)
      index_fwhm = i;
  }

  if (index_centre < 0 || index_fwhm < 0) {
    throw runtime_error(
        "Input Bragg peak table workspace does not have TOF_h and/or FWHM");
  }

  // Get values
  size_t numrows = peaktablews->rowCount();
  vec_peakcentre.resize(numrows, 0.);
  vec_peakfwhm.resize(numrows, 0.);

  for (size_t i = 0; i < numrows; ++i) {
    double centre = peaktablews->cell<double>(i, index_centre);
    double fwhm = peaktablews->cell<double>(i, index_fwhm);
    vec_peakcentre[i] = centre;
    vec_peakfwhm[i] = fwhm;
  }

  return;
}
开发者ID:dezed,项目名称:mantid,代码行数:36,代码来源:ProcessBackground.cpp

示例2: createBackgroundFunction

  /** Select background points via a given background function
    */
  void ProcessBackground::execSelectBkgdPoints2()
  {
    // Process properties
    BackgroundFunction_sptr bkgdfunc = createBackgroundFunction(m_bkgdType);
    TableWorkspace_sptr bkgdtablews = getProperty("BackgroundTableWorkspace");

    // Set up background function from table
    size_t numrows = bkgdtablews->rowCount();
    map<string, double> parmap;
    for (size_t i = 0; i < numrows; ++i)
    {
      TableRow row = bkgdtablews->getRow(i);
      string parname;
      double parvalue;
      row >> parname >> parvalue;
      if (parname[0] == 'A')
        parmap.insert(make_pair(parname, parvalue));
    }

    int bkgdorder = static_cast<int>(parmap.size()-1); // A0 - A(n) total n+1 parameters
    bkgdfunc->setAttributeValue("n", bkgdorder);
    for (map<string, double>::iterator mit = parmap.begin(); mit != parmap.end(); ++mit)
    {
      string parname = mit->first;
      double parvalue = mit->second;
      bkgdfunc->setParameter(parname, parvalue);
    }

    // Filter out
    m_outputWS = filterForBackground(bkgdfunc);

    return;
  }
开发者ID:jkrueger1,项目名称:mantid,代码行数:35,代码来源:ProcessBackground.cpp

示例3: createBackgroundFunction

/** Select background points via a given background function
  */
void ProcessBackground::selectFromGivenFunction() {
  // Process properties
  BackgroundFunction_sptr bkgdfunc = createBackgroundFunction(m_bkgdType);
  TableWorkspace_sptr bkgdtablews = getProperty("BackgroundTableWorkspace");

  // Set up background function from table
  size_t numrows = bkgdtablews->rowCount();
  map<string, double> parmap;
  for (size_t i = 0; i < numrows; ++i) {
    TableRow row = bkgdtablews->getRow(i);
    string parname;
    double parvalue;
    row >> parname >> parvalue;
    if (parname[0] == 'A')
      parmap.emplace(parname, parvalue);
  }

  int bkgdorder =
      static_cast<int>(parmap.size() - 1); // A0 - A(n) total n+1 parameters
  bkgdfunc->setAttributeValue("n", bkgdorder);
  for (auto &mit : parmap) {
    string parname = mit.first;
    double parvalue = mit.second;
    bkgdfunc->setParameter(parname, parvalue);
  }

  // Filter out
  m_outputWS = filterForBackground(bkgdfunc);

  return;
}
开发者ID:dezed,项目名称:mantid,代码行数:33,代码来源:ProcessBackground.cpp

示例4: 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;
  }
开发者ID:jkrueger1,项目名称:mantid,代码行数:54,代码来源:GetDetOffsetsMultiPeaks.cpp

示例5: 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;
}
开发者ID:dezed,项目名称:mantid,代码行数:14,代码来源:PoldiPeakCollection.cpp

示例6: getInitializedResultWorkspace

TableWorkspace_sptr PoldiPeakSummary::getSummaryTable(
    const PoldiPeakCollection_sptr &peakCollection) const {
  if (!peakCollection) {
    throw std::invalid_argument(
        "Cannot create summary of a null PoldiPeakCollection.");
  }

  TableWorkspace_sptr peakResultWorkspace = getInitializedResultWorkspace();

  for (size_t i = 0; i < peakCollection->peakCount(); ++i) {
    storePeakSummary(peakResultWorkspace->appendRow(), peakCollection->peak(i));
  }

  return peakResultWorkspace;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:15,代码来源:PoldiPeakSummary.cpp

示例7:

/**
 * Creates Dead Time Table using all the data between begin and end.
 * @param specToLoad :: vector containing the spectrum numbers to load
 * @param deadTimes :: vector containing the corresponding dead times
 * @return Dead Time Table create using the data
 */
TableWorkspace_sptr
LoadMuonNexus1::createDeadTimeTable(std::vector<int> specToLoad,
                                    std::vector<double> deadTimes) {
  TableWorkspace_sptr deadTimeTable =
      boost::dynamic_pointer_cast<TableWorkspace>(
          WorkspaceFactory::Instance().createTable("TableWorkspace"));

  deadTimeTable->addColumn("int", "spectrum");
  deadTimeTable->addColumn("double", "dead-time");

  for (size_t i = 0; i<specToLoad.size(); i++) {
    TableRow row = deadTimeTable->appendRow();
    row << specToLoad[i] << deadTimes[i];
  }

  return deadTimeTable;
}
开发者ID:nimgould,项目名称:mantid,代码行数:23,代码来源:LoadMuonNexus1.cpp

示例8: recoverDataFromLog

void PoldiPeakCollection::recoverDataFromLog(
    const TableWorkspace_sptr &tableWorkspace) {
  LogManager_sptr tableLog = tableWorkspace->logs();

  m_intensityType = intensityTypeFromString(getIntensityTypeFromLog(tableLog));
  m_profileFunctionName = getProfileFunctionNameFromLog(tableLog);
  m_pointGroup = pointGroupFromString(getPointGroupStringFromLog(tableLog));
  m_unitCell = unitCellFromString(getUnitCellStringFromLog(tableLog));
}
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:PoldiPeakCollection.cpp

示例9: dataToTableLog

void PoldiPeakCollection::dataToTableLog(const TableWorkspace_sptr &table) {
  LogManager_sptr tableLog = table->logs();
  tableLog->addProperty<std::string>("IntensityType",
                                     intensityTypeToString(m_intensityType));
  tableLog->addProperty<std::string>("ProfileFunctionName",
                                     m_profileFunctionName);
  tableLog->addProperty<std::string>("PointGroup",
                                     pointGroupToString(m_pointGroup));
  tableLog->addProperty<std::string>("UnitCell",
                                     Geometry::unitCellToStr(m_unitCell));
}
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:PoldiPeakCollection.cpp

示例10: peaksToTable

void PoldiPeakCollection::peaksToTable(const TableWorkspace_sptr &table) {
  for (std::vector<PoldiPeak_sptr>::const_iterator peak = m_peaks.begin();
       peak != m_peaks.end(); ++peak) {
    TableRow newRow = table->appendRow();

    newRow << MillerIndicesIO::toString((*peak)->hkl()) << (*peak)->d().value()
           << (*peak)->d().error() << (*peak)->q().value()
           << (*peak)->q().error() << (*peak)->intensity().value()
           << (*peak)->intensity().error()
           << (*peak)->fwhm(PoldiPeak::Relative).value()
           << (*peak)->fwhm(PoldiPeak::Relative).error();
  }
}
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:PoldiPeakCollection.cpp

示例11: constructFromTableWorkspace

void PoldiPeakCollection::constructFromTableWorkspace(
    const TableWorkspace_sptr &tableWorkspace) {
  if (checkColumns(tableWorkspace)) {
    size_t newPeakCount = tableWorkspace->rowCount();
    m_peaks.resize(newPeakCount);

    recoverDataFromLog(tableWorkspace);

    for (size_t i = 0; i < newPeakCount; ++i) {
      TableRow nextRow = tableWorkspace->getRow(i);
      std::string hklString;
      double d, deltaD, q, deltaQ, intensity, deltaIntensity, fwhm, deltaFwhm;
      nextRow >> hklString >> d >> deltaD >> q >> deltaQ >> intensity >>
          deltaIntensity >> fwhm >> deltaFwhm;

      PoldiPeak_sptr peak = PoldiPeak::create(
          MillerIndicesIO::fromString(hklString), UncertainValue(d, deltaD),
          UncertainValue(intensity, deltaIntensity),
          UncertainValue(fwhm, deltaFwhm));
      m_peaks[i] = peak;
    }
  }
}
开发者ID:mantidproject,项目名称:mantid,代码行数:23,代码来源:PoldiPeakCollection.cpp

示例12: getProperty

/// Create a TableWorkspace for the statistics with appropriate columns or get
/// one from the ADS.
ITableWorkspace_sptr
SortHKL::getStatisticsTable(const std::string &name) const {
  TableWorkspace_sptr tablews;

  // Init or append to a table workspace
  bool append = getProperty("Append");
  if (append && AnalysisDataService::Instance().doesExist(name)) {
    tablews = AnalysisDataService::Instance().retrieveWS<TableWorkspace>(name);
  } else {
    tablews = boost::make_shared<TableWorkspace>();
    tablews->addColumn("str", "Resolution Shell");
    tablews->addColumn("int", "No. of Unique Reflections");
    tablews->addColumn("double", "Resolution Min");
    tablews->addColumn("double", "Resolution Max");
    tablews->addColumn("double", "Multiplicity");
    tablews->addColumn("double", "Mean ((I)/sd(I))");
    tablews->addColumn("double", "Rmerge");
    tablews->addColumn("double", "Rpim");
    tablews->addColumn("double", "Data Completeness");
  }

  return tablews;
}
开发者ID:stuartcampbell,项目名称:mantid,代码行数:25,代码来源:SortHKL.cpp

示例13: 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

示例14: UNUSED_ARG

int PeakIntegration::fitneighbours(int ipeak, std::string det_name, int x0,
                                   int y0, int idet, double qspan,
                                   PeaksWorkspace_sptr &Peaks,
                                   const detid2index_map &pixel_to_wi) {
  UNUSED_ARG(ipeak);
  UNUSED_ARG(det_name);
  UNUSED_ARG(x0);
  UNUSED_ARG(y0);
  Geometry::IPeak &peak = Peaks->getPeak(ipeak);
  // Number of slices
  int TOFmax = 0;

  IAlgorithm_sptr slice_alg = createChildAlgorithm("IntegratePeakTimeSlices");
  slice_alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", inputW);
  std::ostringstream tab_str;
  tab_str << "LogTable" << ipeak;

  slice_alg->setPropertyValue("OutputWorkspace", tab_str.str());
  slice_alg->setProperty<PeaksWorkspace_sptr>("Peaks", Peaks);
  slice_alg->setProperty("PeakIndex", ipeak);
  slice_alg->setProperty("PeakQspan", qspan);

  int nPixels = std::max<int>(0, getProperty("NBadEdgePixels"));

  slice_alg->setProperty("NBadEdgePixels", nPixels);
  slice_alg->executeAsChildAlg();
  Mantid::API::MemoryManager::Instance().releaseFreeMemory();

  MantidVec &Xout = outputW->dataX(idet);
  MantidVec &Yout = outputW->dataY(idet);
  MantidVec &Eout = outputW->dataE(idet);
  TableWorkspace_sptr logtable = slice_alg->getProperty("OutputWorkspace");

  peak.setIntensity(slice_alg->getProperty("Intensity"));
  peak.setSigmaIntensity(slice_alg->getProperty("SigmaIntensity"));

  TOFmax = static_cast<int>(logtable->rowCount());
  for (int iTOF = 0; iTOF < TOFmax; iTOF++) {
    Xout[iTOF] = logtable->getRef<double>(std::string("Time"), iTOF);
    if (m_IC) // Ikeda-Carpenter fit
    {
      Yout[iTOF] = logtable->getRef<double>(std::string("TotIntensity"), iTOF);
      Eout[iTOF] =
          logtable->getRef<double>(std::string("TotIntensityError"), iTOF);
    } else {
      Yout[iTOF] = logtable->getRef<double>(std::string("ISAWIntensity"), iTOF);
      Eout[iTOF] =
          logtable->getRef<double>(std::string("ISAWIntensityError"), iTOF);
    }
  }

  outputW->getSpectrum(idet)->clearDetectorIDs();
  // Find the pixel ID at that XY position on the rectangular detector
  int pixelID = peak.getDetectorID(); // det->getAtXY(x0,y0)->getID();

  // Find the corresponding workspace index, if any
  auto wiEntry = pixel_to_wi.find(pixelID);
  if (wiEntry != pixel_to_wi.end()) {
    size_t wi = wiEntry->second;
    // Set detectorIDs
    outputW->getSpectrum(idet)
        ->addDetectorIDs(inputW->getSpectrum(wi)->getDetectorIDs());
  }

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

示例15: runtime_error

  /** Parse table workspace to a map of Parameters
    */
  void RefinePowderInstrumentParameters2::parseTableWorkspace(TableWorkspace_sptr tablews,
                                                              map<string, Parameter>& parammap)
  {
    // 1. Process Table column names
    std::vector<std::string> colnames = tablews->getColumnNames();
    map<string, size_t> colnamedict;
    convertToDict(colnames, colnamedict);

    int iname = getStringIndex(colnamedict, "Name");
    int ivalue = getStringIndex(colnamedict, "Value");
    int ifit = getStringIndex(colnamedict, "FitOrTie");
    int imin = getStringIndex(colnamedict, "Min");
    int imax = getStringIndex(colnamedict, "Max");
    int istep = getStringIndex(colnamedict, "StepSize");

    if (iname < 0 || ivalue < 0 || ifit < 0)
      throw runtime_error("TableWorkspace does not have column Name, Value and/or Fit.");

    // 3. Parse
    size_t numrows = tablews->rowCount();
    for (size_t irow = 0; irow < numrows; ++irow)
    {
      string parname = tablews->cell<string>(irow, iname);
      double parvalue = tablews->cell<double>(irow, ivalue);
      string fitq = tablews->cell<string>(irow, ifit);

      double minvalue;
      if (imin >= 0)
        minvalue = tablews->cell<double>(irow, imin);
      else
        minvalue = -DBL_MAX;

      double maxvalue;
      if (imax >= 0)
        maxvalue = tablews->cell<double>(irow, imax);
      else
        maxvalue = DBL_MAX;

      double stepsize;
      if (istep >= 0)
        stepsize = tablews->cell<double>(irow, istep);
      else
        stepsize = 1.0;

      Parameter newpar;
      newpar.name = parname;
      newpar.value = parvalue;
      newpar.minvalue = minvalue;
      newpar.maxvalue = maxvalue;
      newpar.stepsize = stepsize;

      // If empty string, fit is default to be false
      bool fit = false;
      if (fitq.size() > 0)
      {
        if (fitq[0] == 'F' || fitq[0] == 'f')
          fit = true;
      }
      newpar.fit = fit;

      parammap.insert(make_pair(parname, newpar));
    }

    return;
  }
开发者ID:trnielsen,项目名称:mantid,代码行数:67,代码来源:RefinePowderInstrumentParameters2.cpp


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