本文整理汇总了C++中api::ITableWorkspace_sptr::getColumnNames方法的典型用法代码示例。如果您正苦于以下问题:C++ ITableWorkspace_sptr::getColumnNames方法的具体用法?C++ ITableWorkspace_sptr::getColumnNames怎么用?C++ ITableWorkspace_sptr::getColumnNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::ITableWorkspace_sptr
的用法示例。
在下文中一共展示了ITableWorkspace_sptr::getColumnNames方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSearchRessults
/** This method saves the search response( investigations )data to a table
* workspace
* @param response :: const reference to response object
* @param outputws :: shared pointer to output workspace
*/
void CICatHelper::saveSearchRessults(
const ns1__searchByAdvancedPaginationResponse &response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
outputws->addColumn("str", "Investigation id");
outputws->addColumn("str", "Facility");
outputws->addColumn("str", "Title");
outputws->addColumn("str", "Instrument");
outputws->addColumn("str", "Run range");
outputws->addColumn("str", "Start date");
outputws->addColumn("str", "End date");
outputws->addColumn("str", "SessionID");
}
saveInvestigations(response.return_, outputws);
}
示例2: 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.");
}
}
}
示例3: 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;
}
示例4: 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;
}
}
示例5: calculateEISF
/**
* Calculates the EISF if the fit includes a Delta function
* @param tableWs - The TableWorkspace to append the EISF calculation to
*/
void ConvolutionFitSequential::calculateEISF(
API::ITableWorkspace_sptr &tableWs) {
// Get height data from parameter table
const auto columns = tableWs->getColumnNames();
const auto height = searchForFitParams("Height", columns).at(0);
const auto heightErr = searchForFitParams("Height_Err", columns).at(0);
auto heightY = tableWs->getColumn(height)->numeric_fill<>();
auto heightE = tableWs->getColumn(heightErr)->numeric_fill<>();
// Get amplitude column names
const auto ampNames = searchForFitParams("Amplitude", columns);
const auto ampErrorNames = searchForFitParams("Amplitude_Err", columns);
// For each lorentzian, calculate EISF
size_t maxSize = ampNames.size();
if (ampErrorNames.size() > maxSize) {
maxSize = ampErrorNames.size();
}
for (size_t i = 0; i < maxSize; i++) {
// Get amplitude from column in table workspace
const auto ampName = ampNames.at(i);
auto ampY = tableWs->getColumn(ampName)->numeric_fill<>();
const auto ampErrorName = ampErrorNames.at(i);
auto ampErr = tableWs->getColumn(ampErrorName)->numeric_fill<>();
// Calculate EISF and EISF error
// total = heightY + ampY
auto total = cloneVector(heightY);
std::transform(total.begin(), total.end(), ampY.begin(), total.begin(),
std::plus<double>());
// eisfY = heightY / total
auto eisfY = cloneVector(heightY);
std::transform(eisfY.begin(), eisfY.end(), total.begin(), eisfY.begin(),
std::divides<double>());
// heightE squared
auto heightESq = cloneVector(heightE);
heightESq = squareVector(heightESq);
// ampErr squared
auto ampErrSq = cloneVector(ampErr);
ampErrSq = squareVector(ampErrSq);
// totalErr = heightE squared + ampErr squared
auto totalErr = cloneVector(heightESq);
std::transform(totalErr.begin(), totalErr.end(), ampErrSq.begin(),
totalErr.begin(), std::plus<double>());
// heightY squared
auto heightYSq = cloneVector(heightY);
heightYSq = squareVector(heightYSq);
// total Squared
auto totalSq = cloneVector(total);
totalSq = squareVector(totalSq);
// errOverTotalSq = totalErr / total squared
auto errOverTotalSq = cloneVector(totalErr);
std::transform(errOverTotalSq.begin(), errOverTotalSq.end(),
totalSq.begin(), errOverTotalSq.begin(),
std::divides<double>());
// heightESqOverYSq = heightESq / heightYSq
auto heightESqOverYSq = cloneVector(heightESq);
std::transform(heightESqOverYSq.begin(), heightESqOverYSq.end(),
heightYSq.begin(), heightESqOverYSq.begin(),
std::divides<double>());
// sqrtESqOverYSq = squareRoot( heightESqOverYSq )
auto sqrtESqOverYSq = cloneVector(heightESqOverYSq);
std::transform(sqrtESqOverYSq.begin(), sqrtESqOverYSq.end(),
sqrtESqOverYSq.begin(),
static_cast<double (*)(double)>(sqrt));
// eisfYSumRoot = eisfY * sqrtESqOverYSq
auto eisfYSumRoot = cloneVector(eisfY);
std::transform(eisfYSumRoot.begin(), eisfYSumRoot.end(),
sqrtESqOverYSq.begin(), eisfYSumRoot.begin(),
std::multiplies<double>());
// eisfErr = eisfYSumRoot + errOverTotalSq
auto eisfErr = cloneVector(eisfYSumRoot);
std::transform(eisfErr.begin(), eisfErr.end(), errOverTotalSq.begin(),
eisfErr.begin(), std::plus<double>());
// Append the calculated values to the table workspace
auto columnName =
ampName.substr(0, (ampName.size() - std::string("Amplitude").size()));
columnName += "EISF";
auto errorColumnName = ampErrorName.substr(
0, (ampErrorName.size() - std::string("Amplitude_Err").size()));
errorColumnName += "EISF_Err";
tableWs->addColumn("double", columnName);
tableWs->addColumn("double", errorColumnName);
size_t maxEisf = eisfY.size();
if (eisfErr.size() > maxEisf) {
maxEisf = eisfErr.size();
}
Column_sptr col = tableWs->getColumn(columnName);
Column_sptr errCol = tableWs->getColumn(errorColumnName);
for (size_t j = 0; j < maxEisf; j++) {
col->cell<double>(j) = eisfY.at(j);
errCol->cell<double>(j) = eisfErr.at(j);
}
//.........这里部分代码省略.........
示例6: invalid_argument
/** Forms the quadrature phase signal (squashogram)
* @param ws :: [input] workspace containing the measured spectra
* @param phase :: [input] table workspace containing the detector phases
* @param n0 :: [input] vector containing the normalization constants
* @return :: workspace containing the quadrature phase signal
*/
API::MatrixWorkspace_sptr
PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws,
const API::ITableWorkspace_sptr &phase,
const std::vector<double> &n0) {
// Poisson limit: below this number we consider we don't have enough
// statistics
// to apply sqrt(N). This is an arbitrary number used in the original code
// provided by scientists
const double poissonLimit = 30.;
// Muon life time in microseconds
const double muLife = PhysicalConstants::MuonLifetime * 1e6;
const size_t nspec = ws->getNumberHistograms();
if (n0.size() != nspec) {
throw std::invalid_argument("Invalid normalization constants");
}
auto names = phase->getColumnNames();
for (auto &name : names) {
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
}
auto phaseIndex = findName(phaseNames, names);
auto asymmetryIndex = findName(asymmNames, names);
// Get the maximum asymmetry
double maxAsym = 0.;
for (size_t h = 0; h < nspec; h++) {
if (phase->Double(h, asymmetryIndex) > maxAsym &&
phase->Double(h, asymmetryIndex) != ASYMM_ERROR) {
maxAsym = phase->Double(h, asymmetryIndex);
}
}
if (maxAsym == 0.0) {
throw std::invalid_argument("Invalid detector asymmetries");
}
std::vector<bool> emptySpectrum;
emptySpectrum.reserve(nspec);
std::vector<double> aj, bj;
{
// Calculate coefficients aj, bj
double sxx = 0.;
double syy = 0.;
double sxy = 0.;
for (size_t h = 0; h < nspec; h++) {
emptySpectrum.push_back(
std::all_of(ws->y(h).begin(), ws->y(h).end(),
[](double value) { return value == 0.; }));
if (!emptySpectrum[h]) {
const double asym = phase->Double(h, asymmetryIndex) / maxAsym;
const double phi = phase->Double(h, phaseIndex);
const double X = n0[h] * asym * cos(phi);
const double Y = n0[h] * asym * sin(phi);
sxx += X * X;
syy += Y * Y;
sxy += X * Y;
}
}
const double lam1 = 2 * syy / (sxx * syy - sxy * sxy);
const double mu1 = 2 * sxy / (sxy * sxy - sxx * syy);
const double lam2 = 2 * sxy / (sxy * sxy - sxx * syy);
const double mu2 = 2 * sxx / (sxx * syy - sxy * sxy);
for (size_t h = 0; h < nspec; h++) {
if (emptySpectrum[h]) {
aj.push_back(0.0);
bj.push_back(0.0);
} else {
const double asym = phase->Double(h, asymmetryIndex) / maxAsym;
const double phi = phase->Double(h, phaseIndex);
const double X = n0[h] * asym * cos(phi);
const double Y = n0[h] * asym * sin(phi);
aj.push_back((lam1 * X + mu1 * Y) * 0.5);
bj.push_back((lam2 * X + mu2 * Y) * 0.5);
}
}
}
const size_t npoints = ws->blocksize();
// Create and populate output workspace
API::MatrixWorkspace_sptr ows =
API::WorkspaceFactory::Instance().create(ws, 2, npoints + 1, npoints);
// X
ows->setSharedX(0, ws->sharedX(0));
ows->setSharedX(1, ws->sharedX(0));
// Phase quadrature
auto &realY = ows->mutableY(0);
auto &imagY = ows->mutableY(1);
//.........这里部分代码省略.........