void EnggDiffFittingModel::mergeTables( const API::ITableWorkspace_sptr tableToCopy, API::ITableWorkspace_sptr targetTable) const { for (size_t i = 0; i < tableToCopy->rowCount(); ++i) { API::TableRow rowToCopy = tableToCopy->getRow(i); API::TableRow newRow = targetTable->appendRow(); for (size_t j = 0; j < tableToCopy->columnCount(); ++j) { double valueToCopy; rowToCopy >> valueToCopy; newRow << valueToCopy; } } }
/* This function fills in a list of the row numbers starting 0 of the parameters in the table workspace, so one can find the position in a column of the value of the given parameter. */ void LoadFullprofResolution::getTableRowNumbers( const API::ITableWorkspace_sptr &tablews, std::map<std::string, size_t> ¶mmap) { parammap.clear(); size_t numrows = tablews->rowCount(); for (size_t i = 0; i < numrows; ++i) { TableRow row = tablews->getRow(i); std::string name; row >> name; parammap.emplace(name, i); } return; }
void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr workspace, std::ofstream &file, const size_t columnSize) { for (size_t rowIndex = 0; rowIndex < workspace->rowCount(); ++rowIndex) { TableRow row = workspace->getRow(rowIndex); for (size_t columnIndex = 0; columnIndex < columnSize; columnIndex++) { const auto row_str = boost::lexical_cast<std::string>(row.Double(columnIndex)); g_log.debug() << row_str << std::endl; if (columnIndex == columnSize - 1) writeVal(row_str, file, true); else writeVal(row_str, file, false); } } }
/** Load PhaseTable file to a vector of HistData. * @param phaseTable :: [input] phase table containing detector info * @param deadTimeTable :: [output] phase table containing dead times */ void PhaseQuadMuon::loadPhaseTable(API::ITableWorkspace_sptr phaseTable, API::ITableWorkspace_sptr deadTimeTable) { if ( phaseTable->rowCount() ) { if ( phaseTable->columnCount()<4 ) { throw std::invalid_argument("PhaseQuad: PhaseTable must contain at least four columns"); } // Check number of histograms in inputWs match number of detectors in phase table if (m_nHist != static_cast<int>(phaseTable->rowCount())) { throw std::runtime_error("PhaseQuad: Number of histograms in phase table does not match number of spectra in workspace"); } for (size_t i=0; i<phaseTable->rowCount(); ++i) { API::TableRow phaseRow = phaseTable->getRow(i); // The first three columns go to m_histData HistData tempHist; tempHist.detOK = phaseRow.Bool(0); tempHist.alpha = phaseRow.Double(1); tempHist.phi = phaseRow.Double(2); m_histData.push_back(tempHist); // The last column goes to deadTimeTable API::TableRow deadRow = deadTimeTable->appendRow(); deadRow << static_cast<int>(i)+1 << phaseRow.Double(3); } } else { throw std::invalid_argument("PhaseQuad: PhaseTable is empty"); } }