本文整理汇总了C++中api::ITableWorkspace_sptr::appendRow方法的典型用法代码示例。如果您正苦于以下问题:C++ ITableWorkspace_sptr::appendRow方法的具体用法?C++ ITableWorkspace_sptr::appendRow怎么用?C++ ITableWorkspace_sptr::appendRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::ITableWorkspace_sptr
的用法示例。
在下文中一共展示了ITableWorkspace_sptr::appendRow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveInvestigations
/** This method saves investigations to a table workspace
* @param investigations :: a vector containing investigation data
* @param outputws :: shared pointer to output workspace
*/
void CICatHelper::saveInvestigations(
const std::vector<ns1__investigation *> &investigations,
API::ITableWorkspace_sptr &outputws) {
try {
std::vector<ns1__investigation *>::const_iterator citr;
for (citr = investigations.begin(); citr != investigations.end(); ++citr) {
API::TableRow t = outputws->appendRow();
std::string id = std::to_string(*(*citr)->id);
savetoTableWorkspace(&id, t);
savetoTableWorkspace((*citr)->facility, t);
savetoTableWorkspace((*citr)->title, t);
savetoTableWorkspace((*citr)->instrument, t);
savetoTableWorkspace((*citr)->invParamValue, t);
std::string startDate = std::to_string(*(*citr)->invStartDate);
savetoTableWorkspace(&startDate, t);
std::string endDate = std::to_string(*(*citr)->invEndDate);
savetoTableWorkspace(&endDate, t);
std::string sessionID = m_session->getSessionId();
savetoTableWorkspace(&sessionID, t);
}
} catch (std::runtime_error &) {
throw std::runtime_error(
"Error when saving the ICat Search Results data to Workspace");
}
}
示例2: mergeTables
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;
}
}
}
示例3: runtime_error
/**
* Loops through the response vector and saves the datasets details to a table
* workspace.
* @param response :: A vector containing the results of the search query.
* @param outputws :: Shared pointer to output workspace.
*/
void ICat4Catalog::saveDataSets(std::vector<xsd__anyType *> response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
// Add rows headers to the output workspace.
outputws->addColumn("long64", "ID");
outputws->addColumn("str", "Name");
outputws->addColumn("str", "Description");
outputws->addColumn("str", "Type");
outputws->addColumn("str", "Related investigation ID");
outputws->addColumn("size_t", "Number of datafiles");
}
std::string emptyCell;
for (auto &iter : response) {
ns1__dataset *dataset = dynamic_cast<ns1__dataset *>(iter);
if (dataset) {
API::TableRow table = outputws->appendRow();
savetoTableWorkspace(dataset->id, table);
savetoTableWorkspace(dataset->name, table);
if (dataset->description)
savetoTableWorkspace(dataset->description, table);
else
savetoTableWorkspace(&emptyCell, table);
if (dataset->type)
savetoTableWorkspace(dataset->type->name, table);
else
savetoTableWorkspace(&emptyCell, table);
if (dataset->investigation)
savetoTableWorkspace(dataset->investigation->name, table);
else
savetoTableWorkspace(&emptyCell, table);
size_t datafileCount = dataset->datafiles.size();
savetoTableWorkspace(&datafileCount, table);
} else {
throw std::runtime_error("ICat4Catalog::saveDataSets expected a dataset. "
"Please contact the Mantid development team.");
}
}
}
示例4: saveDataSets
/** This method loops through the response return_vector and saves the datasets details to a table workspace
* @param response :: const reference to response object
* @param outputws :: shred pointer to workspace
* @returns shared pointer to table workspace which stores the data
*/
void CICatHelper::saveDataSets(const ns1__getInvestigationIncludesResponse& response,API::ITableWorkspace_sptr& outputws)
{
//create table workspace
if (outputws->getColumnNames().empty())
{
outputws->addColumn("str","Name");//File name
outputws->addColumn("str","Status");
outputws->addColumn("str","Type");
outputws->addColumn("str","Description");
outputws->addColumn("long64","Sample Id");
}
try
{
std::vector<ns1__dataset*> datasetVec;
datasetVec.assign((response.return_)->datasetCollection.begin(),(response.return_)->datasetCollection.end());
std::vector<ns1__dataset*>::const_iterator dataset_citr;
for(dataset_citr=datasetVec.begin();dataset_citr!=datasetVec.end();++dataset_citr)
{
API::TableRow t = outputws->appendRow();
// DataSet Name
savetoTableWorkspace((*dataset_citr)->name,t);
// DataSet Status
savetoTableWorkspace((*dataset_citr)->datasetStatus,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->datasetType,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->description,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->sampleId,t);
}
}
catch(std::runtime_error& )
{
throw;
}
//return outputws;
}
示例5: extractDetectorInfo
/** Extracts detector asymmetries and phases from fitting results
* and adds a new row to the results table with them
* @param paramTab :: [input] Output parameter table resulting from the fit
* @param resultsTab :: [input] Results table to update with a new row
* @param spectrumNumber :: [input] Spectrum number
*/
void CalMuonDetectorPhases::extractDetectorInfo(
const API::ITableWorkspace_sptr ¶mTab,
const API::ITableWorkspace_sptr &resultsTab,
const specnum_t spectrumNumber) {
double asym = paramTab->Double(0, 1);
double phase = paramTab->Double(2, 1);
// If asym<0, take the absolute value and add \pi to phase
// f(x) = A * sin( w * x + p) = -A * sin( w * x + p + PI)
if (asym < 0) {
asym = -asym;
phase = phase + M_PI;
}
// Now convert phases to interval [0, 2PI)
int factor = static_cast<int>(floor(phase / 2 / M_PI));
if (factor) {
phase = phase - factor * 2 * M_PI;
}
// Copy parameters to new row in results table
API::TableRow row = resultsTab->appendRow();
row << static_cast<int>(spectrumNumber) << asym << phase;
}
示例6: loadPhaseTable
/** 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");
}
}
示例7: saveInvestigationIncludesResponse
/**
* This method loops through the response return_vector and saves the datafile
* details to a table workspace
* @param response :: const reference to response object
* @param outputws :: shared pointer to table workspace which stores the data
*/
void CICatHelper::saveInvestigationIncludesResponse(
const ns1__getInvestigationIncludesResponse &response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
outputws->addColumn("str", "Name");
outputws->addColumn("str", "Location");
outputws->addColumn("str", "Create Time");
outputws->addColumn("long64", "Id");
outputws->addColumn("long64", "File size(bytes)");
outputws->addColumn("str", "File size");
outputws->addColumn("str", "Description");
}
try {
std::vector<ns1__dataset *> datasetVec;
datasetVec.assign((response.return_)->datasetCollection.begin(),
(response.return_)->datasetCollection.end());
if (datasetVec.empty()) {
throw std::runtime_error("No data files exists in the ICAT database for "
"the selected investigation");
}
std::vector<ns1__dataset *>::const_iterator dataset_citr;
for (dataset_citr = datasetVec.begin(); dataset_citr != datasetVec.end();
++dataset_citr) {
std::vector<ns1__datafile *> datafileVec;
datafileVec.assign((*dataset_citr)->datafileCollection.begin(),
(*dataset_citr)->datafileCollection.end());
if (datafileVec.empty()) {
throw std::runtime_error("No data files exists in the ICAT database "
"for the selected investigation ");
}
std::vector<ns1__datafile *>::const_iterator datafile_citr;
for (datafile_citr = datafileVec.begin();
datafile_citr != datafileVec.end(); ++datafile_citr) {
API::TableRow t = outputws->appendRow();
// File Name
savetoTableWorkspace((*datafile_citr)->name, t);
savetoTableWorkspace((*datafile_citr)->location, t);
// File creation Time.
std::string *creationtime = nullptr;
if ((*datafile_citr)->datafileCreateTime != nullptr) {
time_t crtime = *(*datafile_citr)->datafileCreateTime;
char temp[25];
strftime(temp, 25, "%Y-%b-%d %H:%M:%S", localtime(&crtime));
std::string ftime(temp);
creationtime = new std::string;
creationtime->assign(ftime);
}
savetoTableWorkspace(creationtime, t);
if (creationtime)
delete creationtime;
//
savetoTableWorkspace((*datafile_citr)->id, t);
LONG64 fileSize =
boost::lexical_cast<LONG64>(*(*datafile_citr)->fileSize);
savetoTableWorkspace(&fileSize, t);
savetoTableWorkspace((*datafile_citr)->description, t);
}
}
} catch (std::runtime_error &) {
throw;
}
}
示例8: loadPhaseList
/** Load PhaseList file to a vector of HistData and a deadTimeTable.
* @param filename :: [input] phase list .inf filename
* @param deadTimeTable :: [output] table containing dead times
*/
void PhaseQuadMuon::loadPhaseList(const std::string& filename, API::ITableWorkspace_sptr deadTimeTable )
{
std::ifstream input(filename.c_str(), std::ios_base::in);
if (input.is_open())
{
if ( input.eof() )
{
throw Exception::FileError("PhaseQuad: File is empty.", filename);
}
else
{
std::string line;
// Header of .INF file is as follows:
//
// Comment on the output file
// Top row of numbers are:
// #histos, typ. first good bin#, typ. bin# when pulse over, mean lag.
// Tabulated numbers are, per histogram:
// det ok, asymmetry, phase, lag, deadtime_c, deadtime_m.
//
std::getline( input, line ); // Skip first line in header
std::getline( input, line ); // Skip second line
std::getline( input, line ); // ...
std::getline( input, line );
std::getline( input, line );
// Read first useful line
int nHist;
input >> nHist >> m_tValid >> m_tPulseOver >> m_meanLag;
if (m_nHist!=nHist)
{
throw std::runtime_error("PhaseQuad: Number of histograms in phase list does not match number of spectra in workspace");
}
// Read histogram data
int cont=0;
HistData tempData;
double lag, dead, deadm;
while( input >> tempData.detOK >> tempData.alpha >> tempData.phi >> lag >> dead >> deadm )
{
m_histData.push_back (tempData);
cont++;
// Add dead time to deadTimeTable
API::TableRow row = deadTimeTable->appendRow();
row << cont << dead;
}
if ( cont != m_nHist )
{
if ( cont < m_nHist )
{
throw Exception::FileError("PhaseQuad: Lines missing in phase list", filename);
}
else
{
throw Exception::FileError("PhaseQuad: Extra lines in phase list", filename);
}
}
}
}
else
{
// Throw exception if file cannot be opened
throw std::runtime_error("PhaseQuad: Unable to open PhaseList");